4
votes

i am checking if the directory exist but i get a warning

Incompatible integer to pointer conversion sending 'BOOL' (aka 'signed char') to parameter of type 'BOOL *' (aka 'signed char *')

 BOOL isFile ;
 isFile = [[NSFileManager defaultManager] fileExistsAtPath:[dirurl path] isDirectory:YES];

why do i get this warning and how to fix it

1
From the error is looks like you declared the isFile like 'BOOL *isFile;' thus making it a pointer. - rckoenes
No, it seems, that he needs a pointer instead of a value, which he has now. - Morgan Wilde

1 Answers

9
votes

Use like this:

BOOL isDir;
BOOL isFileExists;

isFileExists = [[NSFileManager defaultManager] fileExistsAtPath:[dirurl path] isDirectory:&isDir];
if (isDir) {...}

Official documentation example developer.apple.com:

NSArray *subpaths;
BOOL isDir;

NSArray *paths = NSSearchPathForDirectoriesInDomains
                     (NSLibraryDirectory, NSUserDomainMask, YES);

if ([paths count] == 1) {

    NSFileManager *fileManager = [[NSFileManager alloc] init];
    NSString *fontPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Fonts"];

    if ([fileManager fileExistsAtPath:fontPath isDirectory:&isDir] && isDir) {
        subpaths = [fileManager subpathsAtPath:fontPath];
// ...
[fileManager release];