ASSIGNING NSMUTABLESET DATA INTO NSARRAY

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 525  View(s)
Ratings:
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..!

  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Assigning NSMutableSet data into NSArray

    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];
    NSLog(@"%@",oldDataArray);

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!