yes, it will crash. But there are ways to prevent this.
Yesterday I did something similar with Event Kit.
I created my own EventHandler object that returns nil in init if there is no Event Kit. Calls to nil are perfectly legal so this abstraction class prevents crashes on iOS3. And I don't need to do the NSClassFromString check for every call I make.
Due to lack of iOS3 devices I couldn't test it yet, but I hope it'll work.
- (id)init {
self = [super init];
if (self) {
Class eventKitClass = NSClassFromString(@"EKEventStore");
if(eventKitClass) {
// iOS4++
// more init
}
else {
// iOS3
[self release];
return nil;
}
}
return self;
}
you have to weak link the Event Kit framework. [Targets/YourTarget/Get Info/General]
EDIT: I misread your question, you aren't asking about the event kit. But the approach works for the adressbook framework too.
EDIT2: Since addressbook was available since iOS 2.0 my approach is useless for you.
You have to use
if ([foo respondsToSelector:@selector(doSomething:)]) {
[foo doSomething:bar];
}
for each call you make that might not be present in iOS3. Like the other answerer said.