Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Apple Software > iPhone Programming
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread  
Old Mar 14, 2008, 10:49 AM   #26
cmaier
macrumors 65816
 
Join Date: Jul 2007
Location: California
Remember that "release" isn't like "delete" in C++ or free in C. It merely reduces the reference count.
__________________
http://www.waffleturtle.com
cmaier is online now   Reply With Quote
Old Mar 19, 2008, 04:56 AM   #27
muscheteer
macrumors newbie
 
Join Date: Mar 2008
handle a call event

Quote:
Originally Posted by gifford View Post
I have been trundling through the adressbook iphone framework all day looking for ways to receive "missed call" events, are an array of missed calls, or any info to do with missed calls.

Has anyone spotted any info on this anywhere?
Has anyone try to handle a call event or someting like this ?

Thanks
muscheteer is offline   Reply With Quote
Old Mar 23, 2008, 09:43 PM   #28
kiezarsoze
macrumors newbie
 
Join Date: Mar 2008
get phones out of the addressbook

I've gotten this far, but when I try to use the property called kABPersonPhoneProperty in ABPerson.h I get a return value of NSCFType.

At loggerheads. Can anyone show me how to get the phone numbers, specifically the cell phone number (kABPersonPhoneMobileLabel)?

(Also trying to get the phone number of the device itself)

Quote:
Originally Posted by drivefast View Post
i think youre talking about how to get the values in the database fields...? something like this?
PHP Code:
NSString *contactFirstLast = [NSString stringWithFormat:@"%@,%@"
  
ABRecordCopyValue(refkABPersonFirstNameProperty), 
  
ABRecordCopyValue(refkABPersonLastNameProperty)
]; 
the kABPersonBlahBlahProperty constants (or enums, i forgot what they are) are decribed in the ABPerson documentation pages. it's a little more difficult to get a hold of the multivalues, like addresses and phone numbers, ive got something working if you need it, but i feel it's not as nice as it could be.
kiezarsoze is offline   Reply With Quote
Old Mar 24, 2008, 02:08 AM   #29
kiezarsoze
macrumors newbie
 
Join Date: Mar 2008
iphone sdk address book

anyone got experience with ABMultiValueRef and ABMultiValueIdentifier. How do we initialize these variables? How can we use them to access multi value strings such as phone numbers and other contact info in the iphone addressbook sdk?
kiezarsoze is offline   Reply With Quote
Old Apr 7, 2008, 10:34 PM   #30
yarshure
macrumors newbie
 
Join Date: Apr 2008
use this code get person phone number
ABAddressBookRef book = ABAddressBookCreate(); // b
CFArrayRef people = ABAddressBookCopyArrayOfAllPeople(book);

NSLog(@"%@",ABMultiValueCopyValueAtIndex(ABRecordCopyValue(CFArrayGetValueAtIndex(people,indexPath.r ow),kABPersonPhoneProperty) ,0));

Quote:
Originally Posted by kiezarsoze View Post
anyone got experience with ABMultiValueRef and ABMultiValueIdentifier. How do we initialize these variables? How can we use them to access multi value strings such as phone numbers and other contact info in the iphone addressbook sdk?
yarshure is offline   Reply With Quote
Old Apr 21, 2008, 12:42 PM   #31
StrAbZ
macrumors newbie
 
Join Date: Apr 2008
Thank you for all the answers in this thread, it was very helpful !

I've tried to use the SimpleDrillDown example from the apple dev center, and replace the list of name define in the code by the name from the address book, but as you can imagine i have a probleme.

This is the code i use to retrieve data from the addressBook.
Code:
ABAddressBookRef addressBook = ABAddressBookCreate();

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

NSMutableArray *masterList = [[NSMutableArray alloc] init];
for (int i = 0; i < nPeople; i++) {
	ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
	CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
	CFStringRef lastName = ABRecordCopyValue(ref, kABPersonLastNameProperty);
	NSString *contactFirstLast = [NSString stringWithFormat: @"%@", (NSString *)lastName];
	CFRelease(firstName);
	CFRelease(lastName);
	[masterList addObject:contactFirstLast];
	[contactFirstLast release];
}
	
