arrays - (NSString *) description -- not clear on something.... (Objective-C) -


let's have 2 array's. let's imagine 1 nsmutabledictionary, other nsmutablearray.

i have defined:

-(nsstring *) description {     // return human readable version of array contents     return self.contents; } 

then, clarity sake, want print array using this:

self.descriptionoflastflip = [nsstring stringwithformat:@"array %@",[cardsfaceup componentsjoinedbystring:@", "]]; 

then, of course, using self.descriptionoflastflip print screen.

ok, stupid question time... how define 2 separate description methods dealing array , dictionary in different way? i'd want access info differently, but, self.description, while might work array, wouldn't work dictionary..

i'd love insight on how deal creating description method multiple array's/dictionary's (or, how can 'target' description 1 type of array, etc..?)

i tend things this:

- (nsstring *)description {     return [nsstring stringwithformat:@"myclass { array = %@, dictionary = %@ }", somearray, somedictionary]; } 

replace somearray , somedictionary whatever properties or ivars wish include.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -