Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible integer to pointer conversion

Tags:

objective-c

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

like image 586
skcrpk Avatar asked Jan 13 '23 23:01

skcrpk


1 Answers

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];
like image 172
torip3ng Avatar answered May 25 '23 21:05

torip3ng