NSManagedObject doesn't conform to the NSCoding Protocol so you can't convert a managed object straight to data.
Instead, you just need to add a method to the managed object subclass that returns a dictionary with the instance attributes and then on the receiver side, use those to create a new managed object in the local context.
Edit:
From comments:
Currently I have for the sending
side..
NSData* data;
NSString *str0 = [NSString stringWithFormat:@"%@",[[person valueForKey:@"PersonName"] description]];
NSString *str1 = [NSString stringWithFormat:@"%@",[[person valueForKey:@"alias"] description]];
NSMutableDictionary *taskPrototype = [NSMutableDictionary dictionary];
[taskPrototype setObject:str0 forKey:@"PersonName"];
[taskPrototype setObject:str1 forKey:@"alias"];
data = ?????;
//I do not know what to put here... [self mySendDataToPeers:data];
on the receiving side I have...
NSMutableDictionary *trial = [[NSMutableDictionary alloc] initWithData:data];
NSString *str0a = ???? NSString *str1a = ????
//I dont know what to put after this to retrieve the values and keys from the dictionary
You would simply reverse the process to create a managed object on the receiver.
NSMutableDictionary *trial = [[NSMutableDictionary alloc] initWithData:data];
NSManagedObject *person=[NSEntityDescription insertNewObjectForEntityForName:@"PersonEntity" inManagedObjectContext:moc];
[person setValue:[trial objectForKey:@"PersonName"] forKey:@"PersonName"];
[person setValue:[trial objectForKey:@"alias"] forKey:@"alias"];
.. and you're done.