0ny*_*nyx 0 iphone ftp xcode objective-c automatic-ref-counting
我有一个通过FTP下载的NSMutableArray.数组中的元素是CFSTPStream 资源常量,类型为CFStringRef.
我想从"kCFFTPResourceName"常量创建一个String.然而,作为Objective C和iphone开发的新手,我正在努力.
我所做的一切都导致ARC投掷适合或错误,如:
2013-01-03 15:31:44.874 Street Light Reporter[1382:11603] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6e1e930
2013-01-03 15:31:44.875 Street Light Reporter[1382:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x6e1e930'
Run Code Online (Sandbox Code Playgroud)
我最近的尝试是:CFStringRef*c = [ar objectAtIndex:4]; 哪个不起作用有以下两个原因:
Incompatible pointer types initializing 'CFStringRef *' (aka 'const struct __CFString **') with an expression of type 'id'
Run Code Online (Sandbox Code Playgroud)
和
Implicit conversion of an Objective-C pointer to 'CFStringRef *' (aka 'const struct __CFString **') is disallowed with ARC
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种类型转换和乱码(__bridge)以及诸如此类而我没有运气.
有人可以帮帮我吗?任何帮助将不胜感激.
CFStringRef已经是一个指针,你不需要这个星号.此外,您可以将CFStringRef强制转换为NSString,它将正常工作,并且更容易使用.这称为免费桥接.如果您仍需要CFStringRef:
弧:
CFStringRef c = (__bridge CFStringRef)([ar objectAtIndex:4]);
Run Code Online (Sandbox Code Playgroud)
非弧形
CFStringRef c = (CFStringRef)([ar objectAtIndex:4]);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
865 次 |
| 最近记录: |