Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

eliavlevy

macrumors newbie
Original poster
Feb 8, 2009
12
0
Edit: I got my answer for the first question.
I have:
(These are only certain parts from the file.)

NSString *nameString = string; // (string is a name that exists)
nameString = [NSDate date];
nameString = [nameString substringWithRange:NSMakeRange(10, 4)];
NSLog(nameString);

The application works, but when I make a label display the text in nameString, it crashes.
Why? What am I doing wrong?

If I am not doing this correctly, then:
How can I remove certain parts of a string?
For example: in C# I would have done:
str = str.Remove(5,3);

Thanks, Eliav
 
I added a question.

weeeell ... your code is pretty much wrong from the beginning. your are getting an NSDate Object via [NSDate date], but you are storing it in an NSString - not gonna work.
look at the description method of NSDate
 
Re:

I just jumped into objective-C, I learned before 2 years of C#, and had 2 last weeks of console C++, and 1 last week of Visual C++, and I just jumped into this the day before yesterday.
I guess I should read and learn alot before I try to start working.
Thanks, guys. (Read away! ^^)
 
I just jumped into objective-C, I learned before 2 years of C#, and had 2 last weeks of console C++, and 1 last week of Visual C++, and I just jumped into this the day before yesterday.
I guess I should read and learn alot before I try to start working.
Thanks, guys. (Read away! ^^)
well, apple provides some excellent documentation for people who are already familiar with other programming languages.

objective-C is (suprise) very object-oriented. nearly everything is an object of some kind, and you simply can't store an NSDate object in an NSString. but you can convert :)
 
In fact, when I did this:

NSString *nameString = string; // (string is a name that exists)
nameString = [NSDate date];

It actually worked without an error or warning.

But anyway, where can I start learning quickly from tutorials?
 
It doesn't give you an error because +[NSDate date] returns id, not NSDate*.

I think you should read up on C first, since it seems you don't fully understand pointers which is the core of this problem.
 
It doesn't give you an error because +[NSDate date] returns id, not NSDate*.

I think you should read up on C first, since it seems you don't fully understand pointers which is the core of this problem.

Correct, because that is exactly where I stopped learning in C++...:(
 
Unfortunately they are a necessary evil and it isn't worth your while not to learn them. C wouldn't be anywhere near as powerful as it is without them

Just remember * is contents of and & is address of and you can't go wrong :D
 
Unfortunately they are a necessary evil and it isn't worth your while not to learn them. C wouldn't be anywhere near as powerful as it is without them

Just remember * is contents of and & is address of and you can't go wrong :D

Just learning about them right now.
But, as I can see, I know basic and intermediate C++ and C#, but programming in Xcode has lots of stuff I never saw like [blabla alloc]; or [blabla release]; or initWithBlaBla and such... Anywhere else I can learn about that? Maybe some tutorials?
 
Just learning about them right now.
But, as I can see, I know basic and intermediate C++ and C#, but programming in Xcode has lots of stuff I never saw like [blabla alloc]; or [blabla release]; or initWithBlaBla and such... Anywhere else I can learn about that? Maybe some tutorials?

well, initWithBlaBla are really just methods of classes, so it's nothing really new. for alloc and release you should read up on memory managment and retain counts.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.