Leave a Reply

21 Comments on "Objective C Programming Tutorial – 53 – String Objects"

Notify of
avatar

Andrei Vlad
Guest
Andrei Vlad
5 years 1 month ago

Yes, I understood, thanks for the explanation, at that point when I wrote the comment I didn't know much about pointers, memory address and mutable strings but now what you wrote there makes sense 🙂

ackpacket
Guest
ackpacket
5 years 1 month ago

Program a real-time animated multiplayer game in javascript and get back to me 😉

ackpacket
Guest
ackpacket
5 years 1 month ago

To be honest, I think he's just forgetting to do it. The reason it's not a problem is because your program releases all memory when it terminates.

A situation where it WOULD be a problem is say, if you had program running all the time, occasionally creating string objects as needed. Eventually you would run out of memory.

The best practice is to release something when you're done with it, period. This applies to anything created with alloc, objects created by other objects/methods/functions

ackpacket
Guest
ackpacket
5 years 1 month ago

Understand, Objective C is riddled with pointers, and that's what these are. The variable 's' holds the address of memory where a string object resides. if you did tester=s; then tester would hold that same memory address, and point to the same string. You might not think this is a problem at first, but if you were working with mutable strings and used this practice, then changing any of the two strings would change both. Hopefully he'll explain pointers soon. Otherwise msg me or google it.

Andrei Vlad
Guest
Andrei Vlad
5 years 3 months ago

….
or you can do tester = s;
Bucky, why are you always showing us the hardest way?

kayvanmsh
Guest
kayvanmsh
5 years 6 months ago

"SH"tring 😀

Rougang Tang
Guest
Rougang Tang
5 years 7 months ago

I will name is 's', because I am very creative. lol!!!!

zingzhang
Guest
zingzhang
5 years 7 months ago

I feel like Bucky's getting more and more insane every tutorial.

Dustin Riley
Guest
Dustin Riley
5 years 8 months ago

@iEatBabies412 that doesn't do what you think it does. You're not assigning the value of s to tester, you're assigning the object s to tester.

RobertHimler
Guest
RobertHimler
6 years 1 month ago

@iEatBabies412 If you don't allocate memory there's nothing to release.

1 2 3
wpDiscuz