Why does string show up in NSDictionary with quotes, but others don’t? [duplicate]

The quotes appear because the string contains something besides basic alphanumerics — in this case, an underscore. It’s the same reason “tbyg.jpg” and “6bcb4126-4bbe-4b3d-be45-9a06cf56a22f” have quotes (they contain a dot and dashes, respectively). That’s just how the description method works. It wouldn’t cause your second log to fail.

What are the numbers in the square brackets in NSLog() output?

The first number is the process ID, the second is the logging thread’s Mach port. A desktop example: 2010-10-19 17:37:13.189 nc_init[28617:a0f] nc <CFNotificationCenter 0x10010d170 [0x7fff70d96f20]> – default <CFNotificationCenter 0x10010d2a0 [0x7fff70d96f20]> (gdb) i thread Thread 1 has current state “WAITING” Mach port #0xa0f (gdb port #0x4203) frame 0: main () at nc_init.m:10 pthread ID: 0x7fff70ebfc20 system-wide … Read more

iOS AutoLayout – get frame size width

Actually, above answers are not quite right. I followed them and got zeros again and again. The trick is to place your frame-dependent code to the viewDidLayoutSubviews method, which Notifies the view controller that its view just laid out its subviews. Do not forget that this method is called multiple times and is not the … Read more

Warning: “format not a string literal and no format arguments”

Xcode is complaining because this is a security problem. Here’s code similar to yours: NSString *nameFormat = @”%@ %@”; NSString *firstName = @”Jon”; NSString *lastName = @”Hess %@”; NSString *name = [NSString stringWithFormat:nameFormat, firstName, lastName]; NSLog(name); That last NSLog statement is going to be executing the equivalent of this: NSLog(@”Jon Hess %@”); That’s going to … Read more

How to print out the method name and line number and conditionally disable NSLog?

Here are some useful macros around NSLog I use a lot: #ifdef DEBUG # define DLog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else # define DLog(…) #endif // ALog always displays output regardless of the DEBUG setting #define ALog(fmt, …) NSLog((@”%s [Line %d] ” fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) The DLog macro is … Read more