Andre M
Andre M

Reputation: 7536

Preinitialised NSArray indicates count is zero?

I am trying to debug an issue, whereby the NSArray I have created shows that it has zero elements.

NSArray *libPaths = [NSArray arrayWithObjects:
            [[NSBundle mainBundle] pathForResource:@"libcustomx.2" ofType:@"dylib"],
            INSTALL_PATH,
            [@"~/Library/Application Support/MyApp/libcustomx.2.dylib" stringByExpandingTildeInPath],
            @"/usr/lib/libcustomx.2.dylib",
            nil];

NSUInteger count = libPaths.count

This is Objective-C code from a project that was originally designed to build on MacOS X 10.6 and I am now trying to get it to build on MacOS X 10.11, using Xcode 7.2.1. Not being very experienced with Objective-C, I am not sure what could be causing a new array to be zero length at this point?

Upvotes: 0

Views: 46

Answers (1)

rmaddy
rmaddy

Reputation: 318814

If there is no file in the app bundle named libcustomx.2.dylib then the first value will be nil and the array will be empty.

Upvotes: 3

Related Questions