[英]iphone iCloud app crashes when compiling on iOS 4
I'd like to use an iCloud, but when I compile the app on iOS 4.3 Simulator it crashes. 我想使用iCloud,但是当我在iOS 4.3 Simulator上编译应用程序时会崩溃。
dyld: Symbol not found: _OBJC_CLASS_$_NSMetadataQuery dyld:找不到符号:_OBJC_CLASS _ $ _ NSMetadataQuery
What should I do to make it working on iOS 3, 4, and 5? 我应该怎么做才能使其在iOS 3、4和5上运行?
my sulotion is: 我的推测是:
Where have NSMetadataQuery change to id: ex NSMetadataQuery在哪里更改为id:ex
normal : - (void)loadData:(NSMetadataQuery *)query; 正常:-(void)loadData:(NSMetadataQuery *)query; change to: - (void)loadData:(id)query; 更改为:-(void)loadData:(id)query;
normal: @property (retain, nonatomic) NSMetadataQuery *query; 正常:@property(保留,非原子)NSMetadataQuery * query; change to: @property (retain, nonatomic) id query; 更改为:@property(保留,非原子)id查询;
and check iCloud available: 并检查可用的iCloud:
if ([[NSFileManager defaultManager] respondsToSelector:@selector(URLForUbiquityContainerIdentifier:)]) {
NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
// Code for access iCloud here
}
}
When use NSMetadataQuery: 使用NSMetadataQuery时:
id _query = [[NSClassFromString(@"NSMetadataQuery") alloc] init];
// Some code here
[_query startQuery];
Have fun (^_^) 玩得开心(^_^)
The usual way would be to compile it with iOS 5 SDK and setting the deployment target to the oldest iOS Version you'd like it to work with. 通常的方法是使用iOS 5 SDK进行编译,然后将部署目标设置为您希望使用的最旧的iOS版本。 It's up to you though to check at runtime on which classes and methods are available to the current system. 您可以在运行时检查当前系统可以使用哪些类和方法。 A user on iOS 4 for example will not be able to use functions that only ship with iOS 5. 例如,iOS 4上的用户将无法使用iOS 5附带的功能。
To check the availability of classes do: 要检查类的可用性,请执行以下操作:
if ( NSClassFromString(@"NSMetadataQuery") != nil ) {
//do stuff with NSMetadataQuery here
}
To check the availability of methods do: 要检查方法的可用性,请执行以下操作:
if ( [myObject respondsToSelector:@selector(doSomething)] ) {
//call doSomething on myObject
}
这些API是与ios5一起启动的,因此您不能在模拟器4或更低的模拟器上运行它,但要发布,可以设置它应该支持的ios系列的最低部署目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.