Solved

Objective-C newb needs assist with NSLog

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

770 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