Added: 1 year ago
From: AppleProgramming
Views: 2,623
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (19)

Sign In or Sign Up now to post a comment!
  • good tut, thanks

  • I would like a video that show how to

    1. substring an NSString

    2. compare a NSString

    3. replace part of a NSString

  • It is time consuming. I was hoping for a quick overview through a tutorial.

  • Will you create a second NSString tutorial and cover all the string comparison and substring functions?

  • @davepamn Perhaps, but they aren't hard to figure out if you read the NSString class reference in the documentation.

  • Thanks Lucas for that info but.. I went to the apple dev site and man there are so many method for creating a string. I am not sure wich one?? Can you do a tutorial on this. I know alot of folks would like to see that..

    Keep up the good work ..Richard..

  • @richardlipp21 I will do one later.

  • HI lucas.. this is great but how do you get user to input... say... his name or some data.... and then turn that into a string object?? could you please do a tutorial on this???. I have searched the net and there are a lot of people very confused about this. Some use "get" some use "scanf"... but know one seems to know how to do this.. Thanks...

  • @richardlipp21 You have to use the C functions and then convert your C string into an NSString using one of the NSString methods (something like stringWithCString:encoding:).

  • thank you a lot!!!! but one thing - it's 'va-ya' not 'vee-ah' in via:) x

  • In reference to the NSString *string = [NSString stringWithString:@"A String here"]; ....... What exactly do you mean when you say "temporary objects that will be destroyed after a while" ? How long do these types of objects remain in memory? Thanks!

  • @ezimerman I go in depth with object memory in later tutorials, but there is no real exact time autoreleased objects get trashed. In this case it will some time after we call [pool drain], but in something like iOS, it could happen after an "event" which could be just pressing a button. A good rule of thumb is to only use them in something like a method where it will be used quickly or when returning a value (very short term storage). Use alloc init to store values for long periods of time.

  • Also how can i refer a particular character in the NSString, for example lets say i have the following string "123" and i want to do the following calculation,

    int n = (string[0] - '0') + (string[1] - '0');

    Thanks a lot.

  • @mrnetanell I would look at the NSString class reference. Some methods that might help you out are substringWithRange:, characterAtIndex:, intValue. Just look in the documentation and I'm sure you can find something there that will accomplish the task. Not sure what you were trying to do with the - '0', but there is not need to do that with an NSString.

  • I want to pass NSString value to another object and this object is a ViewController.

    Can you please demonstrate how can i pass NSString to the ViewController set NSString data member in the ViewController, and when exactly i need to release the memory ?

    Thanks a lot.

    need to pass the NSString to the View Controller and when i need to release the memory ?

    Thanks a lot.

  • @mrnetanell Have you gotten to the memory management tutorials yet?

  • Is there anything wrong with creating the instance without any methods? Ex:

    NSString *myString = @"This is my string";

  • @ezimerman Nope, that is perfectly fine. I just show examples with methods because it gives you more flexibility to what you put in your string.

  • This is a great explanation of NSString. I found this video first because I was looking for more information regarding NSString. I then looked at your other videos on Objective-C and they are really good! Thanks a lot for sharing your knowledge :)

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more