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

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -