0

I'm trying to compare the string changes in core data. I add observer to NSArrayController and it working fine the problem is when I try to compare the string changes. Here is my code:

   - (void)mocDidChangeNotification:(NSNotification *)notification
    {

        NSDictionary *dic = [[notification userInfo] valueForKey:NSUpdatedObjectsKey];
NSString *stringChange = [dic valueForKey:@"category"];

        if ([stringChange isEqualToString:@"rock"])
        {
            NSLog(@"the String change");

        }
    }

if check the value of stringChange I get this output in console:

po stringChange
{(
    rock
)}

My question to you guys is how can I get the string value to compare it?

I'll really appreciate your help

user2924482
  • 8,380
  • 23
  • 89
  • 173
  • `rock` is inside a `NSSet` (there are other levels before the string). That's what says the error, plus notice that if [`dic valueForKey:@"category"]` the "po" wouldn't have the extra "{( )}". – Larme Feb 21 '15 at 20:53
  • @Larme, you are totally right. I don't how did I miss that. – user2924482 Feb 22 '15 at 00:13

1 Answers1

0
- (void)mocDidChangeNotification:(NSNotification *)notification
{

NSDictionary *dic = [notification.userInfo valueForKey:NSUpdatedObjectsKey];
    NSArray *categoryArray = [[dic valueForKey:@"category"] allObjects];
    NSString *newCategoryValue = [categoryArray objectAtIndex:0];
}
user2924482
  • 8,380
  • 23
  • 89
  • 173