Home > DeveloperSection > Forums > Assigning NSMutableSet data into NSArray
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    December-06-2015 11:07 PM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 231  View(s)
Rate this:

I have stored our Phone Contacts id into an NSMutableSet to do some task.
and now I want to pass mutable set object into an NSArray but I have getting problem when I assign it.
this is my code:

NSMutableSet *newsetadded = [NSMutableSet setWithSet:oldsets];
NSArray *oldDataArray = [newsetadded allObjects];

Please tell me what I am doing wrong in our code..!

Tarun Kumar

Total Post:210

Posted on    December-07-2015 11:11 PM

I think your code is not generating error but I am providing the code for your help.
use mutableCopy method of set class, it may be you get your problem's solution.

NSMutableSet *newsetadded = [NSMutableSet setWithSet:oldsets];
NSMutableArray *oldDataArray = [newsetadded allObjects] mutableCopy];

If this code is not helpful for you, then I sure your problem is in your oldsets object, check your oldsets again.

Don't want to miss updates? Please click the below button!

Follow MindStick