GettingStarted
GettingStarted

Reputation: 7605

Why does the warnings only appear when my iPhone is NOT connected to my Mac?

Not a Duplicate of but the warning message is the same. I read this article and it didn't help.

performSelector may cause a leak because its selector is unknown

I am NOT using performSelector but I am getting the same warning as if I were.

The warning message in Xcode 6.3 is

 PerformSelector may cause a leak because its selector is unknown

The code is

NSString *string=[NSString stringWithFormat:@"%tu", data.length];
NSLog(@" Expected :%lli",[response expectedContentLength]);

data.length should return an NSUInteger

expectedContentLength is a long long

When I change %tu to %zu, I get a new warning message

 Values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead

Upvotes: 2

Views: 40

Answers (1)

Droppy
Droppy

Reputation: 9721

The warning is about the changing size of NSUInteger depending on the CPU architecture and probably only occurs during Release builds (which is what I understand to be "not connected to Mac") as Release builds contain all valid CPU architectures (32- and 64-bit), whereas Debug builds contain just the architecture of the device being used to debug. (That is true if you haven't changed the Build Settings from the default).

As NSUInteger changes size, assume it's unsigned long and force that using a cast:

NSString *string=[NSString stringWithFormat:@"%lu", (unsigned long)data.length];

Upvotes: 1

Related Questions