Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6908009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:30:24+00:00 2026-05-27T08:30:24+00:00

I am quite new to objective C , I am using XCode 4.2 and

  • 0

I am quite new to objective C , I am using XCode 4.2 and in a part of the application I will need to save data in the address book . but I need it to be displayed in the address book and not just save it on a button click

I am trying to use the following code :

I added the addressBook framework and the addressBookUI framework
in my .h file I wrote

#import <UIKit/UIKit.h>
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>


    @interface HelloWorld20ViewController : UIViewController<ABNewPersonViewControllerDelegate,ABPersonViewControllerDelegate>{

}
-(IBAction)go;

@end

in my .m file i wrote

-(IBAction)go{
    ABRecordRef newPerson= ABPersonCreate();
    CFErrorRef error = NULL;
    ABRecordSetValue(newPerson, kABPersonFirstNameProperty, CFSTR("john"), &error);
    ABRecordSetValue(newPerson, kABPersonLastNameProperty, CFSTR("Smith"), &error);
    NSAssert(!error, @"something bad happend here.");


    ABNewPersonViewController* newPersonViewController = [[ABNewPersonViewController alloc] initWithNibName:nil bundle:nil];
    [newPersonViewController setDisplayedPerson:newPerson];
    [newPersonViewController setNewPersonViewDelegate:self];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:newPersonViewController];

    [self presentModalViewController:navController animated:YES];

    CFRelease(newPerson);

}

-(void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person{
    [self.navigationController popViewControllerAnimated:YES];
}

when i click on the go button I get a black screen : here is what I am getting

enter image description here

is there a reason why it is doing this ?

Thanks alot!

Edited

current code :

-(IBAction)go{
    ABRecordRef newPerson= ABPersonCreate();
    CFErrorRef error = NULL;
    ABRecordSetValue(newPerson, kABPersonFirstNameProperty, CFSTR("john"), &error);
    ABRecordSetValue(newPerson, kABPersonLastNameProperty, CFSTR("Smith"), &error);
    NSAssert(!error, @"something bad happend here.");


    ABNewPersonViewController* newPersonViewController = [[ABNewPersonViewController alloc] initWithNibName:nil bundle:nil];
    [newPersonViewController setDisplayedPerson:newPerson];
    [newPersonViewController setNewPersonViewDelegate:self];


    [self presentModalViewController:newPersonViewController animated:YES];

    CFRelease(newPerson);

}

and still the same problem

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:30:24+00:00Added an answer on May 27, 2026 at 8:30 am

    Alright, your problem is this line here:

    ABNewPersonViewController* newPersonViewController = [[ABNewPersonViewController alloc] initWithNibName:nil bundle:nil];
    

    If you replace that line with this:

    ABNewPersonViewController* newPersonViewController = [[ABNewPersonViewController alloc] init];
    

    Your code works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm quite new to objective c but have been programming for a while. I
I'm quite new to Objective-C and so far I'm using a UIViewController and I've
Am new to objective-c and xcode, and i love programming with them. But am
Hi I am quite new to php but i have been following some tutorials
I'm quite new to php and have been reading Larry Ullman book to develop
I'm quite new to c++, but I've got the hang of the fundamentals. I've
I'm trying to implement the Strategy pattern using Core Data and Objective C. To
I am quite new to Objective C for the iPhone, so I hope you
I'm quite new to objective-j and the framework so I was attempting to drill
first of all please let me say that I am quite new to objective

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.