Solved

Objective-C newb needs assist with NSLog

Posted on 2013-01-06
2
669 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
[X]
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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Starting up a Project

627 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