AddressBook: Why can't I add a person, that is not (yet) in the AB, to a group?
AddressBook: Why can't I add a person, that is not (yet) in the AB, to a group?
- Subject: AddressBook: Why can't I add a person, that is not (yet) in the AB, to a group?
- From: Alexandre Aybes <email@hidden>
- Date: Tue, 17 Dec 2002 10:08:59 +0100
Hi there,
I am writing a little application that needs to serialize and
deserialize address book entries to send over a socket connection, it
works fine with ABPerson objects, but when I get to the ABGroup I have
one problem:
When I deserialize the group, I need to recreate the persons that were
embedded in the group unfortunately it seems that addMember silently
fails when the person is not in the addressBook already, it does NOT
return NO, and does not throw an exception, but it logs in the console:
"Could not find person in group"
Here are 2 code snipets that reproduce the issue:
Works:
ABGroup* rootGroup = [[[ABGroup alloc] init] autorelease];
ABPerson* person = nil;
[rootGroup setValue:@"Test Root Group"
forProperty:kABGroupNameProperty];
person = [self createTestPerson];
[[ABAddressBook sharedAddressBook] addRecord:person];
NSLog(@"Person: %@", person);
[self assertTrue:[rootGroup addMember:person] message:@"Could not add
member"];
Does NOT work:
ABGroup* rootGroup = [[[ABGroup alloc] init] autorelease];
ABPerson* person = nil;
[rootGroup setValue:@"Test Root Group"
forProperty:kABGroupNameProperty];
person = [self createTestPerson];
NSLog(@"Person: %@", person);
[self assertTrue:[rootGroup addMember:person] message:@"Could not add
member"];
The only difference between the 2 snipets is that in one case I
actually add the person to the shared address book before adding it to
the group.
Is this an expected behavior or a bug? The fact that it does not return
NO seems strange to me anyhow. If this is not an expected behavior, I
will file a bug against it.
Thanks a lot,
Alex.
PS: I am running Mac OS X 10.2.2 and have not tried this on any other
version of OS X.
PPS: the code is not complete but illustrates the problem, and yes it
is part of a unit test for my application, and no, the assertion around
the addMember never fails, even though the person is not added to the
group.
--
SearchBar, the best way to search all your favorite web based search
engines
http://www.PommSoft.com/searchbar
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.