ios - Add other object to NSArray -


i made small code

nsarray* _options = [nsarray arraywithobjects:[nsdictionary dictionarywithobjectsandkeys:[uiimage    imagenamed:@"2"],@"img",name,@"text"                                    , nil],nil]; 

now, want add other object _options. should do? make more test no success. thank all

you can use [nsarray arraybyaddingobject:]

_options = [_options arraybyaddingobject:object]; 

or change _options nsmutablearray

nsmutablearray *_options = [nsmutablearray arraywithobjects:[nsdictionary dictionarywithobjectsandkeys:[uiimage    imagenamed:@"2"],@"img",name,@"text"                                    , nil],nil]; [_options addobject:object]; 

and may want use modern syntax

nsmutablearray *_options = [@[@{@"img":[uiimage imagenamed:@"2"],@"text":name}] mutablecopy]; [_options addobject:object]; 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -