Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 674
  • Last Modified:

Objective-C newb needs assist with NSLog

Totally new to iOS and am starting out with Objective-C. Been trying to figure out how to correctly output this NSLog string. I want the length of the "Hello, World!" to output. I believe the result should be "Here is the length of the string:12" right?

Can someone show me the code to fix this? Currently the result i'm getting is
"Here is the length of the string:0x1.fffe332cf2cp-1028"


// 3 ways of using @ and NSString. Each valid.
        NSString *myString = @"Hello, World!";
        int len = [myString length];
        
        len = [@"Hello, World!" length];
        
        myString = [[NSString alloc] initWithString:@"Hello, World!"];
        len = [myString length];
        
        NSLog(@"Here is the length of the string:%a",len);

Open in new window

0
Mark_Co
Asked:
Mark_Co
1 Solution
 
Mark_CoAuthor Commented:
crap. I figured it out. I just needed a d. Weird
0
 
darbid73Commented:
NSLog is fine but it is a lot of work sometimes and your xcode output become filled with too much text.

Pause your code after mySting has been init with "Hello World" and then in xCode where all the output information is put this


po [myString length]

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now