Hallo zusammen,
ich versuch mich grade n meiner ersten App und hier und da hab ich doch noch das eine oder andere Problem. Ich wollte heute eigentlich den Zugriff auf das Adressbuch programmieren und hab mir dafür mal die von Apple zur Verfügung gestellten Samples angeschaut und einfach mal versucht das nach zu programmieren.
developer.apple.com/library/io…/Chapters/QuickStart.html
Das erste Problem war dann schonmal das der Ausdruck "[self presentModalViewController:picker animated:YES]" leider nicht mehr aktuell ist. Da bin ich dann auf den Ausdruck "[self presentViewController:self animated:YES completion:NULL]" ausgewichen. Dasselbe mit "[self dismissModalViewControllerAnimated:YES]".
Soweit war dann auch alles ... keine Fehler Meldung... App auf dem Simulator gestartet... und .... Enttäuschung. Läuft nicht. Es wird keine einzige der von mir implementierten Methoden ausgeführt.
Mein Header-file
Alles anzeigen
Mein Implementation-File:
Alles anzeigen
und die Fehlermeldung:
Alles anzeigen
Was hab ich übersehen und falsch gemacht? Ich hoffe mir kann jmd helfen... bin leider nicht erfahren genug, damit mir die Fehlermeldung etwas sagt
Schonmal vielen Dank im Voraus!
ich versuch mich grade n meiner ersten App und hier und da hab ich doch noch das eine oder andere Problem. Ich wollte heute eigentlich den Zugriff auf das Adressbuch programmieren und hab mir dafür mal die von Apple zur Verfügung gestellten Samples angeschaut und einfach mal versucht das nach zu programmieren.
developer.apple.com/library/io…/Chapters/QuickStart.html
Das erste Problem war dann schonmal das der Ausdruck "[self presentModalViewController:picker animated:YES]" leider nicht mehr aktuell ist. Da bin ich dann auf den Ausdruck "[self presentViewController:self animated:YES completion:NULL]" ausgewichen. Dasselbe mit "[self dismissModalViewControllerAnimated:YES]".
Soweit war dann auch alles ... keine Fehler Meldung... App auf dem Simulator gestartet... und .... Enttäuschung. Läuft nicht. Es wird keine einzige der von mir implementierten Methoden ausgeführt.
Mein Header-file
Quellcode
- //
- // CEViewController.h
- // ContactBookTry
- //
- // Created by Hinrich Hobbensiefken on 27.10.13.
- // Copyright (c) 2013 Hinrich Hobbensiefken. All rights reserved.
- //
- #import <UIKit/UIKit.h>
- #import <AddressBook/AddressBook.h>
- #import <AddressBookUI/AddressBookUI.h>
- @interface CEViewController : UIViewController <ABPeoplePickerNavigationControllerDelegate>
- @property (weak, nonatomic) IBOutlet UILabel *firstName;
- @property (weak, nonatomic) IBOutlet UILabel *phoneNumber;
- - (IBAction)showPicker:(id)sender;
- @end
Mein Implementation-File:
Quellcode
- //
- // CEViewController.m
- // ContactBookTry
- //
- // Created by Hinrich Hobbensiefken on 27.10.13.
- // Copyright (c) 2013 Hinrich Hobbensiefken. All rights reserved.
- //
- #import "CEViewController.h"
- @interface CEViewController ()
- @end
- @implementation CEViewController
- @synthesize firstName;
- @synthesize phoneNumber;
- - (void)viewDidLoad
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)didReceiveMemoryWarning
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)peoplePickerNavigationControllerDidCancel:
- (ABPeoplePickerNavigationController *)peoplePicker
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [self dismissViewControllerAnimated:YES completion:NULL];
- }
- - (BOOL)peoplePickerNavigationController:
- (ABPeoplePickerNavigationController *)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- [self displayPerson:person];
- [self dismissViewControllerAnimated:YES completion:NULL];
- return NO;
- }
- - (BOOL)peoplePickerNavigationController:
- (ABPeoplePickerNavigationController *)peoplePicker
- shouldContinueAfterSelectingPerson:(ABRecordRef)person
- property:(ABPropertyID)property
- identifier:(ABMultiValueIdentifier)identifier
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- return NO;
- }
- - (void) displayPerson: (ABRecordRef)person
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- NSString* name = (__bridge_transfer NSString*)ABRecordCopyValue(person, kABPersonFirstNameProperty);
- self.firstName.text = name;
- NSString* phone = Nil;
- ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
- if (ABMultiValueGetCount(phoneNumbers)>0) {
- phone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneNumbers, 0);
- } else {
- phone = @"[none]";
- }
- self.phoneNumber.text = phone;
- CFRelease(phoneNumbers);
- }
- - (IBAction)showPicker:(id)sender
- {
- NSLog(@"%s",__PRETTY_FUNCTION__);
- ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
- picker.peoplePickerDelegate = self;
- [self presentViewController:self animated:YES completion:NULL];
- }
- @end
und die Fehlermeldung:
Quellcode
- 2013-10-27 15:10:30.107 ContactBookTry[3108:a0b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<CEViewController 0x9c58b90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key showPicker.'
- *** First throw call stack:
- (
- 0 CoreFoundation 0x01a5b5e4 __exceptionPreprocess + 180
- 1 libobjc.A.dylib 0x017de8b6 objc_exception_throw + 44
- 2 CoreFoundation 0x01aeb6a1 -[NSException raise] + 17
- 3 Foundation 0x0149fc2e -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
- 4 Foundation 0x0140bf3b _NSSetUsingKeyValueSetter + 88
- 5 Foundation 0x0140b493 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
- 6 Foundation 0x0146d94a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
- 7 UIKit 0x007f2cd5 -[UIRuntimeOutletConnection connect] + 106
- 8 libobjc.A.dylib 0x017f07d2 -[NSObject performSelector:] + 62
- 9 CoreFoundation 0x01a56b6a -[NSArray makeObjectsPerformSelector:] + 314
- 10 UIKit 0x007f182e -[UINib instantiateWithOwner:options:] + 1417
- 11 UIKit 0x00663c95 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
- 12 UIKit 0x0066443d -[UIViewController loadView] + 302
- 13 UIKit 0x0066473e -[UIViewController loadViewIfRequired] + 78
- 14 UIKit 0x00664c44 -[UIViewController view] + 35
- 15 UIKit 0x0058d5ad -[UIWindow addRootViewControllerViewIfPossible] + 66
- 16 UIKit 0x0058d947 -[UIWindow _setHidden:forced:] + 312
- 17 UIKit 0x0058dbdd -[UIWindow _orderFrontWithoutMakingKey] + 49
- 18 UIKit 0x0059844a -[UIWindow makeKeyAndVisible] + 65
- 19 UIKit 0x0054b8e0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
- 20 UIKit 0x0054ffb8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
- 21 UIKit 0x0056442c -[UIApplication handleEvent:withNewEvent:] + 3447
- 22 UIKit 0x00564999 -[UIApplication sendEvent:] + 85
- 23 UIKit 0x00551c35 _UIApplicationHandleEvent + 736
- 24 GraphicsServices 0x02a072eb _PurpleEventCallback + 776
- 25 GraphicsServices 0x02a06df6 PurpleEventCallback + 46
- 26 CoreFoundation 0x019d6dd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
- 27 CoreFoundation 0x019d6b0b __CFRunLoopDoSource1 + 523
- 28 CoreFoundation 0x01a017ec __CFRunLoopRun + 2156
- 29 CoreFoundation 0x01a00b33 CFRunLoopRunSpecific + 467
- 30 CoreFoundation 0x01a0094b CFRunLoopRunInMode + 123
- 31 UIKit 0x0054f6ed -[UIApplication _run] + 840
- 32 UIKit 0x0055194b UIApplicationMain + 1225
- 33 ContactBookTry 0x000027cd main + 141
- 34 libdyld.dylib 0x02e9a725 start + 0
- )
- libc++abi.dylib: terminating with uncaught exception of type NSException
Was hab ich übersehen und falsch gemacht? Ich hoffe mir kann jmd helfen... bin leider nicht erfahren genug, damit mir die Fehlermeldung etwas sagt
Schonmal vielen Dank im Voraus!
Think positive, flaps negative!