self.list = masterList;
[masterList release];
the problem is : if i wrote the ligne :
Code:
NSString *contactFirstLast = (NSString *)lastName;
I can get all lastName, but when i try to use :
Code:
NSString *contactFirstLast = [NSString stringWithFormat: @"%@", (NSString *)lastName];
it doesn't work, did you have any idea of the probleme?

It look likes
Code:
[NSString stringWithFormat: @"LN: %@", (NSString *)lastName]
and
Code:
(NSString *)lastName
are not the same kind of NSString... i really can't understand...

Thanks
StrAbZ is offline   Reply With Quote
Old May 28, 2008, 12:58 PM   #32
MediadorAv
macrumors newbie
 
Join Date: May 2008
i'm new in the iPhone, somebody know how add a record in the addressBook. thanks
MediadorAv is offline   Reply With Quote
Old May 28, 2008, 02:04 PM   #33
gnasher729
macrumors 68040
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by jhershauer View Post
[Edit]: Hmm...I see other references to NDA, and although this thing is publicly available now, I know I agreed to something (didn't actually read it) when I downloaded the SDK, so I've gone back and attempted to kind of obfuscate the code so as not to give any SDK "secrets" away. :-)
The iPhone SDK _is_ under NDA and it is _not_ publicly available. And yes, you did agree not to publish any information about the iPhone SDK at all.
gnasher729 is offline   Reply With Quote
Old May 28, 2008, 05:22 PM   #34
MediadorAv
macrumors newbie
 
Join Date: May 2008
oooh ok, no problem, I'll search other site,or anywhere, with a person like you the world don't work, so, anyway I will found it, and I'll publish all, that it is not problem for me.jajaja secrets (like secrets expedients "X").
MediadorAv is offline   Reply With Quote
Old Jun 2, 2008, 02:12 PM   #35
MediadorAv
macrumors newbie
 
Join Date: May 2008
this is for add record to addressBook,

-(void)editarid)sender{

ABAddressBookRef libroDirec = ABAddressBookCreate();
ABRecordRef persona = ABPersonCreate();

ABRecordSetValue(persona, kABPersonFirstNameProperty, @"kate" , nil);
ABRecordSetValue(persona, kABPersonLastNameProperty, @"Hutson", nil);
ABAddressBookAddRecord(libroDirec, persona, nil);
ABAddressBookSave(libroDirec, nil);

CFRelease(persona);
}



this code is for remove one record in the addressbook like the record in this case with the name kate. good luck.

