i have a question about compile a programme, here is the code:
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
ABAddressBook * book = [ABAddressBook sharedAddressBook];
NSArray * people = [book people];
int count = [people count];
int i;
for (i = 0; i < count; i++) {
ABPerson * person = [people objectAtIndex:i];
NSString * firstName = [person valueForProperty"First"];
NSString * lastName = [person valueForProperty"Last"];
printf("%s %s\n",
[lastName UTF8String],
[firstName UTF8String]);
}
[pool drain];
return 0;
}
WHY i have to explicitly explicitly add AddressBook.framework to add to the project(from menu Project->Add to project)? i have already import it in my code.
if i deleted the line #import <Foundation/Foundation.h>, nothing happened, but without the line #import <AddressBook/AddressBook.h>, error occurred. WHY?
#import <Foundation/Foundation.h>
#import <AddressBook/AddressBook.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
ABAddressBook * book = [ABAddressBook sharedAddressBook];
NSArray * people = [book people];
int count = [people count];
int i;
for (i = 0; i < count; i++) {
ABPerson * person = [people objectAtIndex:i];
NSString * firstName = [person valueForProperty"First"];
NSString * lastName = [person valueForProperty"Last"];
printf("%s %s\n",
[lastName UTF8String],
[firstName UTF8String]);
}
[pool drain];
return 0;
}
WHY i have to explicitly explicitly add AddressBook.framework to add to the project(from menu Project->Add to project)? i have already import it in my code.
if i deleted the line #import <Foundation/Foundation.h>, nothing happened, but without the line #import <AddressBook/AddressBook.h>, error occurred. WHY?