Incompatible pointer conversion integer

I check if the directory exists, but I get a warning

Incompatible integer for converting a pointer sending 'BOOL' (it is also signed char) to a parameter of type 'BOOL *' (aka 'signed char *')

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

why am I getting this warning and how to fix it?

+4
source share
1 answer

Use this:

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

Developer.apple.com official documentation sample:

 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]; 
+9
source

Source: https://habr.com/ru/post/1490843/


All Articles