-(void)editarid)sender
{

ABAddressBookRef libroDirec = ABAddressBookCreate();

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(libroDirec);

CFIndex xPeople = ABAddressBookGetPersonCount(libroDirec);


for (int i=0; i <xPeople; i++ )
{
ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
CFStringRef nombreX = ABRecordCopyValue(ref, kABPersonFirstNameProperty);


CFStringRef cadena = CFSTR("kate");



if (CFStringCompare(nombreX, cadena , 0) == kCFCompareEqualTo )
{
ABAddressBookRemoveRecord(libroDirec, ref, nil);
ABAddressBookSave(libroDirec, nil);

}



}


hi, hi, secrets,
don't more tv, get down of the cloud programmers, we share, we aren't FBI agents, or anything else like secrets.

Last edited by MediadorAv : Jun 2, 2008 at 02:44 PM.
MediadorAv is offline   Reply With Quote
Old Jun 3, 2008, 07:08 PM   #36
sabross
macrumors newbie
 
Join Date: Jun 2008
Quote:
Originally Posted by kainjow View Post
Did you link in the entire framework?
Hi I'm having the same problem, and I linked the framework using Ctrl-Click Frameworks>add>existing framework and choosing "AddressBook Framework"

I add #import <AddressBook/AddressBook.h> and then if i try

ABAddressBook *ab = [ABAddressBook sharedAddressBook];

I get the error:
ABAddressBook undeclared

but no error in the "import" line.

What am I missing to link correctly the library??

Thx,

Dani
sabross is offline   Reply With Quote
Old Jun 3, 2008, 08:09 PM   #37
MediadorAv
macrumors newbie
 
Join Date: May 2008
hi, you have problem because in the iPhone is diferent like this:

addressBookRef ab=AddressBookCreate();

in the example above you see something like this
MediadorAv is offline   Reply With Quote
Old Jun 4, 2008, 04:31 AM   #38
korzieher
macrumors newbie
 
Join Date: Jun 2008
Multi values

hi there

has anyone ever managed to add an ABMutableMultiValue to an ABRecord?

what i'm trying to do is to add a new record to the addressbook.
i managed to add a record with several properties as described earlier in this thread. but when it comes to multivalues i don't have a clue...
basically i want to add for example an address. i noticed that there are constants (keys) like 'kABPersonAddressZIPKey' and a 'kABPersonAddressProperty'. but how can i add the zip key to the record?

thanks for any help.

now i came up with this.
Code:
current = ABPersonCreate();
ABRecordSetValue(current, kABPersonFirstNameProperty, @"foo", nil);
ABRecordSetValue(current, kABPersonLastNameProperty, @"bar", nil);

ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABPersonAddressProperty);
if(!ABMultiValueAddValueAndLabel(address, @"street 123", kABPersonAddressStreetKey, nil))
	NSLog(@"adding value/label didn't work.");

if(!ABRecordSetValue(current, kABPersonAddressProperty, address, nil))
	NSLog(@"setting value didn't work.");

if(!ABAddressBookAddRecord(addressBook, current, nil))
	NSLog(@"adding didn't work.");

ABAddressBookSave(addressBook, nil);
but it crashes on the last line with the messages
Code:
*** -[NSCFString count]: unrecognized selector sent to instance 0x63e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString count]: unrecognized selector sent to instance 0x63e0'

Last edited by korzieher : Jun 4, 2008 at 08:45 AM.
korzieher is offline   Reply With Quote
Old Apr 29, 2009, 06:54 AM   #39
pranav
macrumors newbie
 
Join Date: Nov 2008
contactFirstLast is autorelased object, so you should not release it.

Quote:
Originally Posted by StrAbZ View Post
Thank you for all the answers in this thread,
it was very helpful !

I've tried to use the SimpleDrillDown example from the apple dev center, and replace the list of name define in the code by the name from the address book, but as you can imagine i have a probleme.

This is the code i use to retrieve data from the addressBook.
Code:
ABAddressBookRef addressBook = ABAddressBookCreate();

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);

NSMutableArray *masterList = [[NSMutableArray alloc] init];
for (int i = 0; i < nPeople; i++) {
	ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);
	CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);
	CFStringRef lastName = ABRecordCopyValue(ref, kABPersonLastNameProperty);
	NSString *contactFirstLast = [NSString stringWithFormat: @"%@", (NSString *)lastName];
	CFRelease(firstName);
	CFRelease(lastName);
	[masterList addObject:contactFirstLast];
	[contactFirstLast release];
}
	
self.list = masterList;
[masterList release];
the problem is : if i wrote the ligne :
Code:
NSString *contactFirstLast = (NSString *)lastName;
I can get all lastName, but when i try to use :
Code:
NSString *contactFirstLast = [NSString stringWithFormat: @"%@", (NSString *)lastName];
it doesn't work, did you have any idea of the probleme?

It look likes
Code:
[NSString stringWithFormat: @"LN: %@", (NSString *)lastName]
and
Code:
(NSString *)lastName
are not the same kind of NSString... i really can't understand...

Thanks
pranav is offline   Reply With Quote
Old Apr 30, 2009, 06:10 AM   #40
StrAbZ
macrumors newbie
 
Join Date: Apr 2008
It was a years ago (starting objective c), but thx for replying ^^
I learned a lot since that post
StrAbZ is offline   Reply With Quote

Reply

Mac Forums > Apple Software > iPhone Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:27 PM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC