Re: [iPhone] Addressbook "group" problem
Re: [iPhone] Addressbook "group" problem
- Subject: Re: [iPhone] Addressbook "group" problem
- From: James Lin <email@hidden>
- Date: Mon, 13 Jul 2009 15:33:28 +0800
Thank you Roland, and Luke!
I got it...thank you for your pointers!
ABRecordRef group = CFArrayGetValueAtIndex(grpval, i);
NSString *groupName = (NSString *)ABRecordCopyCompositeName(group);
This works, finally...
Thank you again!
James
On 2009/7/13, at 下午 3:18, Roland King wrote:
Well they aren't strings, they are some kind of opaque type which
represents a group. So you can't find it using CFArrayContainsValue
with a String. The name is a property of the Group object which is
returned. You'll have to iterate the array, get the property for
each group which is the name and test it against the name you want
to add.
This is all documented in the Address Book Programming Guide For
iPhone OS whereh it explains what records are and tells you how to
get properties out of them.
The ABGroup Reference documentation then tells you what the one
single property for a group is. (kABGroupNameProperty)
Can't say this is the easiest documentation to fully understand on
the first reading but bouncing around a bit you should be able to
sort out how it works (and if you have documentation improvement
suggestions you should hit the link at the bottom and make some, I'm
just about to!)
James Lin wrote:
Thank you Roland.
Actually, I tried that function...but there is a problem that I
can't figure out.
the following is my code segment...
ABAddressBookRef addressBook=ABAddressBookCreate(); CFArrayRef
grpval= ABAddressBookCopyArrayOfAllGroups(addressBook);
CFIndex groupCount = ABAddressBookGetGroupCount(addressBook);
CFRange range = CFRangeMake(0, 1);
NSArray *convertedArray = (NSArray *)grpval;
if (CFArrayContainsValue(grpval, range, @"Dangle Three"))
{
NSLog(@"Yes, it contains the group");
}
NSLog(@"tthe group count is %d", groupCount);
NSLog(@"the group name is %@", (NSString
*)CFArrayGetValueAtIndex(grpval, 0));
NSLog(@"The converted group is nsarray %@", [convertedArray
objectAtIndex:0]);
the output i get from the NSLog statements are:
*2009-07-13 14:29:08.686 KSOne[7520:20b] tthe group count is 1*
*2009-07-13 14:29:08.687 KSOne[7520:20b] the group name is
<NSCFType: 0x119e1a0>*
*2009-07-13 14:29:08.688 KSOne[7520:20b] The converted group is
nsarray <NSCFType: 0x119e1a0>*
*
*
*For some reason, the toll-free bridging doesn't work.*
*although i can get the count of the group array of 1 correctly, *
*the actual group name remains illusive to me :(*
*
*
*any ideas? *
*what's "NSCFType"?*
*what am I doing wrong?*
*
*
*Thank you in advance...*
*
*
*James*
On 2009/7/13, at 下午 1:15, Roland King wrote:
ABAddressBookCopyArrayOfAllGroups()?
James Lin wrote:
Hi,
Sorry I didn't frame my question more clearly...
The part I am having trouble with is finding out if a "group
name" already exists in the addressbook,
is there a way to do this? the ABGroup documentation has no
function that allows this...
any suggestions?
Thank you in advance...
James
On 2009/7/11, at 下午 9:36, Luke Hiesterman wrote:
The group doesn't have a name when you create it. Try setting
the name after creation rather than getting it.
Luke
Sent from my iPhone.
On Jul 11, 2009, at 12:50 AM, James Lin <email@hidden <mailto:email@hidden
>> wrote:
Hi all,
Anyone familiar with the Addressbook framework?
I can't seem to be able to add a "group" into the addressbook
only ONCE.
if i use ABRecordRef group = ABGroupCreate(); to get a handle
on group,
calling NSString *groupName = (NSString
*)ABRecordCopyCompositeName(group);
returns a NULL.
so I can't seem to be able to check if a group name already
exists and don't have to re-create the group again.
Can you please help me and point me in the right direction?
How do I create group only "once"?
Thank you and best regards...
James
_______________________________________________
Cocoa-dev mailing list (email@hidden <mailto:email@hidden
>)
Please do not post admin requests or moderator comments to the
list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden <mailto:email@hidden>
_______________________________________________
Cocoa-dev mailing list (email@hidden <mailto:email@hidden
>)
Please do not post admin requests or moderator comments to the
list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden <mailto:email@hidden>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden