忍者ブログ
2024 / 09
≪ 2024 / 081 2 3 4 5 6 78 9 10 11 12 13 1415 16 17 18 19 20 2122 23 24 25 26 27 2829 30 2024 / 10 ≫

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。



#import "QuickStartViewController.h"



@implementation QuickStartViewController

@synthesize についてわかりやすい説明を見つけました。
▶getterおよびsetterと@synthesize

@synthesize firstName;

@synthesize lastName;





- (IBAction)showPicker:(id)sender {
showPicker メソッドの実装
  
    ABPeoplePickerNavigationController *picker =
    [[ABPeoplePickerNavigationController alloc] init];
ABPeoplePickerNavigationController インスタンスの生成と初期化
ABPeoplePickerNavigationController のデータを格納するメモリ領域を確保している。
picker という変数に ABPeoplePickerNavigationController が格納される。
*picker( * ポインタ )なので、メモリ領域、○○○番地( 先頭アドレス )に ABPeoplePickerNavigationController のデータが流し込まれる( 格納 )されるということなのかな・・・


[ABPeoplePickerNavigationController alloc] のことをABPeoplePickerNavigationControllerインスタンスの生成( alloc ) というってやつか・・・
メモリ領域を確保したってやつだね。
init で初期化・・・


    picker.peoplePickerDelegate = self;
   
   
   
    [self presentModalViewController:picker animated:YES];
   
    [picker release];
   
}
- (void)peoplePickerNavigationControllerDidCancel:

(ABPeoplePickerNavigationController *)peoplePicker {
   
    [self dismissModalViewControllerAnimated:YES];
   
}





- (BOOL)peoplePickerNavigationController:

(ABPeoplePickerNavigationController *)peoplePicker

      shouldContinueAfterSelectingPerson:(ABRecordRef)person {
   
   
   
    NSString* name = (NSString *)ABRecordCopyValue(person,
                                                  
                                                   kABPersonFirstNameProperty);
   
    self.firstName.text = name;
   
    [name release];
   
   
   
    name = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
   
    self.lastName.text = name;
   
    [name release];
   
   
   
    [self dismissModalViewControllerAnimated:YES];
   
   
   
    return NO;
   
}

- (BOOL)peoplePickerNavigationController:

(ABPeoplePickerNavigationController *)peoplePicker

      shouldContinueAfterSelectingPerson:(ABRecordRef)person

                                property:(ABPropertyID)property

                              identifier:(ABMultiValueIdentifier)identifier{
   
    return NO;
   
}

- (BOOL)shouldAutorotateToInterfaceOrientation:

(UIInterfaceOrientation)interfaceOrientation {
   
    // サポートされている方向に対してYESを返す
   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
   
}





- (void)didReceiveMemoryWarning {
   
    [super didReceiveMemoryWarning]; // スーパービューがなければ
   
    // ビューを解放する
   
    // キャッシュデータなどの重要でないものをすべて解放する
   
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/


- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
   
    [firstName release];
   
    [lastName release];
   
    [super dealloc];
   
}

@end

PR


#import <UIKit/UIKit.h>

AddressBook フレームワークを読み込む
#import <AddressBook/AddressBook.h>
AddressBookUI フレームワークを読み込む
#import <AddressBookUI/AddressBookUI.h>

UIViewController( SuperClass) を継承して QuickStartViewController( SubClass ) を定義
@interface QuickStartViewController :UIViewController  <ABPeoplePickerNavigationControllerDelegate> {

  ボタンのラベルおよびアクションのアウトレットを宣言  
結びつけてるのかぁ
    IBOutlet UILabel *firstName;
   
    IBOutlet UILabel *lastName;
   
}


★プロパティ(property) プロパティは、アクセサメソッドに代わって使われる便利な表記法です。プロパティは、クラス宣言内に新しいメンバ変数を作成しません。プロパティは単に、既存のメンバ変数にアクセスするメソッドを定義するための簡単な表記法です。

@property (オプション指定) データ型 プロパティ名;
noatomic :
マルチスレッド環境を想定していない
retain : 保持する。メモリを確保するってことかな??

@property (nonatomic, retain) UILabel *firstName;

@property (nonatomic, retain) UILabel *lastName;


タップされた時の処理(アクション)
- (IBAction)showPicker:(id)sender;
@end


Delegate ってのは割り込み処理のようなものなのかなぁ??

iPhone Dev CenterGetting Started Documents の文章を赤(★マーク)でコピペしときます。


Developer Connection のサンプルを解析してみます。
iPhone OS Address Bookプログラミングガイド

「クイックスタートチュートリアル」では、ユーザに連絡先を選択するように求め、その連絡先に関する情報を表示する簡単なアプリケーションを作成する方法を、最初の一歩として示します。


こんなのができます。
30a1299c.jpg49002955.jpg










アドレス帳でタップした名前がピックアップされて表示されるプログラムです。


08 2024/09 10
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
HN:
cow

自己紹介:
iPhone購入がきっかけでiPhoneアプリの制作にチャレンジ!