使用ARC项目中的非ARC库的方法?
我使用的是非常棒的非ARC项目: https : //github.com/boredzo/iso-8601-date-formatter
我试图从这个在ARC项目中是非ARC的库中使用下面的方法:
- (NSDate *) dateFromString:(NSString *)string timeZone:(out NSTimeZone **)outTimeZone;
我努力了:
group.updatedAt = [formatter dateFromString:someString timeZone:[NSTimeZone localTimeZone]]; group.updatedAt = [formatter dateFromString:someString timeZone:*__autorelease [NSTimeZone localTimeZone]]; group.updatedAt = [formatter dateFromString:someString timeZone:(*__autoreleasing [NSTimeZone localTimeZone]] *); group.updatedAt = [formatter dateFromString:someString timeZone:[[NSTimeZone localTimeZone] autorelease]];
请注意,我对iOS相当新,所以我没有任何内存pipe理的经验。
但是,所有这些尝试,我收到以下错误信息:
Implicit conversion of an Objective-C pointer to 'NSTimeZone *__autoreleasing *' is disallowed with ARC
那么如何在ARC项目中使用非ARC库的方法呢?
NSTimeZone
是一个输出参数,所以你需要传递一个指针给指针,像这样:
NSTimeZone *theTimeZone = nil; group.updatedAt = [formatter dateFromString:someString timeZone:&theTimeZone];
当函数返回时, theTimeZone
将被设置为函数的输出值。