Solved

Objective-C newb needs assist with NSLog

Posted on 2013-01-06
2
657 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 19

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now