skcrpk
skcrpk

Reputation: 556

Incompatible integer to pointer conversion

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

Upvotes: 4

Views: 2770

Answers (1)

torip3ng
torip3ng

Reputation: 585

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];

Upvotes: 9

Related Questions