Objective C Calling Method Syntax -
this question has answer here:
i'm bit confused on how methods called , syntax behind it. can dissect 2 lines of code me? i've got bunch of random questions.
nsstring *teststring; teststring = [[nsstring alloc] init]; so what's going on here? there's new pointer called teststring being created... point to?
then in last line, it's being set, quite confused what. is:
[[nsstring alloc] init] returning address? method "alloc" being called on nsstring, , init being called on output? alloc , init do?
thanks.
alloc/init standard way create new objects in objective-c. method alloc class method of nsobject class, nsstring (and other objective-c objects) subclass of. allocates memory string teststring, , returns that. init method returns empty , immutable string. equivalent [nsstring string], returns exact same thing.
all nsstring *teststring declare new variable, doesn't allocate memory or initialize it.
Comments
Post a Comment