Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Objective-C newb needs assist with NSLog

Posted on 2013-01-06
2
664 Views
Last Modified: 2013-01-08
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
Comment
Question by:Mark_Co
2 Comments
 

Author Comment

by:Mark_Co
ID: 38749942
crap. I figured it out. I just needed a d. Weird
0
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 38749969
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question