Wednesday, 23 July 2014

Newbie Objective-C question/problem


hi,

i've encountered little problem while doing beginner programming in objective-c. problem apparently don't understand how use init. i'm kind of (it little bigger, actually) trying following:
want have ivar holds name of object, declared "nsstring* name;" in @interface section , have initialized string in init method in @implentation. string has "no name given yet.". when call init method in main, string keeps being null/nil.

understanding, problem lies in following line of code:
anirrelevantclass* myobject = [myobject init];
problem being init method never gets called. (i included nslog call in init method check)

suspect has new memory management techniques , fact chain init alloc method, doesn't work. can please me this?

thanks. :)
apologize if parts of post bit vague/strange, i'm quite tired right now. ;)
 

your aren't allocating before

anirrelevantclass *myobject = [ [myobject alloc] init];

happens if that? or if use new instead
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment