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..
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:).
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,
@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 ?
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 :)
good tut, thanks
findthebug 1 week ago
I would like a video that show how to
1. substring an NSString
2. compare a NSString
3. replace part of a NSString
davepamn 3 weeks ago
It is time consuming. I was hoping for a quick overview through a tutorial.
davepamn 3 weeks ago
Will you create a second NSString tutorial and cover all the string comparison and substring functions?
davepamn 3 weeks ago
@davepamn Perhaps, but they aren't hard to figure out if you read the NSString class reference in the documentation.
AppleProgramming 3 weeks ago
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 7 months ago
@richardlipp21 I will do one later.
AppleProgramming 7 months ago
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 7 months ago
@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:).
AppleProgramming 7 months ago
thank you a lot!!!! but one thing - it's 'va-ya' not 'vee-ah' in via:) x
unholyGothyx 8 months ago
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 9 months ago
@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.
AppleProgramming 9 months ago
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 9 months ago
@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.
AppleProgramming 9 months ago
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 9 months ago
@mrnetanell Have you gotten to the memory management tutorials yet?
AppleProgramming 9 months ago
Is there anything wrong with creating the instance without any methods? Ex:
NSString *myString = @"This is my string";
ezimerman 10 months ago
@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.
AppleProgramming 10 months ago
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 :)
marcushammar 1 year ago