ios - adding objects to unknown sized array, not orderly -


i trying find structure or way adding objects array array. clarify;

actualarray[] // size not specified smtharray[1,9,8,4,9] 

i want add objects smtharray actualarray 5th index. that,

actualarray[,,,,,1,9,8,4,9] 

second times can add object begging. that,

actualarray[1,9,8,4,9,1,9,8,4,9] 

what kind of structure need achieve ?

note: nsset doesn't fit purpose because care actualarray orders.

if understand correctly, trying use insertobjects:atindexes: perform first step of description (so elements begin @ index 5). cannot nsmutablearray because not support empty elements. here relevant discussion apple documentation (see https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/classes/nsmutablearray_class/index.html#//apple_ref/occ/cl/nsmutablearray):

note nsarray objects not c arrays. is, though specify size when create array, specified size regarded “hint”; actual size of array still 0. means cannot insert object @ index greater current count of array. example, if array contains 2 objects, size 2, can add objects @ indices 0, 1, or 2. index 3 illegal , out of bounds; if try add object @ index 3 (when size of array 2), nsmutablearray raises exception.

if want achieve describe need first fill space nsnull objects:

for (nsuinteger = 0; < temparray.count; i++) {     [actualarray addobject:[nsnull null]]; } 

then can add temparray content:

[actualarray addobjectsfromarray:temparray]; 

finally can replace nulls content:

[actualarray replaceobjectsinrange:nsmakerange(0, temparray.count) withobjectsfromarray:temparray.count]; 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -