Assigning NSMutableSet data into NSArray

Total Post:183

 876  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..!

  1. Post:214

    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];

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