objective c - iOS How Array objects separated by commas convert into string? -


i have array named child_list child_list: "9,8,21,22,20,24,25", take in nsstring @ index 0 when convert string work when use nsmutablearray crashed, don't know why.

my code here:

if([thedictionary objectforkey:@"child_list"])     {         nsstring *str = [[thedictionary objectforkey:@"child_list"]objectatindex:0];         nslog(@"child list %@",str);         _child_list = [[nsmutablearray alloc ]initwithobjects: [str componentsseparatedbystring:@","], nil];     } 

when break point come on str show result when comes on _child_list crashed.

use initwitharray method while allocating _child_list nsmutablearray

 if([thedictionary objectforkey:@"child_list"])     {         nsstring *str = [[thedictionary objectforkey:@"child_list"]objectatindex:0];         nslog(@"child list %@",str);         _child_list = [[nsmutablearray alloc ] initwitharray:[str componentsseparatedbystring:@","]];     } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -