I have an app that is using the ABAdressBook
API & NSFileManager
.
When i'm running the application from the command line - the API doesn't seems to retrieve
the AddressBook/NSFileManager
information - but when i run it from the springboard - it does show me the information required.
Is it because my app doesn't have a UI when it run from the command line?
int main(int argc, char *argv[])
{
@autoreleasepool
{
printf("HELLO TEST\n");
NSLog(@"---------");
NSMutableArray* dbList = [[NSMutableArray alloc] init];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"file manager address is %@",fileManager);
NSDirectoryEnumerator *dirnum = [fileManager enumeratorAtPath: @"/private/"];
NSLog(@"dirNum is %@",dirnum);
NSString *nextItem = [NSString string];
while( (nextItem = [dirnum nextObject])) {
if ([[nextItem pathExtension] isEqualToString: @"db"] ||
[[nextItem pathExtension] isEqualToString: @"sqlitedb"]) {
if ([fileManager isReadableFileAtPath:nextItem]) {
[dbList addObject:nextItem];
NSLog(@"%@", nextItem);
}
}
}
}
}
Edit: I pinned the issue down to the following selector: [fileManager isReadableFileAtPath:nextItem] when i run this function from the SpringBoard - it returns true - for several of the files...
when i run it in the command line - it return false to all of the files - although i'm running the app with root privileges.
any idea what can cause this change in behavior?
Thanks, Itay