tag:blogger.com,1999:blog-68344799632284157592024-02-19T18:06:46.750+07:00Belajar iOSAdmin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-6834479963228415759.post-80295105791269132032015-04-21T14:36:00.000+07:002015-05-03T14:02:53.863+07:00Apakah Array itu?<div style="text-align: justify;">
<b>Array </b>adalah struktur data dasar dalam pemrograman komputer. Anda dapat menganggap sebuah array sebagai kumpulan elemen data. Pertimbangkan array tabel data dalam kode di atas, itu merupakan kumpulan elemen tekstual. Anda dapat memvisualisasikan array seperti ini.</div>
<div style="text-align: justify;">
Setiap elemen array diidentifikasi atau diakses oleh <b>indeks</b>. Sebuah array dengan <b>10 elemen</b> akan memiliki indeks dari <b>0</b> sampai <b>9</b>. Itu berarti, <b>tableData [0]</b> mengembalikan elemen pertama dari "tableData" array.</div>
<div style="text-align: justify;">
Di Objective C, <b>NSArray </b>adalah class untuk membuat dan mengelola berbagai data. Anda dapat menggunakan <b><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html" target="_blank">NSArray</a></b> untuk membuat <b>array statis </b>yang jumlahnya ukurannya tetap. Jika Anda membutuhkan <b>array dinamis</b>, menggunakan <b><a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html" target="_blank">NSMutableArray</a> </b>sebagai gantinya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
NSArray menawarkan seperangkat metode <b>factory </b>untuk membuat <b>objek array</b>. Dalam kode yang kita buat, kita gunakan "<b>arrayWithObjects</b>" untuk <b>instantiate </b>objek NSArray dan preload dengan unsur-unsur tertentu (misalnya Hamburger).</div>
<div style="text-align: justify;">
Anda juga dapat menggunakan <b>built-in</b> metode lain untuk query dan mengelola array. Kemudian, kita akan memanggil metode "<b>count</b>" untuk query jumlah elemen data dalam array. Untuk mempelajari lebih lanjut tentang penggunaan NSArray, Anda selalu dapat merujuk ke dokumen resmi <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html" target="_blank">Apple</a>.</div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com1tag:blogger.com,1999:blog-6834479963228415759.post-591569975285189342015-04-21T14:24:00.000+07:002015-05-03T14:04:07.603+07:00Protokol UITableViewDelegate & UITableViewDataSource<div style="text-align: justify;">
Sebelumnya telah kita tambahkan protokol "<b>UITableViewDelegate</b>" dan "<b>UITableViewDataSource</b>" dalam file header. Ini mungkin membingungkan. apa saja kegunaan kedua protokol tersebut dalam membuat Table View?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>UITableView</b>, sebenarnya adalah class di balik <b>Table View</b>, yang dirancang untuk menjadi fleksibel dalam menangani berbagai <b>jenis data</b>. Contohnya Anda dapat menampilkan daftar negara atau nama kontak. Atau seperti contoh ini, kita akan menggunakan tampilan tabel untuk menyajikan daftar resep.</div>
<div style="text-align: justify;">
Jadi bagaimana Anda dapat mengetahui bahwa daftar data pada UITableView yang akan ditampilkan? <b>UITableViewDataSource</b> adalah jawabannya. Ini adalah hubungan antara<b> data</b> dan tampilan <b>tabel</b>. Protokol UITableViewDataSource menyatakan dua <b>metode </b>yang diperlukan (<b>tableView: cellForRowAtIndexPath</b> dan<b> tableView: numberOfRowsInSection</b>) bahwa Anda harus menerapkan di dalam program. Melalui penerapan metode ini, Anda diberitahu Table View berapa <b>banyak baris</b> untuk menampilkan dan data dalam setiap baris.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>UITableViewDelegate</b>, ini berkaitan dengan munculnya <b>UITableView</b>. Metode opsional protokol memungkinkan Anda mengatur <b>ketinggian baris tabel</b>, mengkonfigurasi<b> judul bagian</b> dan <b>footer</b>, <b>sel tabel</b> <b>re-order</b> dan lain-lain. </div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-24148720897530066452013-06-17T19:05:00.002+07:002015-05-03T14:03:19.757+07:00Tidak dapat Menampilkan Autoresizing Panel dalam Size InspectorUntuk Xcode 4.3 tata letak otomatis diaktifkan secara default. Untuk menonaktifkan hapus pilihan "use auto layout" pilihan di Interface Builder desain kanvas.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Luhzty8VSSF3Wx9rQ_z7iv-fpmEgJXEljHvOdV9pKnm-9-GYW_wdPUNf57z4fAjZwCTZ-50nCj8rRhj8sioqJBdB8W7FDK4Up2qem7IBjEY7d4rVxbcgZVlg5k0ku7ozkcuIEVJQFSBq/s1600/XcxAo.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Luhzty8VSSF3Wx9rQ_z7iv-fpmEgJXEljHvOdV9pKnm-9-GYW_wdPUNf57z4fAjZwCTZ-50nCj8rRhj8sioqJBdB8W7FDK4Up2qem7IBjEY7d4rVxbcgZVlg5k0ku7ozkcuIEVJQFSBq/s320/XcxAo.jpg" height="264" width="320" /></a></div>
<br />
<span id="goog_21329673"></span><span id="goog_21329674"></span><br />Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-58296864571109828062013-06-10T17:17:00.000+07:002015-05-03T14:02:11.592+07:00Contoh UIActivityIndicatorView<div style="text-align: justify;">
UIActivityIndicatorView digunakan untuk menunjukkan bahwa beberapa proses panjang diproses dibelakang layar, dan dapat diimplementasikan dengan menggunakan IBOutlet.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Paa tutorial ini kita akan membuat sebuah UIActivityIndicatorView dengan memulai dan menghentikan animasi. Mari kita mulai...</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Langkah 1: Buat sebuah proyek baru di Xcode.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Langkah 2: Set properti untuk UIActivityIndicatorView dalam file .h dan set @synthesis dalam file .m</div>
<div style="text-align: justify;">
<br /></div>
<br />
<span style="color: lime;">.h file: </span><br />
<br />
<span style="color: blue; font-family: Courier New, Courier, monospace;">@property (nonatomic,retain) UIActivityIndicatorView *activityIndicatorObject;</span><br />
<br />
<span style="color: lime;">.m file:</span><br />
<br />
<span style="color: blue; font-family: Courier New, Courier, monospace;">@synthesis activityIndicatorObject;</span><br />
<div>
<br /></div>
<div>
<div>
Langkah 3: Initialize object UIActivityIndicatorView dan posisi set.</div>
<div>
<br /></div>
<div>
<span style="color: lime;">/ / Initialize obyek ActivityIndicator</span></div>
</div>
<span style="font-family: Courier New, Courier, monospace;"><br /><span style="color: blue;"> activityIndicatorObject = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];</span></span><br />
<br />
<br />
<span style="color: lime;">/ / Set Posisi Tengah ActivityIndicator</span><br />
<div>
<br /></div>
<span style="color: blue; font-family: Courier New, Courier, monospace;"> activityIndicatorObject.center = CGPointMake(150, 150);</span><br />
<div>
<br /></div>
<div>
<span style="color: lime;">/ / Tambahkan ActivityIndicator pada View</span></div>
<div>
<br /></div>
<span style="color: blue; font-family: Courier New, Courier, monospace;">[self.view addSubview:activityIndicatorObject];</span><br />
<div>
<br /></div>
<div>
<div style="text-align: justify;">
Langkah 4: Menambahkan dua tombol di xib untuk mengatur aksi sebagai Method stopAnimating dan startAnimating. Itu digunakan untuk memulai dan menghentikan ActivityIndicator.</div>
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /><br />- (IBAction)startAnimating:(id)sender </span><span style="color: blue; font-family: 'Courier New', Courier, monospace;">{</span><span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span><span style="color: blue; font-family: 'Courier New', Courier, monospace;">[activityIndicatorObject startAnimating]; </span><span style="color: blue; font-family: Courier New, Courier, monospace;"><br />}<br /><br /> - (IBAction)stopAnimating:(id)sender </span><span style="color: blue; font-family: 'Courier New', Courier, monospace;">{</span><span style="color: blue; font-family: Courier New, Courier, monospace;"><br />[activityIndicatorObject stopAnimating];<br />}</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR1dPKDrl-AOu92NBHjDk4X-mqJEdSxA93fxJI0zV75Lqjdgr6ITndkv0nKhWQeYXHaOwac8ACZETV549w032Io0jBz3PYaKUNtZIEUURZyHMIBa_Ezd4eCQKWwaE29pEux47iXfYWplLg/s1600/ios-simulator-screen-shot-24-may-2013-12-55-03-am.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR1dPKDrl-AOu92NBHjDk4X-mqJEdSxA93fxJI0zV75Lqjdgr6ITndkv0nKhWQeYXHaOwac8ACZETV549w032Io0jBz3PYaKUNtZIEUURZyHMIBa_Ezd4eCQKWwaE29pEux47iXfYWplLg/s1600/ios-simulator-screen-shot-24-may-2013-12-55-03-am.png" /></a></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div>
Langkah 5: Jalankan project Anda</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgz8i4-y8FDg9mXFMDL2fUPuM5cKy0WPjJMTBbbcXSmORCmgaSdkOfqJWbpvr1Edu9mmghxspuJKLbEV-W3eIfP5fyNFLdG8RstOWCsl2eDaYWjk8RZ94eEQsHYFcpnJaRq7PvMq_3FnPTD/s1600/ios-simulator-screen-shot-24-may-2013-12-55-10-am.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgz8i4-y8FDg9mXFMDL2fUPuM5cKy0WPjJMTBbbcXSmORCmgaSdkOfqJWbpvr1Edu9mmghxspuJKLbEV-W3eIfP5fyNFLdG8RstOWCsl2eDaYWjk8RZ94eEQsHYFcpnJaRq7PvMq_3FnPTD/s1600/ios-simulator-screen-shot-24-may-2013-12-55-10-am.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-45714889309666959112013-06-10T16:04:00.000+07:002015-05-03T14:08:28.699+07:00Kustomisasi ActivityIndicatorViewTutorial ini menunjukkan bagaimana aktifitas indikator SDK oleh rounded view yang berisi tampilan aktivitas indikator dan label teks yang terlihat seperti contoh berikut:<br />
<br />
<br />
<br />
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA0U5Zo3G_U8ZxEAlIk7WIvHjLu1eEDFA8bR9vGM83cgyq0v0_XCbi_y505olWxOSijoQ1_z0evgus91j1oS7OD8Bk9aMyHfJmhUO9ofW2kvLFTBeoXYNgeg3m14UcLPxaGjiTE_Y7gmvj/s1600/loadingview.png"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA0U5Zo3G_U8ZxEAlIk7WIvHjLu1eEDFA8bR9vGM83cgyq0v0_XCbi_y505olWxOSijoQ1_z0evgus91j1oS7OD8Bk9aMyHfJmhUO9ofW2kvLFTBeoXYNgeg3m14UcLPxaGjiTE_Y7gmvj/s320/loadingview.png" /></a></div>
<br />
<br />
<br />
<br />
Bagaimana cara kerjanya: <br />
1) Pertama, delarasikan sebuah UIActivityIndicatorView, UIView dan contoh UILabel instance antarmuka controller tampilan di mana Anda ingin menerapkan custom indikator aktivitas.<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><br />@interface RootViewController : UIViewController {<br /> UIActivityIndicatorView *activityView;<br /> UIView *loadingView;<br /> UILabel *loadingLabel;<br />}<br /> <br />@property (nonatomic, retain) UIActivityIndicatorView * activityView;<br />@property (nonatomic, retain) UIView *loadingView;<br />@property (nonatomic, retain) UILabel *loadingLabel;</span><br />
<br />
<br />
<br />
2) Kedua, buat synthesize ketiga variabel class implementasi dan tambahkan kode berikut ke dalam viewDidLoad method:<br />
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<br />
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">// APPViewController.m</span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">// ActivityIndicatorView</span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">//</span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">// Created by Muhamad Yusup on 10/06/13.</span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">// Copyright (c) 2013 raharja. All rights reserved.</span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;">//</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p3">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s1">#import </span>"APPViewController.h"</span></div>
<div class="p3">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s1">#import </span>"QuartzCore/QuartzCore.h"</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p4">
<span style="color: blue; font-family: Courier New, Courier, monospace;">#ifdef __IPHONE_6_0</span></div>
<div class="p4">
<span style="color: blue; font-family: Courier New, Courier, monospace;"># define ALIGN_CENTER NSTextAlignmentCenter</span></div>
<div class="p4">
<span style="color: blue; font-family: Courier New, Courier, monospace;">#else</span></div>
<div class="p4">
<span style="color: blue; font-family: Courier New, Courier, monospace;"># define ALIGN_CENTER UITextAlignmentCenter</span></div>
<div class="p4">
<span style="color: blue; font-family: Courier New, Courier, monospace;">#endif</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s2">@interface</span><span class="s3"> </span>APPViewController<span class="s3"> ()</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p6">
<span style="color: blue; font-family: Courier New, Courier, monospace;">@end</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s2">@implementation</span> APPViewController</span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s2">@synthesize</span> activityView;</span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s2">@synthesize</span> loadingLabel;</span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s2">@synthesize</span> loadingView;</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">- (<span class="s2">void</span>)viewDidLoad</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">{</span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span><span class="s2">super</span><span class="s3"> </span>viewDidLoad<span class="s3">];</span></span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span>// Do any additional setup after loading the view, typically from a nib.</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingView</span><span class="s3"> = [[</span><span class="s4">UIView</span><span class="s3"> </span>alloc<span class="s3">] </span>initWithFrame<span class="s3">:</span>CGRectMake<span class="s3">(</span><span class="s5">75</span><span class="s3">, </span><span class="s5">155</span><span class="s3">, </span><span class="s5">170</span><span class="s3">, </span><span class="s5">170</span><span class="s3">)];</span></span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingView</span><span class="s3">.</span><span class="s6">backgroundColor</span><span class="s3"> = [</span><span class="s4">UIColor</span><span class="s3"> </span>colorWithRed<span class="s3">:</span><span class="s5">0</span><span class="s3"> </span>green<span class="s3">:</span><span class="s5">0</span><span class="s3"> </span>blue<span class="s3">:</span><span class="s5">0</span><span class="s3"> </span>alpha<span class="s3">:</span><span class="s5">0.5</span><span class="s3">];</span></span></div>
<div class="p9">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingView</span><span class="s3">.</span>clipsToBounds<span class="s3"> = </span><span class="s2">YES</span><span class="s3">;</span></span></div>
<div class="p9">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingView</span><span class="s3">.</span>layer<span class="s3">.</span>cornerRadius<span class="s3"> = </span><span class="s5">10.0</span><span class="s3">;</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">activityView</span><span class="s3"> = [[</span><span class="s4">UIActivityIndicatorView</span><span class="s3"> </span>alloc<span class="s3">] </span>initWithActivityIndicatorStyle<span class="s3">:</span>UIActivityIndicatorViewStyleWhiteLarge<span class="s3">];</span></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span>activityView<span class="s3">.</span><span class="s6">frame</span><span class="s3"> = </span><span class="s7">CGRectMake</span><span class="s3">(</span><span class="s5">65</span><span class="s3">, </span><span class="s5">40</span><span class="s3">, </span>activityView<span class="s3">.</span><span class="s6">bounds</span><span class="s3">.</span><span class="s6">size</span><span class="s3">.</span><span class="s6">width</span><span class="s3">, </span>activityView<span class="s3">.</span><span class="s6">bounds</span><span class="s3">.</span><span class="s6">size</span><span class="s3">.</span><span class="s6">height</span><span class="s3">);</span></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span>loadingView<span class="s3"> </span><span class="s7">addSubview</span><span class="s3">:</span>activityView<span class="s3">];</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingLabel</span><span class="s3"> = [[</span><span class="s4">UILabel</span><span class="s3"> </span>alloc<span class="s3">] </span>initWithFrame<span class="s3">:</span>CGRectMake<span class="s3">(</span><span class="s5">20</span><span class="s3">, </span><span class="s5">115</span><span class="s3">, </span><span class="s5">130</span><span class="s3">, </span><span class="s5">22</span><span class="s3">)];</span></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span>loadingLabel<span class="s3">.</span><span class="s6">backgroundColor</span><span class="s3"> = [</span>UIColor<span class="s3"> </span><span class="s7">clearColor</span><span class="s3">];</span></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span>loadingLabel<span class="s3">.</span><span class="s6">textColor</span><span class="s3"> = [</span>UIColor<span class="s3"> </span><span class="s7">whiteColor</span><span class="s3">];</span></span></div>
<div class="p9">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingLabel</span><span class="s3">.</span>adjustsFontSizeToFitWidth<span class="s3"> = </span><span class="s2">YES</span><span class="s3">;</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p9">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingLabel</span><span class="s3">.</span>textAlignment<span class="s3"> = </span><span class="s8">ALIGN_CENTER</span><span class="s3">;</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p3">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span><span class="s4">loadingLabel</span><span class="s3">.</span><span class="s6">text</span><span class="s3"> = </span>@"Getting Channel List..."<span class="s3">;</span></span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"> </span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span>loadingView<span class="s3"> </span><span class="s7">addSubview</span><span class="s3">:</span>loadingLabel<span class="s3">];</span></span></div>
<div class="p5">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span><span class="s2">self</span><span class="s3">.</span><span class="s6">view</span><span class="s3"> </span><span class="s7">addSubview</span><span class="s3">:</span>loadingView<span class="s3">];</span></span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span><span class="s4">activityView</span><span class="s3"> </span>startAnimating<span class="s3">];</span></span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">}</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">- (<span class="s2">void</span>)didReceiveMemoryWarning</span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">{</span></div>
<div class="p8">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> [</span><span class="s2">super</span><span class="s3"> </span>didReceiveMemoryWarning<span class="s3">];</span></span></div>
<div class="p1">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><span class="s3"> </span>// Dispose of any resources that can be recreated.</span></div>
<div class="p7">
<span style="color: blue; font-family: Courier New, Courier, monospace;">}</span></div>
<div class="p2">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<br />
<div class="p6">
<span style="color: blue; font-family: Courier New, Courier, monospace;">@end</span></div>
<br />
<br />
<div style="text-align: justify;">
Pada awalnya akan muncul <i>loading view</i> melakukan <i>initialized</i> dan konfigurasi dengan ukuran dan sudut bulat. Ini akan membentuk bagian agak gelap pada indikator aktivitas dan label teks tersebut muncul. Selanjutnya, <i>activity view</i> akan melakukan inisialisasi, konfigurasi dan penambahan sebagai <i>sub view</i> ke dalam <i>loading view</i>. Sama juga pada <i>loading</i> label yang juga akan melakukan inisialisasi, konfigurasi dengan beberapa parameter dan penambahan sebagai <i>sub view </i>ke dalam <i>loading view</i>. Akhirnya, loading view berisi tampilan aktivitas indikator dan loading label yang ditambahkan sebagai <i>sub view</i> untuk<i> super view</i> pada <i>view controller </i>(Di contohkan pada <b>RootViewController</b> pada toturial ini).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br class="Apple-interchange-newline" /></div>
3) Jalankan aktivitas indikator<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">[activityView startAnimating];</span><br />
<br />
<br />
Pada point class implementasi di mana pengolahan data atau loading akan dijalankan. Ketika aktivitas <i>processing</i> dan <i>loading</i> dilakukan, indikator aktivitas menghentikan animasi dan menghapus tampilan indikator aktivitas dari super view pada penerapannya.<br />
<div>
<br />
<span style="font-family: Courier New, Courier, monospace;">[activityView stopAnimating];<br />[loadingView removeFromSuperview];</span><br />
<div>
<br /></div>
<div>
4) Selanjutnya impor <i>class</i> QuartzCore ke <b>view controller</b> <i>class</i> implementation.</div>
</div>
<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">#import "QuartzCore/QuartzCore.h"</span><br />
<div>
<span style="font-family: Courier New, Courier, monospace;"><br /></span></div>
Demikian tutorial untuk membuat <i>custome</i> ActivityIndicator, selanjutnya anda gabungkan dengan aplikasi yang lain dan hasilnya akan tampil seperti pada gambar di atas.Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-45973774379435387572013-06-07T15:35:00.001+07:002015-05-03T14:08:51.871+07:00Pengenalan Object Oriented Programming<div style="text-align: justify;">
Pada tutorial sebelum sudah dijelaskan bagaimana menggunakan Segue di Storyboard untuk menghubungkan data antara view control yang berbeda. Kita telah membuat sebuah aplikasi sederhana untuk menampilkan daftar resep (recipes). Ketika user men-<i>tap</i> pada salah satu resep, aplikasi kemudian melakukan navigasi ke tampilan detail nama resep (recipe). Ini adalah aplikasi yang sangat sederhana. Tetapi jika Anda memahami cara kerjanya, ini adalah landasannya yang dapat membantu Anda dalam mengembangkan iOS.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Apakah Anda berhasil membuat tampilan detail (<i>detail view</i>) sendiri untuk aplikasi Resep (<i>Recipe</i>)? Lagi pula, saya akan kembali menunjukkan kepada Anda bagaimana membuat layar detail (<i>detail screen</i>). Tapi sebelum itu, saya harus menjelaskan kepada Anda tentang dasar-dasar Pemrograman Berorientasi Objek (<i>Object Oriented Programming - OOP</i>). Dalam tutorial berikutnya, kita akan pelajari apa saja yang dibutuhkan untuk membuat tampilan layar detail.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Jangan takut dengan istilah "Object Oriented Programming" atau OOP singkatnya. Ini bukanlah sesuatu yang baru sebagai bahasa pemrograman tapi sebuah konsep pemrograman / teknik. Saya sengaja meninggalkan konsep OOP ketika saya pertama kali mulai menulis tutorial pemrograman iOS. Saya ingin menjaga hal sederhana dan menampilkannya (bahkan tanpa latar belakang pemrograman) bagaimana membuat sebuah aplikasi. Saya tidak ingin menakut-nakuti Anda untuk mengenal istilah teknis. Namun, saya pikir sudah waktunya anda mempelajari konsep ini. Jika Anda masih membaca artikel ini, saya percaya bahwa Anda bertekad untuk mempelajari pemrograman iOS.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Oke, mari kita mulai.</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Object Oriented Programming - Beberapa Teori</h4>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Objective-C dikenal sebagai Object Oriented Programming (OOP). OOP adalah cara membangun aplikasi perangkat lunak yang terdiri dari banyak objek (<i>object</i>). Dengan kata lain, sebagian besar kode yang sudah Anda tulis di app dalam beberapa cara berurusan dengan banyak <i>object</i> dari beberapa jenis. UIViewController, UIButton, UINavigationController dan UITableView adalah beberapa <i>object</i> dari iOS SDK. Tidak hanya <i>object</i> yang built-in yang ada di app iOS, akan tetapi kita dapat membuat <i>object</i> sendiri seperti RecipeDetailViewController dan SimpleTableCell.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Jadi mengapa harus OOP? Salah satu alasan penting adalah bahwa kita ingin menguraikan sebuah software yang kompleks menjadi bagian-bagian kecil (atau blok bangunan) yang lebih mudah untuk dikembangkan dan dikelola. Di sini, bagian-bagian yang lebih kecil itulah disebut obyek (<i>object</i>). Setiap <i>object</i> memiliki tanggung jawab sendiri dan objek saling berkoordinasi dalam rangka untuk membuat perangkat lunak bekerja. Itulah konsep dasar OOP.</div>
<div style="text-align: justify;">
----</div>
<div style="text-align: justify;">
Ambil aplikasi <i>Hello World </i>sebagai contoh. <i>Object</i> UIViewController bertanggung jawab untuk tampilan dari aplikasi dan sebagai tempat untuk tombol <i>Hello World</i>. UIButton (yaitu tombol <i>Hello World</i>) <i>object</i> yang bertanggung jawab untuk menampilkan tombol <span style="background-color: white;">iOS standar dengan merespon sentuhan pada layar</span>. <i>Object</i> UIAlertView, di sisi lain, bertanggung jawab untuk menampilkan pesan peringatan kepada pengguna. Yang paling penting, semua <i>object</i> ini bekerja sama untuk menciptakan aplikasi Hello World.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<h2 style="color: #333333; font-family: Oswald, arial, serif; font-size: 36px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
</h2>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-54246031280053802832013-06-05T13:12:00.001+07:002015-05-03T14:04:56.742+07:00Menggunakan Storyboards untuk Membangun Navigation Controller dan Table ViewPada tutorial kali ini kita akan membahas tentang sesuatu yang baru - Storyboard. Ini adalah salah satu fitur yang paling menarik diperkenalkan di Xcode 4.2 dan iOS 5 SDK. Dengan menggunakan Storyboard ini, kita dimanjakan dalam membuat app. Secara sederhana dengan Storyboard memungkinkan kita dengan mudah merancang user interface dari aplikasi iOS.<br />
<br />
Disini saya akan menunjukkan kepada Anda bagaimana menggunakan Storyboard untuk membangun Navigasi interface dan mengintegrasikannya dengan UITableView. Disini saya coba buat sederhana terlebih dahulu dan fokus pada penjelasan konsep. Jadi tidak ada interface yang ciamik atau grafis manarik.<br />
<br />Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-85795756338048998962013-06-05T13:04:00.001+07:002015-05-03T14:09:31.163+07:00Tutorial Storyboards Segue: Pass Data diantara ViewControllersAdmin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-39746328154965305702013-06-04T15:51:00.001+07:002015-05-03T14:12:42.373+07:00Membuat Simple TableApp dengan PList (Property List)<div style="text-align: justify;">
Pada tutorial kali ini sebelumnya kita sudah mempelajari bagaimana membuat aplikasi sederhana tentang menampilkan daftar resep. Jika anda melihat ke dalam aplikasi ini, semua resep sudah dimasukan ke dalam kode sumbernya. Pada tutorial ini saya menjaga bagaimana dibuat sesederhana mungkin dan fokus menunjukkan cara membuat UITableView. Namun, pada prakteknya ada beberapa penulisan kode yang sulit pada setiap item dalam kode. Dalam aplikasi nyatam kita gunakan untuk menampilkan informasi yang sifatnya statis dan menempatkannya ke dalam sebuah file atau database di tempat lain. Dalam pemrograman iOS, kita gunakan untuk menyimpan data struktur sederhana contohnya pengaturan aplikasi. Di dalam tutorial ini akan kita akan membuat berubahan pada Tabel sederhana dengan menggunakan Property List.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Secara singkat beberapa materi yang kita bahas diantaranya adalah:</div>
<ol>
<li style="text-align: justify;">Mengkonversi data dari tabel array (statis) ke Property List</li>
<li style="text-align: justify;">Bagaimana membaca Property List</li>
</ol>
<div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
<a name='more'></a><div style="text-align: justify;">
<span style="line-height: 1.25;">Mengapa mengeksternalisasi Tabel Data?</span></div>
</h4>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Ini adalah cara yang baik untuk memisahkan data statis dari kode. Apa keuntungannya kita harus membuat tabel data ke sumber eksternal? Mari saya coba meminta Anda menambahkan 50 resep lainnya di dalam tabel sederhana dibawah ini. Mungkin Anda akan merasa direpotkan dengan mengubah kembali kode dan menempatkan semua resep baru di dalam inisialisasi berikut ini:</div>
<div style="text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: wrap;">
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize table data</span><br />
tableData <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Egg Benedict"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Mushroom Risotto"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Full Breakfast"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Hamburger"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Egg Sandwich"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Creme Brelee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"White Chocolate Donut"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Starbucks Coffee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Vegetable Curry"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Instant Noodle with Egg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Noodle with BBQ Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Japanese Noodle with Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Green Tea"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Thai Shrimp Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Angry Birds Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Cheese Panini"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize thumbnails</span><br />
thumbnails <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"egg_benedict.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"mushroom_risotto.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"full_breakfast.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"hamburger.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_egg_sandwich.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"creme_brelee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"white_chocolate_donut.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"starbucks_coffee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"vegetable_curry.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"instant_noodle_with_egg.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"noodle_with_bbq_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"japanese_noodle_with_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"green_tea.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"thai_shrimp_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"angry_birds_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_cheese_panini.jpg"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize Preparation Time</span><br />
prepTime <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"10 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"1 hour"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"45 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"5 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"8 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"5 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"1.5 hour"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"4 hours"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"10 min"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;</div>
<div>
<br /></div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sebenarnya tidak ada yang salah kita menggunakan cara ini. Tapi kalau melihat kode! Ini tidak mudah untuk mengeditnya dan kita harus secara teliti mengikuti sintaks Objective-C. Mengubah kode pada inisilisasi diatas rentan dapat menimbulkan kesalahan kalau kita kurang teliti. Itu bukanlah yang kita inginkan. ini akan lebih baik lagi jika kita pisahkan data dan logika pemrograman (yaitu kode). Apakah terlihat lebih baik jika data tabel disimpan seperti ini?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBWRvgirmiMkBJ3q3q5KiuWWqUajFu4mGwR9TRjP2sQowM_Z-LD9u9Yeg2Bn7aGj0fWU1K_ddebEpJXGA06JNNG5rvnBR1gWnbuyxV_kSjVujz6-VN5VCCslKBoXxCNHQJ2NHEh4Jw_Lai/s1600/Sample-Property-List.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBWRvgirmiMkBJ3q3q5KiuWWqUajFu4mGwR9TRjP2sQowM_Z-LD9u9Yeg2Bn7aGj0fWU1K_ddebEpJXGA06JNNG5rvnBR1gWnbuyxV_kSjVujz6-VN5VCCslKBoXxCNHQJ2NHEh4Jw_Lai/s400/Sample-Property-List.jpg" height="281" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="wp-caption-text" style="color: #333333; font-family: Lora, serif; font-size: 14px; line-height: 1.5625; margin-bottom: 5px; margin-top: 5px; padding: 0px; text-align: center;">
<div style="text-align: justify;">
Contoh Property List</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Pada kenyataannya informasi yang ditampilkan (disini dicontohnya informasi resep) tidak membutuhkan orang yang memiliki pengalaman dalam pemrograman iOS. Ketika kita tempatkan data di dalam file eksternal, lebih mudah untuk membaca/mengedit dan lebih di mengerti. Selain itu bagaimana kita dapat tempatkan data pada sis server (Cloud), semua permintaan data pada app ditarik dari sisi server. ini akan memberikan manfaat yang lebih besar, dengan memisahkan data dan menempatkannya pada Cloud kita dapat mengubah data kapan saja tanpa memperbaharui aplikasi kita.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Disini kita tidak akan membahas lebih jauh tentang Cloud. Mari kita kembali pada tutorial semula yaitu bagaimana kita dapat menempatkan semua resep dalam Daftar Properti.</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Apa itu Property List?</h4>
<div style="text-align: justify;">
Property List menawarkan cara yang mudah untuk menyimpan struktur data sederhana. Biasanya muncul dalam format XML. Jika Anda telah mengedit beberapa file konfigurasi di Mac atau iPhone sebelumnya, Anda bisa menemukan file dengan ekstensi .plist.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Anda tidak dapat menggunakan daftar properti untuk menyimpan semua jenis data. Item data dalam daftar properti adalah dari sejumlah jenis termasuk "array", "dictionary", "string", dll Untuk detail termasuk tipe yang didukung, Anda dapat dapatkan referensi di <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/PropertyLists/AboutPropertyLists/AboutPropertyLists.html" style="color: #ed702b; font-family: Lora, serif; font-size: 16px; line-height: 25px; text-decoration: none;">Property List documentation</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Property List umumnya digunakan dalam aplikasi iOS untuk menyimpan pengaturan aplikasi. Ini tidak berarti Anda tidak dapat menggunakannya untuk tujuan lain. Tapi itu dirancang untuk menyimpan sejumlah kecil data.</div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Apakah ini jalan terbaik menyimpan Tabel Data?</h4>
</div>
<div>
<div style="text-align: justify;">
Tidak, jelas tidak. kita menggunakan Property List untuk menunjukkan bagaimana untuk menyimpan data tabel di file eksternal. Ini hanya contoh. Ketika Anda mendapatkan lebih banyak pengalaman, Anda akan belajar cara lain untuk menyimpan data.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Mengkonversi Data Tabel ke Property List</h4>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Pertama, buka Project Simple Table di Xcode. Klik kanan pada folder "<b>SimpleTable</b>" dan pilih "New File ...". Pilih "<b>Other</b>" di bawah template "<b>iOS</b>, pilih "<b>Property List</b>" dan klik "<b>Next</b>" untuk melanjutkan.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGtYbPkmHba0Xbx3k6ShFP7zN9FAQMRgpiXgZ5gUM2Q6mCtDFQ_TRRng6_g8N_IPwI4gCf5R6b0fs4Ltl2C4mPPnuLk2zI3cKK2pQryTMMBG8Ykbn1_2O_0oF6jftaq0uodMR7MP575AJV/s1600/Xcode-New-Property-List-File.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGtYbPkmHba0Xbx3k6ShFP7zN9FAQMRgpiXgZ5gUM2Q6mCtDFQ_TRRng6_g8N_IPwI4gCf5R6b0fs4Ltl2C4mPPnuLk2zI3cKK2pQryTMMBG8Ykbn1_2O_0oF6jftaq0uodMR7MP575AJV/s400/Xcode-New-Property-List-File.jpg" height="267" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Buat file baru Property List</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Bila diminta, gunakan "resep" sebagai nama file. Setelah Anda konfirmasi, Xcode akan membuat file property list. Secara default, property list adalah kosong.</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSOob8khyk0AcWcElqTX6no43gBh8411cw-oSfmGNOKVHcJqOgJjuv9hHQdCUubUFn4OsQIpc7dxN3PDguTkrvNKGgXYUynWB6n6gcje76mEx2FHhLnVYNFZ-vRahYxe4ISQOvFOUk_49o/s1600/Xcode-Recipe-Plist.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSOob8khyk0AcWcElqTX6no43gBh8411cw-oSfmGNOKVHcJqOgJjuv9hHQdCUubUFn4OsQIpc7dxN3PDguTkrvNKGgXYUynWB6n6gcje76mEx2FHhLnVYNFZ-vRahYxe4ISQOvFOUk_49o/s400/Xcode-Recipe-Plist.jpg" height="297" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Property List yang kosong</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Ada dua cara untuk mengedit property list. Klik kanan pada area editing dan pilih "<b>Add Row</b>" untuk menambahkan nilai baru.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaLgt1R-qW1hiEIQWqc4fybgal4Y-UOzO9Da6UH2oi4FzTkGY4aEROcvsxlyAosB1JfepwCr4XEvsgQdEtKE6uZ2EfCn1bdc9Bcqs93dYW0SeaTshs-i24-mtpDztDFP5pDx0AdKKBG9G/s1600/Xcode-Property-List-Add-Row.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcaLgt1R-qW1hiEIQWqc4fybgal4Y-UOzO9Da6UH2oi4FzTkGY4aEROcvsxlyAosB1JfepwCr4XEvsgQdEtKE6uZ2EfCn1bdc9Bcqs93dYW0SeaTshs-i24-mtpDztDFP5pDx0AdKKBG9G/s400/Xcode-Property-List-Add-Row.jpg" height="323" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Menambahkan file baru pada Editor Property List</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Kita akan tambahkan tiga data array ke dalam property list, dengan nama: <b>RecipeName</b>, <b>Miniatur</b> dan <b>PrepTime</b>. Kuncinya berfungsi sebagai <b>identifier</b> yang akan kita gunakan dalam penulisan kode untuk memilih array yang sesuai.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrxwPAzLZVUhcqvdRqFsArs6bAN1QlW8ZqojSNyeSneJ-7C0YGrVVLqSJW6m-QoZhyphenhyphenPBji2426BKfg-R-FS5vQ2EUWGAWF39a0ydBZBcmjMiQkWRMNEUY2Jkjvwd_bk85GIhp3kikga2cR/s1600/SimpleTableApp-Property-List-Array.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrxwPAzLZVUhcqvdRqFsArs6bAN1QlW8ZqojSNyeSneJ-7C0YGrVVLqSJW6m-QoZhyphenhyphenPBji2426BKfg-R-FS5vQ2EUWGAWF39a0ydBZBcmjMiQkWRMNEUY2Jkjvwd_bk85GIhp3kikga2cR/s400/SimpleTableApp-Property-List-Array.jpg" height="77" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Tentukan tiga array dalam Property List</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Untuk menambahkan data dalam array, hanya dengan mengklik tombol ikon "+" untuk menambahkan item baru. Ikuti langkah-langkah dalam ilustrasi di bawah ini jika Anda tidak tahu bagaimana melakukannya.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTQO3fl2lcvl9-IfDYvWAuSP3gyeND7x-jOx6a4uMQZGOc2yZKQha51L4IBqUGznZYSUvSJsVllGSkTim0G9xuIlzo6DaED7mra6JEYskgWRReke6bqz2JzfnK4tzZYxtuUwXGFg4bpKgB/s1600/Add-Property-in-Property-List.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTQO3fl2lcvl9-IfDYvWAuSP3gyeND7x-jOx6a4uMQZGOc2yZKQha51L4IBqUGznZYSUvSJsVllGSkTim0G9xuIlzo6DaED7mra6JEYskgWRReke6bqz2JzfnK4tzZYxtuUwXGFg4bpKgB/s400/Add-Property-in-Property-List.jpg" height="307" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Langkah demi Langkah Prosedur untuk Menambahkan Item di Array</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Ulangi prosedur tersebut sampai Anda tambahkan semua nilai untuk array. Property List akan terlihat seperti ini:</div>
</div>
<div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTSJf_uEFyOzRcIrAIXE9THzkm6vbd18LZWY6vfQ_JBP2yCDJrY_Ef6wiHpxevJWnZAb-5AK4A8PPp-7eXeY2H2gyA6fYAjTV1vMMWw0pYsE_1hN6-DFEUVGWAw15lzoQs3CeASlJBBpXO/s1600/Sample-Property-List.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTSJf_uEFyOzRcIrAIXE9THzkm6vbd18LZWY6vfQ_JBP2yCDJrY_Ef6wiHpxevJWnZAb-5AK4A8PPp-7eXeY2H2gyA6fYAjTV1vMMWw0pYsE_1hN6-DFEUVGWAw15lzoQs3CeASlJBBpXO/s400/Sample-Property-List.jpg" height="282" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Resep Property List yang sudah dibuat</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Untuk kemudahan tutorial ini, Anda dapat mendownload <a href="http://www.4shared.com/zip/m24eOD1J/recipesplist.html" target="_blank">recipes.plist </a>dan tambahkan ke dalam project Anda.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti disebutkan sebelumnya, property list biasanya disimpan dalam format XML. Untuk melihat sumber dari property list, klik kanan dan pilih "<b>Open as Source Code</b>".</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8tmyEoVOe7Uk3ihlKdkU17Rr1zzqIYwbGdHJ1sMvvej-l0nYJw8BCqH7SbGFfYcTRza7DpX2RsnYoBLn3kyFvc6Yzpbli8ExGsnlcxFoXVnNUUS8VhOn7EncWKKrWtSkfeuPqBq77hPo4/s1600/Open-Property-List-as-Source-Code.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8tmyEoVOe7Uk3ihlKdkU17Rr1zzqIYwbGdHJ1sMvvej-l0nYJw8BCqH7SbGFfYcTRza7DpX2RsnYoBLn3kyFvc6Yzpbli8ExGsnlcxFoXVnNUUS8VhOn7EncWKKrWtSkfeuPqBq77hPo4/s400/Open-Property-List-as-Source-Code.jpg" height="202" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px; text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px; text-align: start;">Kode sumber “recipes.plist” akan muncul seperti ini:</span></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5MLWGzhBOtIMUHk5ZmPFelOrywqKRctsRiy2NmFeg3_wpKz-voH5uHXyV8ay0F9r0OIE3irPbeYCI1yx-cOr3rekioB3Y2C31gLd40sKjbgbiGPAlk79xsWOYSEjkcn4ToxYXE0XJ9_KU/s1600/Property-List-Source-Code.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5MLWGzhBOtIMUHk5ZmPFelOrywqKRctsRiy2NmFeg3_wpKz-voH5uHXyV8ay0F9r0OIE3irPbeYCI1yx-cOr3rekioB3Y2C31gLd40sKjbgbiGPAlk79xsWOYSEjkcn4ToxYXE0XJ9_KU/s400/Property-List-Source-Code.jpg" height="321" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px; text-align: start;"></span></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Menambahkan Property List ke dalam Objective C</h4>
<div class="separator" style="clear: both; text-align: justify;">
Selanjutnya, kita akan ubah kode dan kita akan masukan daftar resep dari property list. Ini cukup mudah untuk membaca isi dari property list. IOS SDK sudah dilengkapi dengan beberapa fungsi built-in untuk menangani read/write file.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Ganti kode berikut:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: nowrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize table data</span><br />
tableData <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Egg Benedict"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Mushroom Risotto"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Full Breakfast"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Hamburger"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Egg Sandwich"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Creme Brelee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"White Chocolate Donut"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Starbucks Coffee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Vegetable Curry"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Instant Noodle with Egg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Noodle with BBQ Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Japanese Noodle with Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Green Tea"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Thai Shrimp Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Angry Birds Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Cheese Panini"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize thumbnails</span><br />
thumbnails <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"egg_benedict.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"mushroom_risotto.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"full_breakfast.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"hamburger.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_egg_sandwich.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"creme_brelee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"white_chocolate_donut.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"starbucks_coffee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"vegetable_curry.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"instant_noodle_with_egg.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"noodle_with_bbq_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"japanese_noodle_with_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"green_tea.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"thai_shrimp_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"angry_birds_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_cheese_panini.jpg"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize Preparation Time</span><br />
prepTime <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"10 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"1 hour"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"45 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"5 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"30 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"8 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"20 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"5 min"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"1.5 hour"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"4 hours"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"10 min"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;</div>
</td></tr>
</tbody></table>
</div>
<div style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px; margin-bottom: 25px; padding: 0px;">
<div style="text-align: justify;">
dengan:</div>
</div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: nowrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Find out the path of recipes.plist</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSString</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>path <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSBundle</span></a> mainBundle<span style="color: #002200; line-height: 1.4em;">]</span> pathForResource<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"recipes"</span> ofType<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"plist"</span><span style="color: #002200; line-height: 1.4em;">]</span>; <br />
<br style="line-height: 1.4em;" />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Load the file content and read the data into arrays</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSDictionary</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>dict <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDictionary_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSDictionary</span></a> alloc<span style="color: #002200; line-height: 1.4em;">]</span> initWithContentsOfFile<span style="color: #002200; line-height: 1.4em;">:</span>path<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
tableData <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>dict objectForKey<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"RecipeName"</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
thumbnails <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>dict objectForKey<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Thumbnail"</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
prepTime <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>dict objectForKey<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"PrepTime"</span><span style="color: #002200; line-height: 1.4em;">]</span>;</div>
</td></tr>
</tbody></table>
</div>
<div class="note" style="background-color: #fef6d2; background-position: 20px 13px; background-repeat: no-repeat no-repeat; border-bottom-color: rgb(239, 227, 174); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(239, 227, 174); border-top-style: solid; border-top-width: 1px; color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px; margin-bottom: 20px; padding: 10px;">
<div style="text-align: justify;">
Di balik Perubahan Kode</div>
<div style="text-align: justify;">
Baris # 2 - Sebelum membaca "recipes.plist" file, bertujuan untuk mengambil path lengkap dari resource.</div>
<div style="text-align: justify;">
Baris # 5 - Kita definisikan tiga key seperti (<b>RecipeName</b>, <b>Miniatur</b>, <b>PrepTime</b>) dalam property list. Disini dijelaskan bahwa setiap key dikaitkan dengan array tertentu, yang merupakan nilai. Dalam pemrograman iOS, kita menggunakan kamus istilah untuk merujuk pada hubungan pasangan key-value ini. Class NSDictionary menyediakan metode yang diperlukan untuk mengelola dictionary. Di sini kita menggunakan "<b>initWithContentsOfFile</b>" method class NSDictionary untuk membaca pasangan key-value dalam file property list.</div>
<div style="text-align: justify;">
Baris # 6-8 - ini baris kode mengambil array yang sesuai dengan kunci kita definisikan sebelumnya.
</div>
</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah lakukan perubahan pada kode, kita akan coba jalankan aplikasi ini yaitu aplikasi resep yang ditampilkan dari property list.
</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-68143255239565955872013-05-31T11:24:00.000+07:002015-05-03T14:15:07.883+07:00Menyesuaikan TableViewCell untuk UITableView<div style="text-align: justify;">
Sebelumnya, kami telah membuat TableView aplikasi sederhana untuk menampilkan daftar resep dengan gambar yang telah ditentukan.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Tampilan gambar yang berbeda untuk baris yang berbeda pula. Pada tutorial sebelumnya saya telah membuat tutorial dengan menampilkan thumbnail yang sama untuk semua baris. Bukankah lebih baik untuk menampilkan gambar yang berbeda untuk setiap resep?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Tampilan Thumbnail yang Berbeda</h4>
<div style="text-align: justify;">
Sebelum kita mengubah kode, mari kita kembali kode untuk menampilkan thumbnail dalam baris tabel.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-mrc-QYCaY_Cwz86eGIR9uzDX-awEL5-6NohiC69riYl1apuQvBF01ft01jZrm639PY3OQ3J8A6Sv6ekHyam9tEXXdQMJA3_PopAJ5aTmqM9ZfPm661xH1Xm7WvYrf_3ZSo7TVCgdyCCA/s1600/SimpleTable-Image-Code.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-mrc-QYCaY_Cwz86eGIR9uzDX-awEL5-6NohiC69riYl1apuQvBF01ft01jZrm639PY3OQ3J8A6Sv6ekHyam9tEXXdQMJA3_PopAJ5aTmqM9ZfPm661xH1Xm7WvYrf_3ZSo7TVCgdyCCA/s400/SimpleTable-Image-Code.jpg" height="115" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Pada tutorial sebelumnya kita telah menambahkan baris kode untuk menginstruksikan UITableView untuk menampilkan "<b>creme_brelee.jpg</b>" dalam setiap baris. Jelas, untuk menunjukkan gambar yang berbeda, kita perlu mengubah baris kode. Seperti dijelaskan sebelumnya, "cellForRowAtIndexPath" metode ini disebut oleh iOS secara otomatis setiap kali sebelum baris tabel akan ditampilkan.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div 100="" class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSIndexPath</span></a> <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>indexPath</div>
</td></tr>
</tbody></table>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Jika Anda melihat ke dalam parameter method, itu melewati "indexPath" ketika dipanggil. Parameter indexPath berisi nomor baris (serta nomor section) dari baris tabel. Anda hanya dapat menggunakan properti "indexPath.row" untuk mengetahui baris yang menunjuk kepada posisi saat ini. Seperti array, hitungan baris tabel dimulai dari nol. Dengan kata lain, "indexPath.row" properti kembali 0 untuk baris pertama dari tabel.</div>
<a name='more'></a><div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Jadi untuk menampilkan thumbnail yang berbeda, kita akan menambahkan array baru (yaitu thumbnail) yang menyimpan nama file thumbnail:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div 100="" class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;">
<tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13<br />
14<br />
15</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #a61390; line-height: 1.4em;">@implementation</span> SimpleTableViewController<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>tableData;<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>thumbnails;<br />
<span style="color: #002200; line-height: 1.4em;">}</span><br />
<br style="line-height: 1.4em;" />
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span><span style="color: #a61390; line-height: 1.4em;">void</span><span style="color: #002200; line-height: 1.4em;">)</span>viewDidLoad<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #002200; line-height: 1.4em;">[</span>super viewDidLoad<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize table data</span><br />
tableData <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Egg Benedict"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Mushroom Risotto"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Full Breakfast"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Hamburger"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Egg Sandwich"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Creme Brelee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"White Chocolate Donut"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Starbucks Coffee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Vegetable Curry"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Instant Noodle with Egg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Noodle with BBQ Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Japanese Noodle with Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Green Tea"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Thai Shrimp Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Angry Birds Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Cheese Panini"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize thumbnails</span><br />
thumbnails <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"egg_benedict.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"mushroom_risotto.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"full_breakfast.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"hamburger.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_egg_sandwich.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"creme_brelee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"white_chocolate_donut.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"starbucks_coffee.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"vegetable_curry.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"instant_noodle_with_egg.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"noodle_with_bbq_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"japanese_noodle_with_pork.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"green_tea.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"thai_shrimp_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"angry_birds_cake.jpg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"ham_and_cheese_panini.jpg"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
<div>
<span style="color: #002200; line-height: 1.4em;"><br /></span></div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti yang dapat Anda lihat dari kode di atas, kita menentukan thumbnail array dengan daftar nama file gambar. Urutan gambar yang selaras dengan bahwa dari "tableData".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Untuk mudahkan mendapatkan thumbmail, Anda dapat <a href="http://www.mediafire.com/?s50oa2dcxwxeh3l">men-download gambar</a> yang sudah saya siapkan dan menambahkannya ke dalam proyek Anda. Pastikan "Copy items into destination group’s folder" diaktifkan.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoZfpxumWnhQBL2xlUd34GPiMdi0VQsIptr86GBexQionCuy1826IS43-v9u8VAwXUHUg9NgG9oizx283wPlVqCaQLZqMfRdYTI1TXrlztQU0gYltNtJbY-Yw-IrR6e-_q7bI5l3aEkJGP/s1600/SimpleTable-Add-File.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoZfpxumWnhQBL2xlUd34GPiMdi0VQsIptr86GBexQionCuy1826IS43-v9u8VAwXUHUg9NgG9oizx283wPlVqCaQLZqMfRdYTI1TXrlztQU0gYltNtJbY-Yw-IrR6e-_q7bI5l3aEkJGP/s400/SimpleTable-Add-File.jpg" height="400" width="391" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah menambahkan file gambar, Anda akan melihat hasilnya di Navigator Project seperti layar seperti di bawah:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEEpA2AOSLBRosIjk_B7WHWTrxQMgsMgaTIoDBNeTg30YNb1kXUywdRxEot4R6i_hsnhm52djZAcEzqCwNVw_qOqM2qs95sTJjCcj7gT0slX7dRN2E10SgKB62FWK4WKDRF7_WWJO6mCqS/s1600/SimpleTable-Project-Navigator-Image.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEEpA2AOSLBRosIjk_B7WHWTrxQMgsMgaTIoDBNeTg30YNb1kXUywdRxEot4R6i_hsnhm52djZAcEzqCwNVw_qOqM2qs95sTJjCcj7gT0slX7dRN2E10SgKB62FWK4WKDRF7_WWJO6mCqS/s400/SimpleTable-Project-Navigator-Image.jpg" height="400" width="225" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Langkah terakhir, ubah baris kode dalam "cellForRowAtIndexPath" method untuk:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
cell.imageView.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]]; </div>
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><br /></td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><br /></td></tr>
</tbody></table>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Apa itu <b>[thumbnail objectAtIndex: indexPath.row]?</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Baris kode mengambil nama gambar untuk baris tertentu. Katakanlah, untuk baris pertama, indexPath.row properti kembali 0 dan kita ambil gambar pertama (yaitu egg_benedict.jpg) dari array thumbnail menggunakan "objectAtIndex" method.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah menyimpan semua perubahan, selanjutnya kita dapat menjalankan aplikasi Anda lagi. Ini sekarang harus menampilkan thumbnail yang berbeda untuk baris tabel:<span style="color: #333333; font-family: Lora, serif; line-height: 25px;"><br /></span>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3>
</h3>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Sesuaikan TableView Cell </h4>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div style="text-align: justify;">
Apakah aplikasi aplikasi anda terlihat lebih baik? Disini kita akan membuatnya lebih baik dengan menyesuaikan table Cell. Sejauh ini saya menggunakan style default tampilan table cell. Lokasi dan ukuran thumbnail yang akan kita sempurnakan. Bagaimana jika Anda ingin membuat thumbnail lebih besar dan menunjukkan informasi waktu yang diperlukan untuk menyiapkan resep makanan. </div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Merancang Sel</h4>
<div style="text-align: justify;">
Dalam kasus ini, Anda harus membuat dan merancang sel meja Anda sendiri. Kembali ke Xcode. Dalam Proyek Navigator, klik kanan "SimpleTable" folder dan pilih "New file ...".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti kita akan merancang sel tabel kita sendiri, kita harus membuat file Builder Antarmuka baru untuk sel. Untuk kasus ini, kita hanya perlu untuk memulai dengan user interface kemudian pilih "Empty" dan Klik "Next" untuk melanjutkan.
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicZgnmN0OgLuF0pgMpLsV8a1gCM8t5otmwx3z8QK0Hu1QB75sdsAI4lzgsg5EhkGbWS4-EIBy_0eNd4BWOoL-kW2veENhDkAzpWhQS8UcsHSV66qxwAP2nkMbZmluCsIpzvffdmzk-EHKv/s1600/New-Empty-Interface-Builder-File.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicZgnmN0OgLuF0pgMpLsV8a1gCM8t5otmwx3z8QK0Hu1QB75sdsAI4lzgsg5EhkGbWS4-EIBy_0eNd4BWOoL-kW2veENhDkAzpWhQS8UcsHSV66qxwAP2nkMbZmluCsIpzvffdmzk-EHKv/s400/New-Empty-Interface-Builder-File.jpg" height="267" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Ketika meminta untuk memilih device family pilih "iPhone" dan klik "Next" untuk melanjutkan. Simpan file sebagai "SimpleTableCell".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah file dibuat, Anda harus menemukannya dalam Project Navigator. Pilih "SimpleTableCell.xib" untuk beralih ke Interface Builder. Kita akan merancang tampilan dari sel tabel customer.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Di Library Object, pilih "Table View Cell" dan drag ke area desain Interface Builder.
</div>
<div class="note" style="background-position: 20px 13px; border-bottom-color: rgb(239, 227, 174); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(239, 227, 174); border-top-style: solid; border-top-width: 1px; margin-bottom: 20px; padding: 10px;">
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQEVe_ziJKhtErVDh9qzpFU2NujV-hga2Kuab_7leKGkIxTwonIxdKlVTp_quqLlN7eSIh2yZZMETFMrawGxMsfGgk_upw2jRpe5ZnTBi0GeaCaMbG0vdF7Vj-IqNC0hlGuqUmLe6EPwbX/s1600/SimpleTable-Drag-TableViewCell.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQEVe_ziJKhtErVDh9qzpFU2NujV-hga2Kuab_7leKGkIxTwonIxdKlVTp_quqLlN7eSIh2yZZMETFMrawGxMsfGgk_upw2jRpe5ZnTBi0GeaCaMbG0vdF7Vj-IqNC0hlGuqUmLe6EPwbX/s400/SimpleTable-Drag-TableViewCell.jpg" height="140" width="400" /></a></div>
<div class="note" style="background-position: 20px 13px; border-bottom-color: rgb(239, 227, 174); border-bottom-style: solid; border-bottom-width: 1px; border-top-color: rgb(239, 227, 174); border-top-style: solid; border-top-width: 1px; margin-bottom: 20px; padding: 10px;">
<div style="text-align: justify;">
<br /></div>
</div>
<div style="text-align: justify;">
Dalam rangka mengakomodasi thumbnail yang lebih besar, kita harus mengubah ketinggian sel. Hanya menahan pada bagian bawah / atas sisi sel dan skala ketinggian sampai dengan 78.<span style="color: #333333; font-family: Lora, serif;"><span style="line-height: 25px;"><br /></span></span>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbuNNjLeJJJ5EaE54BplBAHfogPMRd7-arrHvTJv9YckS0V3oCQTGWAx-rb53caUSEqmgC9BmYSJ_AfFvpG80X0WILLuhIP9xp3kA3Ayvue3XQ_-1Y7iRam-IvrgA0ndJrSrqaiI5pxk7W/s1600/Table-View-Cell-Change-Height.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbuNNjLeJJJ5EaE54BplBAHfogPMRd7-arrHvTJv9YckS0V3oCQTGWAx-rb53caUSEqmgC9BmYSJ_AfFvpG80X0WILLuhIP9xp3kA3Ayvue3XQ_-1Y7iRam-IvrgA0ndJrSrqaiI5pxk7W/s400/Table-View-Cell-Change-Height.jpg" height="173" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Atau, Anda juga dapat menggunakan "Size Inspector" untuk mengubah ketinggian.</div>
<div style="text-align: justify;">
<span style="color: #333333; font-family: Lora, serif;"><span style="line-height: 25px;"><br /></span></span>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIrorbSVKFbRSNM05xNMb98zVcIXR2GXfYyPoGyLn364SSOnHu16x2YAqJtBgytF9XadibE3HPO8NBv5hpwAbhuldghc4rIJuww_VR_h9Nx-5p2w26_IkWax-sAg13Pvqk-lJbOs8BcaB-/s1600/Table-View-Cell-Size-Inspector.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIrorbSVKFbRSNM05xNMb98zVcIXR2GXfYyPoGyLn364SSOnHu16x2YAqJtBgytF9XadibE3HPO8NBv5hpwAbhuldghc4rIJuww_VR_h9Nx-5p2w26_IkWax-sAg13Pvqk-lJbOs8BcaB-/s400/Table-View-Cell-Size-Inspector.jpg" height="400" width="330" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Size Inspector untuk Table View Cell</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Selanjutnya, pilih "Attributes Inspector" di bagian atas area Utilitas dan mengatur "Identifier" dari sel costom untuk "SimpleTableCell". Identifier ini akan digunakan kemudian dalam kode Anda.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWL9JAYjAnt9gmsLXXsytPu_JKYG6Aw5NKL1Ju2YgEqW0lZHyHepHreT9v9djPu8R09S3HTq0ws_-5YtjdSQkpujcATucExcIWUGZDrqG2oEyneDZeu-Ufkdc3Pe1HH8cU20SAMbpQbC7S/s1600/SimpleTable-Cell-Identifier.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWL9JAYjAnt9gmsLXXsytPu_JKYG6Aw5NKL1Ju2YgEqW0lZHyHepHreT9v9djPu8R09S3HTq0ws_-5YtjdSQkpujcATucExcIWUGZDrqG2oEyneDZeu-Ufkdc3Pe1HH8cU20SAMbpQbC7S/s400/SimpleTable-Cell-Identifier.jpg" height="329" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah mengkonfigurasi tampilan tabel sel, kami akan menempatkan unsur-unsur lain di dalamnya. Pilih "ImageView" dan drag ke TableView Cell.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxbxmWVNIY0mxWzOXW6vaXuJ6siCDF_n-yuAkGs1D-KX9_HvaZVbQ3LLd0sYXwaRXIw_RlmzuVWta2laoFUTQYPd4E3kwDKfumMKHC5M9VihHC12jBNzoOSSwEKxlRAF5x68A9yLEIqfa6/s1600/SimpleTableCell-Drag-ImageView.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxbxmWVNIY0mxWzOXW6vaXuJ6siCDF_n-yuAkGs1D-KX9_HvaZVbQ3LLd0sYXwaRXIw_RlmzuVWta2laoFUTQYPd4E3kwDKfumMKHC5M9VihHC12jBNzoOSSwEKxlRAF5x68A9yLEIqfa6/s400/SimpleTableCell-Drag-ImageView.jpg" height="210" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
ImageView disini digunakan untuk menampilkan Thumbnail. Anda bisa mengubah ukurannya untuk membuatnya sesuai cell.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Selanjutnya kita akan tambahkan tiga label: Nama, Prep Time, dan Time. "Name" Label digunakan untuk menampilkan nama label resep. Prep Time adalah label statis yang hanya menampilkan "Prep Time". Yang terakhir adalah label "time" adalah label dinamis yang digunakan untuk menunjukkan waktu persiapan sebenarnya untuk resep tertentu.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Untuk menambahkan label, pilih "Label" di Object Library dan tarik ke cell. Anda dapat mengklik dua kali label untuk mengganti namanya.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Wb28ahNEhyphenhyphenyGf2-HXh9TM-vpJnD9QRcgHd724MZpn0oeM_mGwDvvLR3IFI5yulXzE85pLhyphenhyphenhzY8lhRIzgKDV4yQF3yXVofDi-ONZ1nt5c3nFtMcUJZdj_FDAoQscQf-oAHYGdQ4bWLB-/s1600/Table-View-Cell-Change-Label-Name.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9Wb28ahNEhyphenhyphenyGf2-HXh9TM-vpJnD9QRcgHd724MZpn0oeM_mGwDvvLR3IFI5yulXzE85pLhyphenhyphenhzY8lhRIzgKDV4yQF3yXVofDi-ONZ1nt5c3nFtMcUJZdj_FDAoQscQf-oAHYGdQ4bWLB-/s400/Table-View-Cell-Change-Label-Name.jpg" height="113" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Anda mungkin melihat ukuran font dan style yang berbeda dari yang ditunjukkan di atas. Untuk mengubah font style, cukup pilih Label dan pilih "Attributes Inspector". Dari sini, Anda dapat mengubah setting "Font" dan ukuran font minimum. Anda juga dapat mengubah warna teks dan keselarasan melalui inspector. </div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY7PSOt7kjekQdJ8LmK8qZX3bHsHNxis6ie443VRO472F5OLqMkBeNCy4ev2oNB_IczZITdAmS0BFDtTT3SU_VlMUPW9OKuow5xCvTHcdr9k6cepRk08iRo7FBa2xUGj8RDjOOfScaQbN3/s1600/Custom-Table-Cell-Attributes.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY7PSOt7kjekQdJ8LmK8qZX3bHsHNxis6ie443VRO472F5OLqMkBeNCy4ev2oNB_IczZITdAmS0BFDtTT3SU_VlMUPW9OKuow5xCvTHcdr9k6cepRk08iRo7FBa2xUGj8RDjOOfScaQbN3/s400/Custom-Table-Cell-Attributes.jpg" height="350" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Desain akhir dari aplikasi yang dibuat adalah seperti ini:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMZQJ4pR-5kNWHWF9e-3lxOPFBjGSPrvxs2O2F6ho2CvrA7JIKzpXiYq9QIN-vFSlD_hfBJ3s2wRpnkKKwAdzhWd0afR7CT25tfnWcS08dfRZqtY8-VKj0jPQGP77HXVtu1JNbPt-oIYK5/s1600/Final-Design-Table-View-Cell.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMZQJ4pR-5kNWHWF9e-3lxOPFBjGSPrvxs2O2F6ho2CvrA7JIKzpXiYq9QIN-vFSlD_hfBJ3s2wRpnkKKwAdzhWd0afR7CT25tfnWcS08dfRZqtY8-VKj0jPQGP77HXVtu1JNbPt-oIYK5/s400/Final-Design-Table-View-Cell.jpg" height="156" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Membuat sebuah Class untuk Table Custom</h4>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div style="text-align: justify;">
Sejauh ini, kita telah mendesain table cell. Tapi bagaimana kita bisa mengubah nilai-nilai label dari sel custom? Kita akan membuat kelas baru untuk tampilan tabel sel custom. Kelas ini merupakan model data yang mendasari dari sel custom.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sama seperti sebelumnya, klik kanan "SimpleTable" folder dalam Project Navigator dan pilih "New File...".</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf92u-HZ1S1zZ8eIWBBjDlMGLRO0xV1v5gQiOIMy71OiSEW0ZXupzEzQO_-pIyZeiAt5eI-aqza6ssoPFzNMo2j2DtPRPtmcG7l0v_mNRp8Fev6Vj8V0xH6zCHT2HcEUahxAYkAdII7_Zx/s1600/New-File-Template-Dialog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf92u-HZ1S1zZ8eIWBBjDlMGLRO0xV1v5gQiOIMy71OiSEW0ZXupzEzQO_-pIyZeiAt5eI-aqza6ssoPFzNMo2j2DtPRPtmcG7l0v_mNRp8Fev6Vj8V0xH6zCHT2HcEUahxAYkAdII7_Zx/s400/New-File-Template-Dialog.jpg" height="267" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah memilih opsi, Xcode meminta Anda untuk memilih template. Seperti kita akan membuat kelas baru untuk tampilan tabel sel custom, pilih "Objective-C class" di bawah "cocoa Touch" dan klik "Next".</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrp6eyXtxsUiIjJMaFyBxrt0Sg_3yJRKBFyJRIUODo6INnTn8jLoUjft83OSi-lE9ont7SZltmWFZET9xiIwRZNvq-WiYyG_QBByZh64zK_Cvmzl7mEmWMUEGdzUN7ziKJmlqpo3VwqxqH/s1600/SimpleTable-New-File.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrp6eyXtxsUiIjJMaFyBxrt0Sg_3yJRKBFyJRIUODo6INnTn8jLoUjft83OSi-lE9ont7SZltmWFZET9xiIwRZNvq-WiYyG_QBByZh64zK_Cvmzl7mEmWMUEGdzUN7ziKJmlqpo3VwqxqH/s400/SimpleTable-New-File.jpg" height="188" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Isi "<b>SimpleTableCell</b>" untuk nama kelas dan pilih "<b>UITableViewCell</b>" untuk pilihan "<b>Subclass of</b>" .</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ9jC0in-TRlZ4InW-ugmYjaWVzyOXKjBatL-uMeGAFUu2L6G_7P6zOUCYjpDeB3Z7RfFTyKuHXvh8AusBLzmN9gfjR_kAaAx5VrH8Yu0CERAXERpBHHnyb7YLJ4QVHhn1MyWMZpeLEDcG/s1600/SimpleTable-Subclass-UITableViewCell.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZ9jC0in-TRlZ4InW-ugmYjaWVzyOXKjBatL-uMeGAFUu2L6G_7P6zOUCYjpDeB3Z7RfFTyKuHXvh8AusBLzmN9gfjR_kAaAx5VrH8Yu0CERAXERpBHHnyb7YLJ4QVHhn1MyWMZpeLEDcG/s400/SimpleTable-Subclass-UITableViewCell.png" height="267" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Klik "Next", menyimpan file dalam folder proyek SimpleTable dan klik "Create" untuk melanjutkan. Xcode harus membuat dua file bernama "</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
SimpleTableCell.h" dan "SimpleTableCell.m" di Project Navigator .</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti disebutkan sebelumnya, class SimpleTableCell berfungsi sebagai model data dari cell custom. Dalam cell, kita memiliki tiga nilai-nilai yang berubah: tampilan gambar kecil, label nama dan label waktu. Di class ini, kita akan menambah tiga properti untuk mewakili nilai-nilai dinamis.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Buka "SimpleTableCell.h" dan menambahkan properti berikut sebelum baris "@end":</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: nowrap; width: '100%';">
<table cellpadding="0" cellspacing="0" style="border: 1px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #a61390; line-height: 1.4em;">@property</span> <span style="color: #002200; line-height: 1.4em;">(</span>nonatomic, weak<span style="color: #002200; line-height: 1.4em;">)</span> IBOutlet UILabel <span style="color: #002200; line-height: 1.4em;">*</span>nameLabel;<br />
<span style="color: #a61390; line-height: 1.4em;">@property</span> <span style="color: #002200; line-height: 1.4em;">(</span>nonatomic, weak<span style="color: #002200; line-height: 1.4em;">)</span> IBOutlet UILabel <span style="color: #002200; line-height: 1.4em;">*</span>prepTimeLabel;<br />
<span style="color: #a61390; line-height: 1.4em;">@property</span> <span style="color: #002200; line-height: 1.4em;">(</span>nonatomic, weak<span style="color: #002200; line-height: 1.4em;">)</span> IBOutlet UIImageView <span style="color: #002200; line-height: 1.4em;">*</span>thumbnailImageView;</div>
</td></tr>
</tbody></table>
</div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
</h4>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
@Property dan Outlet</h4>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Baris kode diatas mendefinisikan 3 instance variabel yang kemudian akan dikaitkan dengan table cell view di dalam instance builder. Kata kunci @property digunakan untuk menyatakan sebuah property dalam class berupa:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
@property (attribute) type name;</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Mengacu pada baris kode di atas, weak dan nonatomic adalah atribut dari property. UILabel dan UIImageView adalah type, sedangkan "nameLabel", "prepTimeLabel" dan "thumbnailImageView" adalah name.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Jadi apa IBOutlet? Anda dapat menganggap IBOutlet sebagai indikator. Untuk mengaitkan kasus variabel dengan unsur-unsur di Cell Table View (yaitu SimpleTableCell.xib), kita menggunakan kata kunci "IBOutlet" untuk memberitahukan Interface Builder bahwa mereka diizinkan untuk melakukan koneksi. Kemudian, kita akan melihat bagaimana untuk membuat koneksi antara outlet dan objects di Interface Builder.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sekarang, buka "SimpleTableCell.m" dan tambahkan kode berikut tepat di bawah "@implementation SimpleTableCell":</div>
<div style="text-align: justify;">
<br /></div>
<div 100="" class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;">
<tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;">
<td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #a61390; line-height: 1.4em;">@synthesize</span> nameLabel <span style="color: #002200; line-height: 1.4em;">=</span> _nameLabel;<br />
<span style="color: #a61390; line-height: 1.4em;">@synthesize</span> prepTimeLabel <span style="color: #002200; line-height: 1.4em;">=</span> _prepTimeLabel;<br />
<span style="color: #a61390; line-height: 1.4em;">@synthesize</span> thumbnailImageView <span style="color: #002200; line-height: 1.4em;">=</span> _thumbnailImageView;</div>
</td></tr>
</tbody>
</table>
</div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
@synthesize Directive</h4>
<div style="text-align: justify;">
Kata kunci "@synthesize" memberitahu compiler secara otomatis menghasilkan kode untuk mengakses properti yang telah kita menyatakan sebelumnya. Jika kita lupa untuk menyertakan Directive ini, Xcode akan menampilkan kode peringatan seperti di bawah ini:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIGup6nDx1qST_9mXJIaH4iRdCnMhTg1txTbI0vb8Yz6yvqy99Owzda0uF2cKp0a-uychlJnA60Yp3zg-VwUMISUVD3cklbDwE-aFUuahgcx_RB9TQWwp5iU0kujNUZ4lvxhJ0_dWK5_eO/s1600/Xcode-Missing-Synthesize.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIGup6nDx1qST_9mXJIaH4iRdCnMhTg1txTbI0vb8Yz6yvqy99Owzda0uF2cKp0a-uychlJnA60Yp3zg-VwUMISUVD3cklbDwE-aFUuahgcx_RB9TQWwp5iU0kujNUZ4lvxhJ0_dWK5_eO/s400/Xcode-Missing-Synthesize.jpg" height="46" width="400" /></a></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
</h4>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Membuat Koneksi</h4>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Simpan perubahan, kemudian pilih "SimpleTableCell.xib" untuk kembali ke Interface Builder. Sekarang kita akan membuat koneksi antara properties dari class dengan Label / ImageView yang dibuat dalam Interface.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Pertama, pilih sel untuk mengubah class pada "SimpleTableCell" dalam "Identity Inspector". Hubungkan View Cell dengan Class Custom yang telah kita buat sebelumnya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sekarang, kita akan membangun koneksi dengan properties. Klik kanan pada "SimpleTableCell" di bawah "Objects" untuk menampilkan "Outlet" Inspector. Klik dan tahan (hold) lingkaran di samping "nameLabel", dan tarik (drag) ke "Label - Nama" object. Xcode otomatis membentuk koneksi.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_guxdRNGsrvP83e4Vq1Hoh_6kVJ8p5RYmFvpmdOCVwxUBJcckdv39T6Hh7Jqx7ssdIfltT4901E6KEAHZTzKrDT03PKnAlXvb8YUSDkYPUlK-Gbn-ys-KbHxEupG4nu8M6QCx0opb206G/s1600/Simple-Table-Cell-Label-Connection.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_guxdRNGsrvP83e4Vq1Hoh_6kVJ8p5RYmFvpmdOCVwxUBJcckdv39T6Hh7Jqx7ssdIfltT4901E6KEAHZTzKrDT03PKnAlXvb8YUSDkYPUlK-Gbn-ys-KbHxEupG4nu8M6QCx0opb206G/s400/Simple-Table-Cell-Label-Connection.jpg" height="222" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Ulangi prosedur di atas untuk "<b>prepTimeLabel</b>" dan "<b>thumbnailImageView</b>":</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Connect "<b>prepTimeLabel</b>" dengan object "<b>Label - Time</b>" </div>
<div class="separator" style="clear: both; text-align: justify;">
Connect "thumbnailImageView" dengan object "I<b>mageView</b>" </div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Setelah Anda membuat semua koneksi, seharusnya terlihat seperti ini: </div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW2WyRyE5w5MJ_-HdKUfWM9a2jfLifB7w6ylpVgIG4BKhfXY-G02pRKvxpW5f8LIjXMnIeASAmVLznV68QOVNF5RYqtNikZ4_E-mIK5FAjhfL1lMiWL5o65jSQXpUeQOVQpBE4g-YxWPZG/s1600/Simple-Table-Cell-Connections.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiW2WyRyE5w5MJ_-HdKUfWM9a2jfLifB7w6ylpVgIG4BKhfXY-G02pRKvxpW5f8LIjXMnIeASAmVLznV68QOVNF5RYqtNikZ4_E-mIK5FAjhfL1lMiWL5o65jSQXpUeQOVQpBE4g-YxWPZG/s400/Simple-Table-Cell-Connections.jpg" height="222" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px; text-align: justify;">
Memperbaharui SimpleTableViewController</h4>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Kami telah menyelesaikan desain dan coding untuk custome table cell. Akhir dari bagian perubahan - untuk memanfaatkan custome cell di SimpleTableViewController tersebut.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Mari kita kembali membuka koding "SimpleTableView.m" yang saat ini digunakan untuk membuat baris tabel:</div>
<div style="text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13<br />
14<br />
15</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSIndexPath</span></a> <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>indexPath<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #a61390; line-height: 1.4em;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSString</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>simpleTableIdentifier <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"SimpleTableItem"</span>;<br />
<br style="line-height: 1.4em;" />
UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span>cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200; line-height: 1.4em;">:</span>simpleTableIdentifier<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br style="line-height: 1.4em;" />
<span style="color: #a61390; line-height: 1.4em;">if</span> <span style="color: #002200; line-height: 1.4em;">(</span>cell <span style="color: #002200; line-height: 1.4em;">==</span> <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">)</span> <span style="color: #002200; line-height: 1.4em;">{</span><br />
cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><span style="color: #002200; line-height: 1.4em;">[</span>UITableViewCell alloc<span style="color: #002200; line-height: 1.4em;">]</span> initWithStyle<span style="color: #002200; line-height: 1.4em;">:</span>UITableViewCellStyleDefault reuseIdentifier<span style="color: #002200; line-height: 1.4em;">:</span>simpleTableIdentifier<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span><br />
<br style="line-height: 1.4em;" />
cell.textLabel.text <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableData objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
cell.imageView.image <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>UIImage imageNamed<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">[</span>thumbnails objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br style="line-height: 1.4em;" />
<span style="color: #a61390; line-height: 1.4em;">return</span> cell;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
<div>
<span style="color: #002200; line-height: 1.4em;"><br /></span></div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Kita gunakan default tampilan tabel sel (yaitu UITableViewCell) untuk menunjukkan item pada tabel. Untuk menggunakan Custome Table Cell, kita harus mengubah sebagian dari kode dalam "SimpleTableView.m" sebagai berikut:</div>
<div style="text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: wrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13<br />
14<br />
15<br />
16<br />
17</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSIndexPath</span></a> <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>indexPath<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #a61390; line-height: 1.4em;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSString</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>simpleTableIdentifier <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"SimpleTableCell"</span>;<br />
<br style="line-height: 1.4em;" />
SimpleTableCell <span style="color: #002200; line-height: 1.4em;">*</span>cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">(</span>SimpleTableCell <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span><span style="color: #002200; line-height: 1.4em;">[</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200; line-height: 1.4em;">:</span>simpleTableIdentifier<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #a61390; line-height: 1.4em;">if</span> <span style="color: #002200; line-height: 1.4em;">(</span>cell <span style="color: #002200; line-height: 1.4em;">==</span> <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">)</span><br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>nib <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSBundle</span></a> mainBundle<span style="color: #002200; line-height: 1.4em;">]</span> loadNibNamed<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"SimpleTableCell"</span> owner<span style="color: #002200; line-height: 1.4em;">:</span>self options<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>nib objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #2400d9; line-height: 1.4em;">0</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span><br />
<br />
cell.nameLabel.text <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableData objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
cell.thumbnailImageView.image <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>UIImage imageNamed<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">[</span>thumbnails objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
cell.prepTimeLabel.text <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>prepTime objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br />
<span style="color: #a61390; line-height: 1.4em;">return</span> cell;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
<div>
<span style="color: #002200; line-height: 1.4em;"><br /></span></div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Namun, setelah kita memperbarui kode, Xcode mendeteksi ada beberapa kesalahan seperti yang ditunjukkan dalam editor kode sumber.</div>
<div style="text-align: justify;">
<br /></div>
<div class="wp-caption aligncenter" id="attachment_341" style="background-color: whitesmoke; border: 1px solid rgb(221, 221, 221); color: #333333; font-family: Lora, serif; margin: 0px auto 10px; padding: 5px; text-align: center; width: 100%;">
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMgCNAoN_NKar1-iFBd8tQDVvkUeA3LzApdH8zpkuYEKNLBcQIpWCeqn0pqwHTDWn7OpyAUyAQaWxsr7TrZev9VKEvw9IR4c8nAEYf-7fN6exf7KnbZjneS9HgfsmYNcbL8PGtmCB-pVyu/s1600/Xcode-Source-Editor-Error.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMgCNAoN_NKar1-iFBd8tQDVvkUeA3LzApdH8zpkuYEKNLBcQIpWCeqn0pqwHTDWn7OpyAUyAQaWxsr7TrZev9VKEvw9IR4c8nAEYf-7fN6exf7KnbZjneS9HgfsmYNcbL8PGtmCB-pVyu/s400/Xcode-Source-Editor-Error.jpg" height="98" width="400" /></a></div>
<div class="wp-caption-text" style="margin-bottom: 5px; margin-top: 5px; padding: 0px;">
<div style="text-align: center;">
<div style="text-align: justify;">
<span style="font-size: 14px; line-height: 1.5625;">Kesalahan pada Source Code yang dinyatakan oleh Xcode</span></div>
</div>
</div>
<div style="font-size: 16px; line-height: 25px;">
<div style="text-align: justify;">
<br /></div>
</div>
</div>
<div style="text-align: justify;">
Apa masalahnya? Kode yang baru saja kita ubah memberitahu "<b>SimpleTableViewController</b>" untuk menggunakan class "<b>SimpleTableCell</b>" sebagai cell table. Namun, "<b>SimpleTableViewController</b>" tidak memiliki gambaran tentang hal itu. Itu sebabnya Xcode menampilkan kesalahan.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sebagaimana dijelaskan dalam tutorial pertama, file header menyatakan interface class. Untuk "<b>SimpleTableViewController</b>" agar mengenal "<b>SimpleTableCell</b>", kita harus mengimpor "<b>SimpleTableCell.h</b>" dalam "<b>SimpleTableViewController.m</b>".</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4gwO3BkTWpl3muxKI9WdTifs4uMBo7fUCTvwHe5e3jDUs_ieQrNZ0W2C2_E7OYwukQ78xaKalxBea-NqkrQrtx9Z70kPUZN7TvJ2nIwEoVSyo-wq7im-4Q73hZdeMxo6Coj52GM_NZ487/s1600/SimpleTableView-Controller-Import.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4gwO3BkTWpl3muxKI9WdTifs4uMBo7fUCTvwHe5e3jDUs_ieQrNZ0W2C2_E7OYwukQ78xaKalxBea-NqkrQrtx9Z70kPUZN7TvJ2nIwEoVSyo-wq7im-4Q73hZdeMxo6Coj52GM_NZ487/s320/SimpleTableView-Controller-Import.jpg" height="41" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<span style="background-color: whitesmoke; color: #333333; font-family: Lora, serif; font-size: 14px; line-height: 21px;">Impor SimpleTableCell.h</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Dengan mengimpor "<b>SimpleTableCell.h</b>" ke dalam "<b>SimpleTableViewController</b>" kita bisa memanfaatkannya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Terakhir, kita sesuaikan table cell diubah menjadi <b>78</b>, tambahkan kode di bawah ini di atas "<b>@end</b>".</div>
<div style="text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: nowrap; width: 100%;">
<table cellpadding="0" cellspacing="0" style="border: 0px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: wrap;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>CGFloat<span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView heightForRowAtIndexPath<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSIndexPath</span></a> <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>indexPath<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #a61390; line-height: 1.4em;">return</span> <span style="color: #2400d9; line-height: 1.4em;">78</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
<div>
<span style="color: #002200; line-height: 1.4em;"><br /></span></div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Sekarang, klik "Run" tombol aplikasi <b>SimpleTable</b> untuk melihat hasilnya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-51108536216837082392013-05-29T14:46:00.001+07:002015-05-03T14:11:48.314+07:00Penyimpanan Data pada iOS<br />
Menyimpan data di iOS menggunakan 5 metode diantaranya adalah:<br />
<ol>
<li>Plist (Lokal) & AppSetting</li>
<li>SQLite (Lokal)</li>
<li>Core Data (Lokal)</li>
<li>JSON & XML (Remote)</li>
<li>iCloud (Remote)</li>
</ol>
<div>
<br /></div>
<div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
Pengenalan PList (Property List)</h4>
</div>
<br />
<ul>
<li>Sebuah file text sederhana untuk menyimpan data dalam format XML </li>
<li>Pengaturan Aplikasi di iOS adalah dengan menggunakan PList juga. </li>
<li>Data yang disimpan berupa tipe data standar seperti strings, angka, array dan dictionary. </li>
<li>Property List mudah dibuat, dibaca dan ditulis melalui kode, jadi property list adalah jalan masuk yang mudah untuk memasukkan sedikit data ke dalam app kita.</li>
</ul>
<div>
<br />
<a name='more'></a><br /></div>
<div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
Mengambil Data pada PList</h4>
<div class="p1">
<span class="s1"><b><br /></b></span></div>
<div class="p1">
<span class="s1">NSString *</span><span class="s2">pathnamePlist</span><span class="s1"> = [[NSBundle mainBundle] pathForResource:@”</span><span class="s2">yourplistname</span><span class="s1">” ofType:@”</span><span class="s3">plist</span><span class="s1">”];</span></div>
<div class="p1">
<span class="s1">NSArray *</span><span class="s2">localarray</span><span class="s1">=[[NSArray alloc] initWithContentsOfFile:</span><span class="s2">pathnamefilePlist</span><span class="s1">];</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<span class="s1">_GlobalArray=</span><span class="s2">localarray</span><span class="s1">;</span><br />
<span class="s1"><br /></span>
<span class="s1"></span><br />
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
Mengubah PList menjadi Tabel</h4>
<div class="p1">
<span class="s1">B</span>agaimana mengkonversi data pada PList menjadi TableView?<br />
<br />
Langkahnya:</div>
<ul>
<li>Mengkonversi NSDictionary ke NSArray, menunjuk ke file data Plist. </li>
<li>Menggunakan cell.textLabel.text </li>
<li>Menggunakan class yang sesuai ketika kita memilih subclass !!!</li>
</ul>
<div>
</div>
<br />
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
Mempelajari App Settings Menggunakan NSUserDefaults</h4>
<div>
<br /></div>
<div>
<b>App Settings</b></div>
<div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi540QqHg9oVmHqOXNv4Q1vhCp3WJtafeE-AFCeSKWjW2i4-HX7u1-o3JxreQIdT2k-bf-PEfq1ZhHq5fIyQNLxnnCJa1KAd8_-X4PyppJZbW09CIqKJ8z-lmZVoF0Op1KxxMQX-ZLkpr_z/s1600/Screen+Shot+2013-06-04+at+15.03.29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi540QqHg9oVmHqOXNv4Q1vhCp3WJtafeE-AFCeSKWjW2i4-HX7u1-o3JxreQIdT2k-bf-PEfq1ZhHq5fIyQNLxnnCJa1KAd8_-X4PyppJZbW09CIqKJ8z-lmZVoF0Op1KxxMQX-ZLkpr_z/s200/Screen+Shot+2013-06-04+at+15.03.29.png" height="200" width="108" /></a></div>
<br /></div>
<ul>
<li>Menyimpan preferensi Aplikasi Anda </li>
<li>Menambahkan file “Settings” baru </li>
<li>Menggunakan NSUserDefaults untuk membaca key identifiers dari file pengaturan.</li>
</ul>
<div>
<h4 style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; font-weight: normal; line-height: 1.25; margin: 0px 0px 10px; padding: 0px;">
NSUserDefaults</h4>
</div>
Dengan NSUserDefaults class, anda dapat menyimpan pengaturan dan properti yang berkaitan dengan data aplikasi dan pengguna. <br />
Dengan NSUserDefaults, Anda dapat menyimpan objek dari jenis class: <br />
NSData <br />
NSNumbers <br />
NSString <br />
NSDate <br />
NSArray <br />
NSDictionary <br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjja82WmkHqq4MotbjA5JqPqA0LghUCJApO49td4urpzBQ1ZcwIxKn0KZJ2PdtX0VdwNwgESg5xUEvnVmOzucUtJlM1VgavTrewQ4pcLQTcYePB5_WFwUTcAJIk93j8KLl30mstaW6rAaKN/s1600/Screen+Shot+2013-06-04+at+15.05.29.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjja82WmkHqq4MotbjA5JqPqA0LghUCJApO49td4urpzBQ1ZcwIxKn0KZJ2PdtX0VdwNwgESg5xUEvnVmOzucUtJlM1VgavTrewQ4pcLQTcYePB5_WFwUTcAJIk93j8KLl30mstaW6rAaKN/s200/Screen+Shot+2013-06-04+at+15.05.29.png" height="166" width="200" /></a></div>
<br />
<br />
Catatan: Jika Anda ingin menyimpan jenis lain dari objek, seperti UIImage, Anda biasanya akan perlu untuk arsip atau membungkusnya dalam sebuah instance dari NSData, NSNumber, atau NSString. <br />
Biasanya menempatkan kode dalam metode ViewDidLoad atau metode aplikasi DidFinishLaunchingWithOptions. </div>
</div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Kode Penyimpanan Data pada NSUserDefaults</span></div>
<div class="p1">
<br /></div>
<div class="p1">
<div class="p1">
<span class="s1">NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];</span></div>
<div class="p1">
<span class="s1">[default setObject:</span><span class="s2">firstName</span><span class="s1"> forKey:@”</span><span class="s3">firstName</span><span class="s1">”];</span></div>
<div class="p1">
<span class="s1">[default setObject:</span><span class="s3">lastName</span><span class="s1"> forKey:@”</span><span class="s3">lastName</span><span class="s1">”];</span></div>
<div class="p1">
<span class="s1">[defaults setInteger:</span><span class="s3">age</span><span class="s1"> forKey:@”</span><span class="s3">age</span><span class="s1">”];</span></div>
<div class="p1">
<span class="s1">[defaults setObject:</span><span class="s3">imageData</span><span class="s1"> forKey:@”</span><span class="s3">image</span><span class="s1">”];</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">[defaults synchronize];</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Kode Mengambil Data pada NSUserDefaults</span></div>
<div class="p1">
<br /></div>
<div class="p1">
<span class="s1">NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];</span></div>
<div class="p1">
<span class="s1">NSString *</span><span class="s2">FirstName</span><span class="s1"> = [defaults objectForKey:@”</span><span class="s3">firstName</span><span class="s1">”];</span></div>
<div class="p1">
<span class="s1">NSString *</span><span class="s2">LastName</span><span class="s1"> = [defaults objectForKey:@”</span><span class="s3">lastName</span><span class="s1">”];</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">int age = [defaults objectForKey:@”age”];</span></div>
<div class="p1">
<span class="s1">NSString *ageString = [NSString stringWithFormat:@”%i,” age];</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">NSData *imageData = [defaults objectForKey:@”image”];</span></div>
<div class="p1">
<span class="s1">UIImage *contectImage = [UIImage imageWithData:imageData];</span></div>
<div class="p2">
<span class="s1"></span><br /></div>
<div class="p1">
<span class="s1">//update the UI element with the saved data</span></div>
<div class="p1">
<span class="s1">firstNameTextField.text = </span><span class="s2">FirstName</span><span class="s1">;</span></div>
<div class="p1">
<span class="s1">lastNameTextField.text = </span><span class="s2">LastName</span><span class="s1">;</span></div>
<div class="p1">
<span class="s1">ageTextField.text=ageString;</span></div>
<div class="p1">
<span class="s1">
</span></div>
<div class="p3">
<span class="s1">contectImageView.image = contactImage;</span><br />
<span class="s1"><br /></span>
<span class="s1"></span><br />
<div class="p1" style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
</div>
<br />
<div class="p1">
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">JSON</span></div>
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; margin: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
</div>
<br />
JSON (JavaScript Object Notation) adalah format data interchange ringan. Ucapkan "Ja'son" <br />
Hal ini didasarkan pada subset dari JavaScript Programming Language, Standar ECMA-262 Edisi 3. JSON adalah format teks yang benar-benar bahasa independen tetapi menggunakan konvensi yang akrab bagi programmer dari keluarga bahasa C, termasuk C, C + +, C #, Java, JavaScript, Perl, Python, dan banyak lainnya. <br />
Itu adalah mudah bagi manusia untuk membaca dan menulis. Mudah untuk machines untuk parse dan generate. <br />
Properti ini membuat JSON menjadi bahasa pertukaran data yang ideal.</div>
<br />
<br />
Tersedia beberapa kerangka JSON untuk iOS: <br />
Json-framework/SBJson <br />
MTJSON <br />
JSONKit <br />
yajl-objc <br />
TouchJSON <br />
<br />
Contoh ketika menggunakan JSON parser di iOS5.1</div>
<div class="p3">
<br /></div>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Langkah-Demi-Langkah JSON</span><br />
<br />
<ol>
<li>Download file JSON menggunakan NSURLRequest </li>
<li>Kemudian Parse </li>
<li>Selanjutnya tampilkan pada App yang telah kita buat.</li>
</ol>
<div>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">SQLite (Database Lokal untuk iOS)</span><br />
<br /></div>
<div>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Pengenalan SQLite</span></div>
<br />
<ul>
<li>Database Lokal </li>
<li>SQL dalam satu file </li>
<li>Cepat, memori rendah, dapat diandalkan, tidak cocok untuk penggunaan data dengan Blobs besar seperti untuk video dan gambar. </li>
<li>Tidak untuk server, jadi tidak baik untuk concurrency. </li>
<li>Menggunakan perintal normal SQL </li>
<li>Select, Update, Insert, Delete, Join</li>
</ul>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Tools SQLite</span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;"><br /></span></span>Beberapa tools bersifat free <br />
Menggunakan Terminal (sulit) & SQLite Database Browser (mudah dan Free)<br />
Tools lain yang bagus adalah Firefox SQLite Extension <br />
Dapat memasukan Blob sebagai gambar.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfrxMCT2qClPFl_xerdM7p3HMEhiO7RbE3hhYz8Au_xM3nxxqskCxxDWZY4vHwKqAuXfHsURikp6qiD7PDwZGD_PPBxK9KDXlvfNqIxRml5PvTLBSDo19ALv7jgP2TL0JeNBfwBJpERdp1/s1600/Screen+Shot+2013-06-04+at+15.08.41.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfrxMCT2qClPFl_xerdM7p3HMEhiO7RbE3hhYz8Au_xM3nxxqskCxxDWZY4vHwKqAuXfHsURikp6qiD7PDwZGD_PPBxK9KDXlvfNqIxRml5PvTLBSDo19ALv7jgP2TL0JeNBfwBJpERdp1/s400/Screen+Shot+2013-06-04+at+15.08.41.png" height="152" width="400" /></a></div>
<br /></div>
<div class="p1">
<br /></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: 24px; line-height: 30px;">Langkah-Demi-Langkah SQLite</span><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWBm7T3t_fvo1j6i2iD8VxTVOxk-1j2iUQ47cna3yoIwMofzotrvh2pc42HMX9AUKQynPkcBr_xRhp-WNeZK4Qi8MlcaVyk54M9L2qdf8nuCH8Q0KmDuEFR3JdcWqfB6UhCxa6ixo1ukbW/s1600/Screen+Shot+2013-06-04+at+15.07.06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWBm7T3t_fvo1j6i2iD8VxTVOxk-1j2iUQ47cna3yoIwMofzotrvh2pc42HMX9AUKQynPkcBr_xRhp-WNeZK4Qi8MlcaVyk54M9L2qdf8nuCH8Q0KmDuEFR3JdcWqfB6UhCxa6ixo1ukbW/s320/Screen+Shot+2013-06-04+at+15.07.06.png" height="261" width="320" /></a></div>
<ol>
<li>Tambahkan SQLite Lib Framework </li>
<li>Buat SQLite Database (table & Fields) </li>
<li>Membaca data SQLite database </li>
<li>Tentukan Obyek menggunakan NSObject </li>
<li>Menempatkan setiap data ke array obyek Anda melalui proses loop. </li>
<li>Buat metode untuk add, display, update dan delete.</li>
</ol>
<div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;">Core Data (Kerangka Database iOS)</span></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;"><br /></span></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;">Gambaran Umum iOS</span></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUFNvwKXVYg7u2571Nkrqdf_nEvMSzsz6TN7axnAGcL3IHI2DozgH4bdC7FoMRb1M-JDOA0RZX-ySPX_hRS5hj6RlifDDRiaRJU-T0RZQKmYjbrefKS9I9pZHugchlqawJ_sc88ZvXGIyl/s1600/Screen+Shot+2013-06-04+at+14.57.58.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUFNvwKXVYg7u2571Nkrqdf_nEvMSzsz6TN7axnAGcL3IHI2DozgH4bdC7FoMRb1M-JDOA0RZX-ySPX_hRS5hj6RlifDDRiaRJU-T0RZQKmYjbrefKS9I9pZHugchlqawJ_sc88ZvXGIyl/s320/Screen+Shot+2013-06-04+at+14.57.58.png" height="187" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="p1">
<span class="s1">Catatan: Anda dapat membaca rinciannya dalam bahan bacaan core data</span></div>
<div class="p1">
<span class="s1"><br /></span></div>
<div class="p1">
<span class="s1"></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;">Pengenalan Core Data</span></span></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;"><br /></span></span></div>
Penyimpanan data menggunakan pemrograman berorientasi obyek. <br />
Menyimpan objek tetap <br />
Menggunakan SQLite DB <br />
XML tidak didukung di iOS saat ini</div>
<div>
<br /></div>
<div class="p1">
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;">Core Data vs SQLite</span></span></div>
<br />
Core data menyediakan fitur tambahan seperti: <br />
Undo iCloud file-sync secara gratis (baru pada iOS 5) <br />
Kinerja yang lebih baik untuk core data untuk sejumlah besar data <br />
<div>
<ol></ol>
</div>
<div class="p1">
<ul class="ul1"><ul>
</ul>
</ul>
</div>
<div>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large; line-height: 30px;">Langkah-Demi-Langkah Core Data</span></div>
<ol>
<li>Tambahkan Kerangka Core Data </li>
<li>Memerlukan beberapa metode untuk Core data </li>
<li>Dimulai dengan menggunakan template Xcode lebih baik </li>
<li>Hanya perlu menambahkan metode untuk reading, querying, updating atau deleting.</li>
</ol>
<div>
<span style="color: #333333; font-family: Oswald, arial, serif; font-size: large;"><span style="line-height: 30px;">Langkah-Demi-Langkah Remote Data</span></span><br />
<br />
<ol>
<li>Dua hal yang perlu Anda lakukan </li>
<li>Setup layanan web (latihan sederhana ini kita menggunakan bahasa scripting dan database) </li>
<li>Mengatur app untuk get data dan post data. </li>
<li>Menggunakan salah satu parse dengan JSON atau XML. </li>
<li>Menggunakan NSURLConnection untuk mendownload isi dari URL.</li>
</ol>
<ul class="ul1"><ul>
</ul>
</ul>
</div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-68605873065462433482013-05-29T14:45:00.004+07:002015-05-03T14:00:53.372+07:00Objective-C<h3 style="text-align: justify;">
Pengantar iOS</h3>
<ol>
<li style="text-align: justify;">Objective-C adalah superset dari C. Artinya perintah Objective-C relatif saama tapi lebih banyak dari pada perintah Bahasa C. </li>
<li style="text-align: justify;">Inheritance tunggal, class hanya mewarisi dari satu Superclass </li>
<li style="text-align: justify;">Dapat menggunakan protokol (protocol) & delegasi (delegation) atau kategori (categories) untuk memperluas class. </li>
<li style="text-align: justify;">Dinamis saat runtime </li>
<li style="text-align: justify;">Menggunakan getter dan setter untuk mengakses memori instances object di dalam sebuah class.</li>
</ol>
<div>
<div class="p1">
<h3 style="text-align: justify;">
File-File Objective-C</h3>
</div>
<table border="1" cellpadding="1" cellspacing="1" style="text-align: justify;">
<tbody>
<tr>
<td class="td1" valign="middle"><div class="p2">
<span class="s1">.h</span></div>
</td>
<td class="td2" valign="middle"><div class="p3">
<span class="s1">File <i>Header</i>. File <i>Header</i> berisi <i>class</i>, <i>type</i>, <i>function</i>, dan deklarasi <i>contant</i>.</span></div>
</td>
</tr>
<tr>
<td class="td3" valign="middle"><div class="p2">
<span class="s1">.m</span></div>
</td>
<td class="td4" valign="middle"><div class="p3">
<span class="s1">File Sumber. ini adalah ekstensi yang biasa digunakan untuk <i>source file</i> dan dapat berisi objective-C dan kode C.</span></div>
</td>
</tr>
<tr>
<td class="td5" valign="middle"><div class="p2">
<span class="s1">.mm</span></div>
</td>
<td class="td6" valign="middle"><div class="p3">
<span class="s1">File Sumber. Sebuah source file yang berisi kode C++ dengan kode tambahan untuk objective-C dan kode C. Ekstensi ini digunakan jika benar-benar merujuk class pada C++ atau fitur dari kode objectice-C</span></div>
</td></tr>
</tbody></table>
<div class="p1">
<div style="text-align: justify;">
<br /></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Catatan Tambahan: File .Xib dan file Storyboard pada dasarnya adalah file antarmuka.</span></div>
<a href="https://www.blogger.com/null" name="more"></a></div>
<h3 style="text-align: justify;">
</h3>
<h3 style="text-align: justify;">
Koding Praktek</h3>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<br />
<div style="text-align: justify;">
MVC: Model-View-Controller</div>
<span style="font-weight: normal;"></span><br />
<div style="text-align: justify;">
<span style="font-weight: normal;">Pendekatan Modular</span></div>
<span style="font-weight: normal;">
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Ketika object dibutuhkan, maka akan di load ke dalam memori</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Setiap layar informasi adalah terpisah “View Controller yang dapat digunakan kembali</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Setiap ViewController mempunyai sebuah class (file .h & .m)</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Object antarmuka seperti View dalam Storyboard atau file Xib</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Polymorphism oleh subclass Views dan Objects.</div>
</span><br />
<ul class="ul1"><ul>
</ul>
</ul>
<div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Polymorphism “mempunyai banyak bentuk” yang juga merupakan salah satu sifat class yang memungkinkan sebuah method mempunyai nama yang sama, namun memiliki aksi yang berbeda.</span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><br /></span></div>
</div>
<div class="p1">
<span class="s1">
</span></div>
<br />
<div style="text-align: justify;">
<b>Model-View-Controller</b></div>
<div style="text-align: justify;">
<br /></div>
<span style="font-weight: normal;"></span><br />
<div style="text-align: justify;">
<span style="font-weight: normal;">Pola Desain MVC</span></div>
<span style="font-weight: normal;">
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Model - Data atau object yang dimanipulasi atau ditampilkan.</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
View - Aspek visual antarmuka pengguna.</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Controller - Aspek input antarmuka pengguna. Controller menerima input pengguna (mouse, keyboard, network events, dll) dan melakukan operasi model atau melihat pembaharuan dalam menanggapi masukan.</div>
</span><span style="font-weight: normal;"><div style="text-align: justify;">
Pendekatan ini memungkinkan Anda memisahkan tanggung jawab kode dengan tepat.</div>
</span><br />
<h3 style="text-align: justify;">
<span class="s1">Diagram MVC</span></h3>
<div style="text-align: justify;">
<span style="font-weight: normal;"><br /></span>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGneIq9O01LXejkIgYPqizJ1aj1r4Pwsyid7G0l0Lm8A7Rw3c0H1UFayXMQ_xfRhmv6oY8kjBpK8x3IQQwXHSiqePjYPX9nI4g3hIznebEWETuRVtOf4xny1VwNshbeUqvddCKsGpwU78o/s1600/Screen+Shot+2013-06-04+at+15.12.51.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGneIq9O01LXejkIgYPqizJ1aj1r4Pwsyid7G0l0Lm8A7Rw3c0H1UFayXMQ_xfRhmv6oY8kjBpK8x3IQQwXHSiqePjYPX9nI4g3hIznebEWETuRVtOf4xny1VwNshbeUqvddCKsGpwU78o/s320/Screen+Shot+2013-06-04+at+15.12.51.png" height="204" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Sumber: Esri</div>
<div style="text-align: justify;">
<span style="font-weight: normal;"><br /></span></div>
</div>
<div>
<ul class="ul1"><span class="s1"><ul>
</ul>
</span></ul>
<span class="s1">
</span>
<br />
<div>
<h3 style="text-align: justify;">
<span class="s1">
<span class="s1">Dasar OOP</span></span></h3>
</div>
<div>
<div class="p1">
<div style="text-align: justify;">
<b>Encapsulation</b>: Menyimpan implementasi dari object dari antarmuka. Private, Protected, Public.</div>
<div style="text-align: justify;">
<b>Polymorphism</b>: Kemampuan object yang berbeda untuk merespon, masing-masing dengan caranya sendiri, untuk pesan identik. misalnya. Circle & Eclipse.</div>
<div style="text-align: justify;">
<b>Inheritance</b>: Untuk inheritance property yang lain. Objective-C memiliki inheritance tunggal, hanya class yang mewarisi dari satu superclass.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Variabel Dasar</div>
</div>
<span class="s1"><span class="s1">
<table border="1" cellpadding="1" cellspacing="1" style="text-align: justify;">
<tbody>
<tr>
<td class="td1" valign="middle"><div class="p2">
<span class="s1"><b>Type</b></span></div>
</td>
<td class="td2" valign="middle"><div class="p2">
<span class="s1"><b>Keterangan</b></span></div>
</td>
</tr>
<tr>
<td class="td3" valign="middle"><div class="p3">
<span class="s1">General</span></div>
</td>
<td class="td4" valign="middle"><div class="p4">
<span class="s1">id</span></div>
</td>
</tr>
<tr>
<td class="td5" valign="middle"><div class="p3">
<span class="s1">Object</span></div>
</td>
<td class="td6" valign="middle"><div class="p4">
<span class="s1">NSObject</span></div>
</td>
</tr>
<tr>
<td class="td7" valign="middle"><div class="p3">
<span class="s1">Number</span></div>
</td>
<td class="td8" valign="middle"><div class="p4">
<span class="s1">int float, double, NSNumber</span></div>
</td>
</tr>
<tr>
<td class="td9" valign="middle"><div class="p3">
<span class="s1">Character atau String</span></div>
</td>
<td class="td10" valign="middle"><div class="p4">
<span class="s1">varchar, chat, NSString @”string”</span></div>
</td>
</tr>
<tr>
<td class="td11" valign="middle"><div class="p3">
<span class="s1">Array atau Multi-dimensional array</span></div>
</td>
<td class="td12" valign="middle"><div class="p5">
<span class="s1">NSArray, NSMutableArray, NSDictionary, MSMutableDictionary.</span></div>
<div class="p5">
<span class="s1">NSArray adalah suatu berguna yang disediakan untuk menyimpan data.</span></div>
<div class="p5">
<span class="s1">NSMutableArray digunakan untuk menunjukkan tipe array yang berbeda.Perbedaannya adalah bahwa Anda tidak bisa menambah dan menghapus isi dari NSArray setelah anda membuatnya, tapi anda bisa menambah ataupun menghapus isi dari NSMutableArray kapanpun anda mau. </span></div>
<div class="p5">
<span class="s1">Untuk membuat array, dengan menggunakan: @[ item1, item2, item3 ]</span></div>
<div class="p5">
<span class="s1">setiap isi dari array adalah string. Untuk membuat string di Objective-C. anda harus menambahkan simbol @ didepannya. Jadi jika app anda crash ketika anda menggunakan string, periksa kembali apakah anda lupa menggunakan simbol @!</span></div>
<div class="p5">
<span class="s1">Perbedaan tipe array: <b>NSArray</b> ddan <b>NSMutableArray</b> sejauh ini dua-duanya sudah melaksanaan pekerjaan yang sama, Gunakan <b>NSMutableArray</b> jika ingin mengubah/mengupdate array tersebut, seperti namanya, mutable array dapat diubah. Dan normal <b>NSArray</b> adalah statis dan anda tidak tidak bisa menambah item yang baru atau menghapus suatu item dari array dengan mudah. </span></div>
</td>
</tr>
<tr><td>Boolean</td><td>BOOL</td>
</tr>
<tr><td>Data</td><td>NSData</td></tr>
</tbody></table>
</span></span></div>
<div>
<span class="s1"><span class="s1">
</span></span><br />
<div class="p1">
<h3 style="text-align: justify;">
<span class="s1"><span class="s1"><span class="s1">Istilah</span></span></span></h3>
</div>
<br />
<div style="text-align: justify;">
Direktif ini identik dengan #include kecuali bahwa ini memastikan file yang sama tidak pernah disertakan lebih dari sekali. Oleh karena itu disukai dan digunakan ditempat #include di contoh kode seluruh dokumentasi Objective-C</div>
<span class="s1"><span class="s1"><table border="1" cellpadding="1" cellspacing="1" style="text-align: justify;">
<tbody>
<tr>
<td class="td1" valign="middle"><div class="p2">
<span class="s1"><b>Istilah</b></span></div>
</td>
<td class="td2" valign="middle"><div class="p2">
<span class="s1"><b>Keterangan</b></span></div>
</td>
</tr>
<tr>
<td class="td3" valign="middle"><div class="p2">
<span class="s1">Self</span></div>
</td>
<td class="td4" valign="middle"><div class="p3">
<span class="s1">Sebuah nama variabel yang dapat digunakan dalam berbagai cara, bahkan diberi nilai baru. Di dalam <i>instance method</i>, <i>self refers</i> mengacu pada <i>instance</i>, tapi dalam sebuah <i>class method</i>, <i>self refers</i> mengacu pada <i>class object</i>.</span></div>
<div class="p3">
<span class="s1"><b>Self</b> adalah special keyword yang berarti “class yang sekarang” - mirip this pada bahasa pemrograman yang lain.</span></div>
<div class="p3">
<span class="s1">Ada bisa mengakses properti dari suatu class dengan menggunakan titik, dan kemudian mengetikan nama propertinya, mis: <b>self.myQuotes</b> memungkinkan anda mengakses properti <b>myQuotes</b> yang ada buat sebelumnya.</span></div>
</td>
</tr>
<tr>
<td class="td5" valign="middle"><div class="p2">
<span class="s1">Super</span></div>
</td>
<td class="td6" valign="middle"><div class="p3">
<span class="s1">Sebuah flag untuk compiler yang berpengaruh dalam proses mencari metode untuk mengerjakan; ini digunakan sebagai penerima pesan.</span></div>
</td>
</tr>
<tr>
<td class="td7" valign="middle"><div class="p2">
<span class="s1">IBOutlet</span></div>
</td>
<td class="td8" valign="middle"><div class="p3">
<span class="s1">Sebuah variabel instance khusus sebagai referensi dari object lain. IBOutlet adalah menghubung dari code program ke komponen pada user interface. Atau properti yang kelas digunakan untuk terhubung ke element interface pengguna.</span></div>
</td>
</tr>
<tr>
<td class="td9" valign="middle"><div class="p2">
<span class="s1">IBAction</span></div>
</td>
<td class="td10" valign="middle"><div class="p3">
<span class="s1">Sebuah metode khusus yang dipicu oleh object user interface. IBAction adalah metode yang merespon event (misalnya, sentuhan tombol).</span></div>
</td>
</tr>
<tr><td>#import </td><td></td></tr>
<tr><td>@Class</td><td>Deklarasi forward. Deklarasi ini hanya menggunakan nama class sebagai jenis dan tidak bergantung pada setiap detail dari kelas antarmuka (metode dan variabel instance) direktif @class memberikan peringatan pada compiler apa yang diharapkan. Namun, dimana antarmuka untuk kelas sebenarnya digunakan (contoh dibuat, pesan yang dikirim) antarmuka class harus diimport.</td></tr>
</tbody></table>
</span></span><br />
<h3 style="text-align: justify;">
<span class="s1"><span class="s1">
<span class="s1">Atribut @Property</span></span></span></h3>
<div>
<span class="s1"><span class="s1"><span class="s1">
<table border="1" cellpadding="1" cellspacing="1" style="text-align: justify;">
<tbody>
<tr>
<td class="td1" valign="middle"><div class="p2">
<span class="s1"><b>Istilah</b></span></div>
</td>
<td class="td2" valign="middle"><div class="p2">
<span class="s1"><b>Keterangan</b></span></div>
</td>
</tr>
<tr>
<td class="td3" valign="middle"><div class="p2">
<span class="s1">atomic</span></div>
</td>
<td class="td4" valign="middle"><div class="p3">
<span class="s1">Atomic adalah <i>default behavior</i>. Jika suatu <i>object</i> dinyatakan sebagai atomic maka akan menjadi <i>thread-safe</i>. Berarti thread-safe, pada suatu kondisi dimana hanya satu <i>thread</i> dari <i>instance</i> tertentu yang berasal dari class itu sajadapat memiliki kontrol atas <i>object</i> tersebut.</span></div>
<div class="p3">
<span class="s1">Jika thread ini melakukan <i>getter method</i> maka <i>thread</i> lain tidak dapat melakukan <i>setter method</i> pada <i>object</i> tersebut. dan ini akan menjadi lambat.</span></div>
<div class="p4">
<span class="s1"></span><br /></div>
<div class="p3">
<span class="s1">Contoh: </span></div>
<div class="p5">
<span class="s2">@property</span><span class="s3"> </span><span class="s4">NSString</span><span class="s3"> *name; </span><span class="s1">//by default atomic`</span></div>
<div class="p5">
<span class="s2">@property</span><span class="s3"> (atomic)</span><span class="s4">NSString</span><span class="s3"> *name; </span><span class="s1">// explicitly declared atomic`</span></div>
<div class="p4">
<span class="s1"></span><br /></div>
<div class="p1">
<br /></div>
</td>
</tr>
<tr><td>nonatomic</td><td>Atribut nonatomic dapat meningkatkan performance dengan mengorbankan thread-safety.
Non atomic adalah thread tidak aman. Anda dapat menggunakan Atribut properti nonatomic untuk menemukan bahwa synthesized accessors hanya mengatur atau mengembalikan nilai secara langsung, dengan tidak menjamin apa yang terjadi jika nilai yang sama diakses secara bersamaan dari threads yang berbeda.
Untuk alasan ini, lebih cepat mengakses properti nonatomic jika dibandikan dengan atomic.
Contoh:
@property (nonatomic)NSString *name; </td></tr>
<tr><td>Retain</td><td>Retain diperlukan bila atribut berupa pointer ke object. Metode setter akan meningkatkan retain count object, sehingga akan menempati memori pada autorelease pool.
Contoh:
@property (retain)NSString *name; </td></tr>
<tr><td>Copy</td><td>Jika menggunakan copy, anda tidak dapat menggunakan retain. Penggunaan copy instance dari class akan berisi copy itu sendiri.
Bahkan jika mutable string diatur dan kemudian berubah, misalnya menangkap apa saja nilai itu pada waktu yang ditetapkan. Tidak ada metode setter dan getter
</td></tr>
<tr><td>Strong</td><td>Strong adalah pengganti untuk retain.
Atribut Strong mengindikasikan bahwa pointer ke variabel akan tetap di memory selama object yang memakai pointer masih tetap ada.
Strong: ini menspesifikasikan bahwa runtime harus seara otomatis menjaga referensi strong pada object. atau dengan kata lain, kita menginginkan agar ARC runtime tetap mengkeep object di dalam memori selama ada referensi, dan men-deallocate karena tidak ada referensi lagi.
Contoh:
@property (nonatomic, strong) AVPlayer *player;
</td></tr>
<tr><td>@properties</td><td>Adalah satu metode yang digunakan untuk memberi nilai (setter) ke sebuah variabel atau mengambil nilai (getter) dari sebuah variabel dalam sebuah objek.
Pendeklarasian Propery
Property dideklarasikan dalam interface menggunakan @propery
pada implementation property ini harus di synthesize menggunakan @synthesize
Syntax:
@interface nameInstance: NSObject {
tipeData namaVariabel;
}
@property tipeData namaVariabel;
@end
@implementation namaInterface
@synthesize namaVariabel;
@end;
Pengambilan Nilai dari Variabel (Getter)
Syntax:
[namaObjek namaVariabel]
atau
namaObjek.namaVariabel
Contoh:
Buatlah sebuah proyek dengan nama Properties dan isilah file main.m dengan kode berikut ini:
#import<foundation oundation.h="">
</foundation></td></tr>
<tr><td>@properties</td><td>Adalah satu metode yang digunakan untuk memberi nilai (setter) ke sebuah variabel atau mengambil nilai (getter) dari sebuah variabel dalam sebuah objek. </td></tr>
<tr><td>Assign </td><td>ini berarti property di set secara langsung, tanpa ada keterlibatan dari memory management. ini yang biasa kita set untuk tipe data primitive (non-object) seperti float. </td></tr>
</tbody>
</table>
</span></span></span><br />
<div style="text-align: justify;">
<span class="s1"><span class="s1"><span class="s1"><br /></span></span></span></div>
<span class="s1"><span class="s1"><span class="s1">
</span></span></span>
<span class="s1"><span class="s1"><span class="s1">
</span></span></span><br />
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Objective-C </b>NSLog Output</span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<br /></div>
</div>
<table border="1" cellpadding="1" cellspacing="1" style="text-align: justify;">
<tbody>
<tr>
<td class="td1" valign="middle"><div class="p2">
<span class="s1"><b>Format </b></span></div>
<div class="p2">
<span class="s1"><b>Spesifikasi</b></span></div>
</td>
<td class="td2" valign="middle"><div class="p2">
<span class="s1"><b>Keterangan</b></span></div>
</td>
</tr>
<tr>
<td class="td3" valign="middle"><div class="p2">
<span class="s1">%@</span></div>
</td>
<td class="td4" valign="middle"><div class="p3">
<span class="s1">General | Boolean | NSDate | String. </span></div>
<div class="p3">
<span class="s1">NSLog(@ "String value is: %@", _myName); </span></div>
<div class="p3">
<span class="s1">NSLog(@"the current date is %@",today);</span></div>
<div class="p1">
<br /></div>
</td>
</tr>
<tr>
<td class="td5" valign="middle"><div class="p2">
<span class="s1">@f, %g</span></div>
</td>
<td class="td6" valign="middle"><div class="p3">
<span class="s1">Float | Double.<br />
NSLog(@"double value is: %f", _double);</span></div>
<div class="p4">
<br /></div>
<div class="p1">
<br /></div>
</td>
</tr>
<tr>
<td class="td7" valign="middle"><div class="p2">
<span class="s1">@i</span></div>
</td>
<td class="td8" valign="middle"><div class="p3">
<span class="s1">Integer | Long<br />
NSLog(@"The value of integer num is %i", num); NSLog(@"long value is: %i", _long);</span></div>
<div class="p1">
<br /></div>
</td>
</tr>
</tbody>
</table>
<div class="p1">
<span class="s1">
</span></div>
<div class="p1">
<div style="text-align: justify;">
<br /></div>
</div>
<div class="p1">
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Catatan: Programmer menggunakan fungsi NSLog untuk debug app. </span></div>
</div>
<span class="s1"><span class="s1"><span class="s1">
</span></span></span><br />
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Fungsi NSLog digunakan untuk menampilkan pesan debug pada konsol.</span></div>
</div>
<h3 style="text-align: justify;">
Class Declaration</h3>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBpKUBucTnm7ScoaHzpojL2zug687U5R2gGruLFhIAEi8227T2PEYinF0KzxFD__-mhkQy6ZH5EIMZuqma6Gsbx5A6ukxe26IHYwhrdmTLNhtFWlg_6B_KjRNuubwLjU9cZU1J9kKfVARP/s1600/Screen+Shot+2013-06-04+at+15.16.01.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBpKUBucTnm7ScoaHzpojL2zug687U5R2gGruLFhIAEi8227T2PEYinF0KzxFD__-mhkQy6ZH5EIMZuqma6Gsbx5A6ukxe26IHYwhrdmTLNhtFWlg_6B_KjRNuubwLjU9cZU1J9kKfVARP/s400/Screen+Shot+2013-06-04+at+15.16.01.png" height="187" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Catatan: “-” dan “+” diperlukan untuk <i>method declaration</i>. “-” berati menggunakan <i>Instance Method</i> dan “+” berarti menggunakan<i> Class Method</i></span></div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87yu0wZJkUakKn4iRxdAg9htUYgOpZNIl4ULno3QX-s_MthfMwPQ2j6i0iUVI81Ocj_-KiDdiIt4-dTJTw94gc4Dh20cYQs0QwGqhnhnGOXruHIjr-IIu_ZwFE0ga6ipjKT-YDd7xpap7/s1600/Screen+Shot+2013-06-04+at+15.17.35.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi87yu0wZJkUakKn4iRxdAg9htUYgOpZNIl4ULno3QX-s_MthfMwPQ2j6i0iUVI81Ocj_-KiDdiIt4-dTJTw94gc4Dh20cYQs0QwGqhnhnGOXruHIjr-IIu_ZwFE0ga6ipjKT-YDd7xpap7/s400/Screen+Shot+2013-06-04+at+15.17.35.png" height="196" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Method & Messaging</h3>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPgh63OCc6NT6CJhXhFMvX9OcHaAc_JpC7kglUk7DtEncDYmx2pxw-H9zLY-pnVCllK8R7S3srtwlqKpK_Ryspghey3SbMr-iNaqwNwQ-EYSM6XmTNLtonGpr6aGBf-jIg4VhjZgR9JN62/s1600/Screen+Shot+2013-06-04+at+15.18.14.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPgh63OCc6NT6CJhXhFMvX9OcHaAc_JpC7kglUk7DtEncDYmx2pxw-H9zLY-pnVCllK8R7S3srtwlqKpK_Ryspghey3SbMr-iNaqwNwQ-EYSM6XmTNLtonGpr6aGBf-jIg4VhjZgR9JN62/s400/Screen+Shot+2013-06-04+at+15.18.14.png" height="211" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Pemanggilan Method</h3>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Pembuatan method:</b></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">- (void)myMethod {</span></div>
</div>
<div class="p3">
<div style="text-align: justify;">
<span class="s1"><span style="color: lime;">//Your code here</span></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">}</span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">- (void)myName:(NSString *)fullname myAge:(int)age {</span></div>
</div>
<div class="p3">
<div style="text-align: justify;">
<span class="s1"><span style="color: lime;">//Your code here</span></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">}</span></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s1"></span><br /></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Pemanggilan method:</b></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">[self myMethod];</span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">[self myName:@”Muhamad Yusup” myAge:34];</span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="p5">
<div style="text-align: justify;">
<span class="s1">Catatan: @ berarti nilai string diperlukan.</span></div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<h3 style="text-align: justify;">
Allocating & Initializing Object</h3>
</div>
<div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>2 Tahapan untuk membuat object menggunakan objective-C:</b></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">1. Mengalokasikan secara dinamis untuk <b>object</b> baru</span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">2. Menginisialiasi memori yang baru dialokasikan untuk nilai yang tepat</span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1"><br /></span></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH-xou9N4arpzvXjEIW7q6SIV6cvDE2PRmtazQNJ3NGQORrhFmObLbH-pt_AQE6uvWABwdBVn0Yt_v22GqZGEHo6t-wZslG1HloBiHeTrbvTWyJpkWdo0qf7YRQOFUgrkXuYdiKdyTNfBW/s1600/Screen+Shot+2013-06-04+at+15.24.45.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH-xou9N4arpzvXjEIW7q6SIV6cvDE2PRmtazQNJ3NGQORrhFmObLbH-pt_AQE6uvWABwdBVn0Yt_v22GqZGEHo6t-wZslG1HloBiHeTrbvTWyJpkWdo0qf7YRQOFUgrkXuYdiKdyTNfBW/s320/Screen+Shot+2013-06-04+at+15.24.45.png" height="91" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<div class="p1">
</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<h3 style="text-align: justify;">
Memory Allocation</h3>
</div>
<ul>
<li style="text-align: justify;">Automatic Reference Counting (ARC) </li>
<li style="text-align: justify;">Now ARC by default is automatic </li>
<li style="text-align: justify;">No more retain, release </li>
<li style="text-align: justify;">No more Dealloc! </li>
<li style="text-align: justify;">Menggunakan referensi weak & Strong referencing untuk objects </li>
<li style="text-align: justify;">ARC is not garbage collector but somewhere is beetween manual and garbage collector </li>
</ul>
<div>
<div>
<h3 style="text-align: justify;">
Protocol & Delegate</h3>
</div>
</div>
<div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Protocol:</b></span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1">Adalah programatik antarmuka setiap kelas dapat memilih untuk diterapkan. Kelas mengadopsi dapat memilih untuk melaksanakan satu atau lebih metode yang dideklarasikan.</span></div>
</div>
<div class="p3">
<div style="text-align: justify;">
<span class="s1"></span><br /></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s2">@interface myViewController: UIViewController </span></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s3"><b><span style="color: orange;"><UIAlertViewDelegate> </span></b></span><span class="s1"><span style="color: lime;">//berarti kelas ini sesuai dengan UIAlertViewDelegate protocol</span></span></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s2"><br /></span></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s2">@interface myViewController: UIViewController </span></div>
</div>
<div class="p4">
<div style="text-align: justify;">
<span class="s3"><b><span style="color: orange;"><UIAlertViewDelegate, UISplitViewControllerDelegate></span> </b></span><span class="s1"><span style="color: lime;">//Jika lebih dari 1 (satu) delegate terpisah dengan koma</span></span></div>
</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Delegate:</b></span></div>
</div>
<div style="text-align: justify;">
<br /></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Sebuah object yang telah ditetapkan oleh object lain sebagai object yang bertanggung jawab untuk menangani event.</span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><br /></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM_nzqmxEVj6S6sf8pQsrGfFPkRjgLppdI3XisBWf4cl798_lJZQgZbvf4N4MXEzlBTB-Wd5Fhe8sgJmI4uidMLBJTTd-O3h6V6H_GcJhptokEvnKwJEOrhz8fahZ51KLHDhxMi0hHC2CM/s1600/Screen+Shot+2013-06-04+at+15.28.42.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM_nzqmxEVj6S6sf8pQsrGfFPkRjgLppdI3XisBWf4cl798_lJZQgZbvf4N4MXEzlBTB-Wd5Fhe8sgJmI4uidMLBJTTd-O3h6V6H_GcJhptokEvnKwJEOrhz8fahZ51KLHDhxMi0hHC2CM/s400/Screen+Shot+2013-06-04+at+15.28.42.png" height="157" width="400" /></a></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><br /></span></div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Categories:</b></span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Memungkinkan untuk menambah metode untuk class yang ada, tanpa perlu superclass. Bisa juga menimpa class yang ada. Dalam C#, dikenal sebagai metode ekstensi.</span></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1"></span><br /></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Kategori mengikuti sintaks layout yang sama seperti sebuah class, yang dimiliki pada <b>implementation</b> dan <b>interface</b>.</span></div>
</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5K94G7YlzCfFO9f-uNkynvZfVI3-B6YRT1bq1jiPYVHwu03VPBFzjKyAQK5YyjBnwWTUkeIs5e-57W_bTuNrQQtKBchk_lXtXcZIpdNClV_ovQp5x1catp-vDI2DD3v8ggw3DArbunW-/s1600/Screen+Shot+2013-06-04+at+15.30.32.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEha5K94G7YlzCfFO9f-uNkynvZfVI3-B6YRT1bq1jiPYVHwu03VPBFzjKyAQK5YyjBnwWTUkeIs5e-57W_bTuNrQQtKBchk_lXtXcZIpdNClV_ovQp5x1catp-vDI2DD3v8ggw3DArbunW-/s400/Screen+Shot+2013-06-04+at+15.30.32.png" height="172" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixkkR1b1lMJGa9jn3SQSIfSakZlOjjQy-x4H8IYwNxADPojrMvFg_oR-fF4XLd9rarm3BWVrztqtxptzcFBQ60KoZSjmcS6ml1hOQplC5yx4M2fvzLuax-BGkARhKYBksdxn0VT3eSFNxK/s1600/Screen+Shot+2013-06-04+at+15.32.41.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: justify;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixkkR1b1lMJGa9jn3SQSIfSakZlOjjQy-x4H8IYwNxADPojrMvFg_oR-fF4XLd9rarm3BWVrztqtxptzcFBQ60KoZSjmcS6ml1hOQplC5yx4M2fvzLuax-BGkARhKYBksdxn0VT3eSFNxK/s400/Screen+Shot+2013-06-04+at+15.32.41.png" height="400" width="382" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1"><b>Catatan:</b></span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Setiap blok kode (antarmuka dan implementasi) harus dalam file masing-masing sendiri oleh konvensi.</span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Namun, nama kategori sedikit berbeda. </span></div>
</div>
<div class="p1">
<div style="text-align: justify;">
<span class="s1">Dua file yang telah dibuat diberi nama: NSString + reverse.h (interface) dan NSString +reverse.m (implementation). </span></div>
</div>
<div class="separator" style="clear: both; text-align: left;">
</div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1"></span><br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="p2">
<div style="text-align: justify;">
<span class="s1"></span><br /></div>
</div>
<div class="p2">
<div style="text-align: justify;">
<br /></div>
</div>
</div>
</div>
</div>
<span class="s1"><span class="s1">
</span></span></div>
<span class="s1">
</span></div>
</div>
</div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-86000553835632815942013-05-29T14:43:00.003+07:002015-05-03T13:58:08.689+07:00Bagaimana menambahkan splash screen untuk app saya? <div style="text-align: justify;">
Sebelum kita mempelajari lebih rinci tentang storyboard, saya ingin terlebih dahulu menjawab beberapa pertanyaan tentang bagaimana menambahkan splash screen untuk aplikasi saya? apakah sulit untuk membuatnya?</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Meskipun kita berfikir bahwa kita perlu menulis xcode untuk splash screen, Apple telah membuat sangat mudah untuk untuk dicoba di dalam Xcode. Tidak ada coding diperlukan di dalam pembuatan ini. Yang dilakukan hanyalah membuat beberapa konfigurasi di Xcode.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Bagi programmer pemula mungkin belum pernah mendengar istilah "Splash Screen". Splash screen umumnya ditemukan pada aplikasi iOS serta aplikasi desktop lainnya. Ini adalah layar pertama yang kita lihat ketika pertama kali aplikasi muncul. Biasanya, layar splash adalah gambar menutupi seluruh layar kemudian beberapa detik kemudian menghilang setelah layar utama muncul. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Adapun tujuan utama dari splash screen adalah untuk memberitahukan kepada pengguna aplikasi apa yang sedang digunakan dan menampilkan layar pengantar selama proses loading. Splash screen ini penting terutama bagi aplikasi yang membutuhkan waktu lebih lama untuk memulai sebelum muncul aplikasi utamanya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti yang telah dijelaskan sebelumnya, bahwa untuk membuat splash screen tidak diperlukan menulis koding apapun untuk menampilkan splash screen. iOS dilengkapi dengan fitur built-in yang disebut dengan launch image. Image ini ditampilkan secara otomatis ketika pengguna membuka aplikasi dan menghilang sampai aplikasi tersebut sepenuhnya siap untuk digunakan. Anda hanya dapat menentukan splash screen Ada sebagai gambar launch Xcode.</div>
<div style="text-align: justify;">
<br /></div>
<a name='more'></a><div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<h2 style="text-align: justify;">
Persiapan Membuat Splash Screen</h2>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Seperti yang Anda ketahui, iPhone 4/4S mendukung resolusi layar yang lebih tinggi (apa yang disebut Retina Display). Dalam rangka mendukung kedua resolusi layar iPhone model lama dan model terbaru, Anda harus mempersiapkan dua versi gambar splash screen ukuran ini:</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
320 x 480 (untuk iPhone 2G / 3G / 3GS)</div>
<div style="text-align: justify;">
640 x 960 (untuk iPhone 4 / 4S)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Untuk membuat lebih sederhana, saya akan menunjukkan cara untuk menambah splash screen di iPhone app. Dalam kasus Anda sedang membangun sebuah aplikasi iPad, Anda bisa merujuk ke App iOS untuk Pedoman Interaksi Manusia dan Komputer tentang ukuran gambar launching dan konvensi penamaannya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Gambar splash screen harus dalam format PNG. Secara default, Anda harus memberikan nama file gambar untuk resolusi layar yang lebih rendah dengan nama "Default.png". Untuk gambar yang ditujukan untuk Retina Display (yaitu x 640 resolusi layar 960), nama filenya adalah "Default@2x.png". "@ 2x" adalah pengubah skala standar yang digunakan dalam iOS. Semua file gambar ditujukan untuk menampilkan dalam Retina Display harus nama dengan string "@ 2x".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Walaupun menggunakan "Default" sebagai nama file gambar launch, Anda dapat mengubahnya ke salah satu dari pilihan yang ada. Nama gambar launch didefinisikan dalam file Info.plist pada aplikasi yang kita buat. Gunakan aplikasi tabel sederhana sebagai contoh, anda dapat menambahkan properti baru yang disebut "Launch Image" dalam SimpleTable-Info.plist dan tentukan nama file pilihan (misalnya, MyLaunchImage).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjRO_aExM7eHPo-LX2sTgApQmDZ433iksUaalBTiRiDzAvG4CYz5QG3Phvni3ijHFb4nwFgWzV3r-BBFyMxD7nal97k4J8hbdF7HEHHpGDa_xRmO7Rb3IS4tbny59ra_QnstPfwrTSOMO/s1600/Xcode-Change-Launch-Image-Name.jpg"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMjRO_aExM7eHPo-LX2sTgApQmDZ433iksUaalBTiRiDzAvG4CYz5QG3Phvni3ijHFb4nwFgWzV3r-BBFyMxD7nal97k4J8hbdF7HEHHpGDa_xRmO7Rb3IS4tbny59ra_QnstPfwrTSOMO/s320/Xcode-Change-Launch-Image-Name.jpg" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Cara merubah instruksi iOS untuk memilih "MyLaunchImage.png" dan "MyLaunchImage@2x.png" sebagai gambar launch.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Anda dapat merancang splash screen sendiri. Untuk tujuan testing, Anda mungkin dapat mendownload dari sini <a href="http://www.appcoda.com/wp-content/uploads/2012/05/splash_screen.zip">download contoh splash screen</a></div>
<div style="text-align: justify;">
<br /></div>
<h2 style="text-align: justify;">
Menambahkan Launch Image di Xcode</h2>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Setelah menyiapkan launch image, kembali ke Xcode dan buka project Xcode Anda. Di sini kita akan selalu menggunakan project simple table. Klik kanan pada project "SimpleTable" dan pilih "Add File ke SimpleTable". Tambahkan kedua image masing-masing dengan nama "Default.png" dan "Default@2x.png" untuk project yang kita buat.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPjn_FegeWNUi8VmegF8QpoZRnRR3aJSfv-gTuk0X9_x8DVuBonIUir_gfkHkj-vJH6INTgyVE8o64Re34Hot9-25LqVjb5ZXp9RQXalFmbyyD8pAoOcqy5dnNIWh3PGJgcdrNn-91irNO/s1600/Add-file-to-Xcode-Project.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPjn_FegeWNUi8VmegF8QpoZRnRR3aJSfv-gTuk0X9_x8DVuBonIUir_gfkHkj-vJH6INTgyVE8o64Re34Hot9-25LqVjb5ZXp9RQXalFmbyyD8pAoOcqy5dnNIWh3PGJgcdrNn-91irNO/s400/Add-file-to-Xcode-Project.jpg" height="392" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Jika Anda telah melakukan semuanya dengan benar, maka Anda akan melihat kedua file dalam project yang kita buat dan Xcode otomatis mengenali file sebagai Launch Image.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitmWrB7c7kFwo3CWZ1mVTVEDgTWMJl1HzOlTz0NQxfBi32B4nSGStIqds5PPeq7zPspc7mr-RcwCagK9dYo_X8SmEY0oWV_3xQOsE2ylqO6_2NvOAf_MYaD3iAHkr5aBVVSab2rMLYJPVf/s1600/Launch-Image-Added-in-Xcode.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitmWrB7c7kFwo3CWZ1mVTVEDgTWMJl1HzOlTz0NQxfBi32B4nSGStIqds5PPeq7zPspc7mr-RcwCagK9dYo_X8SmEY0oWV_3xQOsE2ylqO6_2NvOAf_MYaD3iAHkr5aBVVSab2rMLYJPVf/s400/Launch-Image-Added-in-Xcode.jpg" height="140" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
ujicoba hasilnya cukup dengan menjalankan aplikasi, kita akan melihat splash screen berjalan sebelum aplikasi utama ditampilkan. </div>
<div style="text-align: justify;">
<br /></div>
<h2 style="text-align: justify;">
<b>Informasi lebih lanjut</b></h2>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Tutorial yang ditampilkan disini cukup singkat, saya telah tunjukkan cara menambahkan splash screen sederhana di app iPhone Anda. Peluncuran gambar yang kita gunakan adalah dalam orientasi potrait. Bagaimana jika Anda merancang sebuah aplikasi dalam orientasi landscape? Bagaimana seharusnya Anda nama launch image? Saya merekomendasikan Anda untuk mempelajari lebih lanjut <a href="http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/App-RelatedResources/App-RelatedResources.html#//apple_ref/doc/uid/TP40007072-CH6-SW12" style="color: #ed702b; font-family: Lora, serif; font-size: 16px; line-height: 25px;">Apple’s programming guideline for App Launch Image</a>. IOS mendukung berbagai versi launch image dengan konvensi penamaan yang berbeda. Jadi pelajari lebih jauh tentang hal itu.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-63148294227557650172013-05-29T14:41:00.002+07:002015-05-03T14:16:13.969+07:00Membuat TabelView Sederhana<div style="text-align: justify;">
Artikel 2
Tutorial Pemrograman iOS: Membuat Simple Table View App
Apakah anda enjoy untuk membuat aplikasi Hello World? Di tutorial ini, kita akan lakukan sesuatu yang lebih kompleks dan bagaimana membangun aplikasi sederhana menggunakan Table View. Jika Anda belum membaca tutorial sebelumnya tentang pemrograman iOS dasar, periksa kembali ke tutorial awal yang lebih sederhana.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Apa itu Table View di aplikasi iPhone? Table View merupakan salah satu elemen UI yang umum di aplikasi iOS. Kebanyakan aplikasi, dalam beberapa hal, memanfaatkan Table View untuk menampilkan daftar data. Contoh terbaik adalah aplikasi Telepon built-in. Kontak Anda ditampilkan dalam Table View. Contoh lain adalah aplikasi Mail. Menggunakan Table View untuk menampilkan kotak surat Anda dan email. Tidak hanya dirancang untuk menampilkan data tekstual, Table View memungkinkan Anda untuk menyajikan data dalam bentuk gambar. Built-in video dan aplikasi YouTube adalah contoh dalam penggunaannya.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaG5x65I3rMH3tIpqe914Ik9nUA-Imqg0FOTAZJhXG9_D6OZ6IFsfBMo3Qn3UQl5ceY492DpOJtc6RuSOMckxmxwSQkrdyojDIKbXx2OYmzCWbkIewm-akx4-FWBrIdQtvKOZ5XhKpLBNZ/s1600/UITableView-Sample-App.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaG5x65I3rMH3tIpqe914Ik9nUA-Imqg0FOTAZJhXG9_D6OZ6IFsfBMo3Qn3UQl5ceY492DpOJtc6RuSOMckxmxwSQkrdyojDIKbXx2OYmzCWbkIewm-akx4-FWBrIdQtvKOZ5XhKpLBNZ/s400/UITableView-Sample-App.jpg" height="267" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Contoh aplikasi yang menggunakan table view.</div>
<a name='more'></a><div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Membuat Project SimpleTable</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Dengan ide dari TableView, kita akan membuat aplikasi sederhana. Tidak hanya sekilas anda pelajari tutorial ini disarankan anda serius untuk belajar pemrograman iOS. Buka Xcode dan Code!</div>
<div style="text-align: justify;">
Setelah ditampilkan Xcode, tahap selanjutnya adalah membuat New Project kemudian pilih "Single View Application.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDKAm84K0890Kz-psCp-wG_svUgd8ilRJNluuH8IaEad_gi8vN4U9hs7OPMj8XpMqJQhX45scZeLK1dSA_5DV_SEa7NunnhSbB_qy13vylRlV3vq8Vrm7N5jNmrelUXXR6ia8JzjqfLlYF/s1600/Choose-Xcode-Template.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDKAm84K0890Kz-psCp-wG_svUgd8ilRJNluuH8IaEad_gi8vN4U9hs7OPMj8XpMqJQhX45scZeLK1dSA_5DV_SEa7NunnhSbB_qy13vylRlV3vq8Vrm7N5jNmrelUXXR6ia8JzjqfLlYF/s400/Choose-Xcode-Template.jpg" height="270" width="400" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Klik "next" untuk melanjutkan. Sekali lagi, ini semua opsi yang diperlukan.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<ul>
<li style="text-align: justify;">Product Name: <i>Simple Name</i> - ini adalah nama aplikasi yang kita buat.</li>
<li style="text-align: justify;">Company Identifier: <i>com.raharja</i> - ini sebenarnya nama domain yang ditulis terbalik. Jika kita telah memiliki nama domain, kita dapat menggunakan nama domain sendiri. Jika tidak, kita dapat menggunakan <i>mine </i>atau "edu.self"</li>
<li style="text-align: justify;">Class Prefix: <i>Simple Table</i> - Xcode menggunakan awalan kelas untuk menyebutkan kelas otomatis. Dimasa yang akan daang, Anda dapat memilih awalan Anda sendiri atau bahkan dibiarkan kosong. Tapi untuk toturial ini, tetap menggunakan "SimpleTable"</li>
<li style="text-align: justify;">Device Family: <i>iPhone</i> - hanya menggunakan "iPhone" untuk project ini.</li>
<li style="text-align: justify;">Use Storyboards [<i>unchecked</i>] - Jangan pilih opsi ini. Kita tidak perlu menggunakan Storyboard untuk project sederhana ini.</li>
<li style="text-align: justify;">Use Automatic Reference Counting [<i>checked]</i> - secara default, ini harus diaktifkan. Biarkan saja seperti itu.</li>
<li style="text-align: justify;">Include Unit Test [<i>unchecked</i>] - Tidak perlu dichecklist untuk saat ini.</li>
</ul>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmLFqKG1gjwFG4-KgVVhFkWy62TO2OAwix3kFYc67X7WZTfMoALB_YJYbloFq4HcGwJ7lMTpmfA93ViofB4sItOAs2M0SzAW_7t5s-xRMwwgT_70ETKoTkpxjX8u4jbiBEIkTowzXPaduX/s1600/SimpleTable-Project-Setting.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmLFqKG1gjwFG4-KgVVhFkWy62TO2OAwix3kFYc67X7WZTfMoALB_YJYbloFq4HcGwJ7lMTpmfA93ViofB4sItOAs2M0SzAW_7t5s-xRMwwgT_70ETKoTkpxjX8u4jbiBEIkTowzXPaduX/s400/SimpleTable-Project-Setting.png" height="267" width="400" /></a></div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Klik "next" untuk melanjutkan. Xcode kemudian meminta Anda dimana menyimpan "SimpleTable" proyek. Pilih folder (misalnya Desktop) untuk menyimpan project Anda. Seperti sebelumnya, hapus opsi untuk Source Control. Klik "Create" untuk melanjutkan.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCtjT_ZJJnIFY57kIPcqObmdfyL07XzaaXT8WN2siuA65Kn7ItEP7Cm8JRPyncb-lYOQ8CAuGoecAzXG2D8KmFN8AqYRzRrrzXHghyphenhyphenQqwIje23E24PKyctK-BCtZvFTuK-fR2W4GhsB9ZP/s1600/Select-Xcode-Project-Folder.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCtjT_ZJJnIFY57kIPcqObmdfyL07XzaaXT8WN2siuA65Kn7ItEP7Cm8JRPyncb-lYOQ8CAuGoecAzXG2D8KmFN8AqYRzRrrzXHghyphenhyphenQqwIje23E24PKyctK-BCtZvFTuK-fR2W4GhsB9ZP/s400/Select-Xcode-Project-Folder.jpg" height="283" width="400" /></a></div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Ketika Anda mengkonfirmasi, Xcode otomatis menciptakan Project "SimpleTable" berdasarkan pilihan yang Anda berikan. Layar yang dihasilkan terlihat seperti ini:</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP3vSL6ahX66LAk6lB3VTcOGZTESELQWgj_GMll30QUSm0Kkcq4dv2CM9u0a3ctAoSWC_AmPfCTIDvSiEy7TBQ0UcEMPpsZc6iqmC_VfAjmWsLgPYzoMBZPrV4OwNwWi7y0EhittbeWM5_/s1600/SimpleTable-Xcode-Main-Screen.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP3vSL6ahX66LAk6lB3VTcOGZTESELQWgj_GMll30QUSm0Kkcq4dv2CM9u0a3ctAoSWC_AmPfCTIDvSiEy7TBQ0UcEMPpsZc6iqmC_VfAjmWsLgPYzoMBZPrV4OwNwWi7y0EhittbeWM5_/s400/SimpleTable-Xcode-Main-Screen.jpg" height="232" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Layar utama Project SimpleTable</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Merancang View</h3>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Pertama, kita akan membuat user interface dan menambahkan tampilan tabel. Pilih "SimpleTableViewController.xib" untuk beralih ke Interface Builder.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc-cH9FKXtrYEiu-2qAO6LraTGBwJhSNB6NF4C0Fgt5gwbzf4SECMZ1koY5bG5N_wCE9oJ28KSURnKz24K_-QO7Cwlvqs6TtpN6W5_iVjcxOjFosGdxsb4KX13UbOJLnPC_0HxZMDbWCb8/s1600/SimpleTable-Interface-Builder.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc-cH9FKXtrYEiu-2qAO6LraTGBwJhSNB6NF4C0Fgt5gwbzf4SECMZ1koY5bG5N_wCE9oJ28KSURnKz24K_-QO7Cwlvqs6TtpN6W5_iVjcxOjFosGdxsb4KX13UbOJLnPC_0HxZMDbWCb8/s400/SimpleTable-Interface-Builder.jpg" height="231" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Di dalam object Library, pilih object "Table View" kemudian drag (seret) ke dalam view.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNFZderVPmj7rOib7ckeXJyVmDZShRCAB1BMyUmLiwmp4XasNIAiIN91AsfOp5AA2McOE1VY6JyjRaJEV8sPcNOt6OQSMFX3znlBtYwSr_FiFRNdiTwHJBCBjank9AWf5Y0jat69wF3vQ/s1600/Xcode-Object-Library-Table-View.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNFZderVPmj7rOib7ckeXJyVmDZShRCAB1BMyUmLiwmp4XasNIAiIN91AsfOp5AA2McOE1VY6JyjRaJEV8sPcNOt6OQSMFX3znlBtYwSr_FiFRNdiTwHJBCBjank9AWf5Y0jat69wF3vQ/s320/Xcode-Object-Library-Table-View.jpg" height="242" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Seharusnya tampilan layarnya seperti dibawah ini setelah insert "Table View"</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGaDuZNENS8luJ8Ipb-H1lnuyoqbd6Uuie1WfdI1MaMewpB7iGvVxFzUUekxI1tq47n_f3RxiLt1gjBVBq17OTZiLQWorrHMGI6sokUSYE4jND5ZBN08K0tmVPu4OpX8Ys34h9959LMo/s1600/SimpleTable-Table-View-Added.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPGaDuZNENS8luJ8Ipb-H1lnuyoqbd6Uuie1WfdI1MaMewpB7iGvVxFzUUekxI1tq47n_f3RxiLt1gjBVBq17OTZiLQWorrHMGI6sokUSYE4jND5ZBN08K0tmVPu4OpX8Ys34h9959LMo/s400/SimpleTable-Table-View-Added.jpg" height="296" width="400" /></a></div>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3>
</h3>
<h3 style="text-align: justify;">
Jalankan aplikasi untuk Pertama kali</h3>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Sebelum pindah, coba jalankan aplikasi Anda menggunakan Simulator. Klik tombol "Run" tombol untuk build aplikasi Anda dan mengujinya.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeNXC591zY-9TrnjbL27IZgWmSJjOVDFpkx5NXHCvZ7s8-BtfIT1x0IWPv8dbzVW9FNhLcuYti-Ed7fj4eMy-RbvhRriRGPHNXP1ysYdyDTRmFBWxi5yH5un6PWv6xN0izaXIWNvQkhus/s1600/SimpleTable-Simulator-Empty.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeNXC591zY-9TrnjbL27IZgWmSJjOVDFpkx5NXHCvZ7s8-BtfIT1x0IWPv8dbzVW9FNhLcuYti-Ed7fj4eMy-RbvhRriRGPHNXP1ysYdyDTRmFBWxi5yH5un6PWv6xN0izaXIWNvQkhus/s400/SimpleTable-Simulator-Empty.jpg" height="400" width="205" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Bagaimana? Mudah bukan? Anda sudah berhasil merancang Table View di app. Untuk saat ini aplikasi yang kita sudah buat tidak belum ada data yang ditampilkan. Selanjutnya, kita akan menulis beberapa kode untuk menambahkan data tabel.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Menambahkan Data Tabel</h3>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Kembali ke <span style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px;">Project Navigator</span> dan pilih "SimpleTableViewController.h". tambahkan "<UITableViewDelegate, UITableViewDataSource>" setelah "UIViewController". Kode Anda akan terlihat seperti di bawah ini:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="codecolorer-container objc geshi" style="background-color: #f1f1f1; border: 1px solid rgb(159, 159, 159); font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 1.4em; margin-bottom: 10px; overflow: auto; white-space: nowrap; width: 100%;">
<table cellpadding="1" cellspacing="1" style="border: 1px; font-size: 13px; line-height: 1.4em; text-align: justify;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="line-height: 1.4em; padding: 5px; white-space: nowrap;">
<span style="color: #6e371a; line-height: 1.4em;">#import <UIKit/UIKit.h></span><br />
<br style="line-height: 1.4em;" />
<span style="color: #a61390; line-height: 1.4em;">@interface</span> SimpleTableViewController <span style="color: #002200; line-height: 1.4em;">:</span> UIViewController <UITableViewDelegate, UITableViewDataSource><br />
<br style="line-height: 1.4em;" />
<span style="color: #a61390; line-height: 1.4em;">@end</span></div>
<div>
<span style="color: #a61390; line-height: 1.4em;"><br /></span></div>
</td></tr>
</tbody></table>
</div>
<div class="separator" style="clear: both; text-align: justify;">
"<b>UITableViewDelegate</b>" dan "<b>UITableViewDataSource</b>" dikenal sebagai protokol di Objective-C. Pada dasarnya untuk menampilkan data di <b>Table View</b>, kita harus sesuai dengan persyaratan yang ditetapkan dalam protokol dan menerapkan semua metode wajib.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
UITableViewDelegate dan UITableViewDataSource</h3>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div>
<div style="text-align: justify;">
Sebelumnya, telah ditambahkan protokol "UITableViewDelegate" dan "UITableViewDataSource" dalam file header. Ini mungkin membingungkan bagi Anda. Apakah UITableViewDelegate dan UITableViewDataSource itu?</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
UITableView, merupakan kelas yang sebenarnya yang ada dibalik Table View, dirancang untuk menjadi fleksibel untuk menangani berbagai jenis data. Misalnya anda dapat menampilkan data seperti daftar negara atau nama kontak. Atau seperti contoh ini, kita akan menggunakan tampilan tabel untuk menyajikan daftar resep. Jadi bagaimana Anda tahu bahwa UITableView dapat menampilkan daftar data? UITableViewDataSource adalah jawabannya. Ini ada hubungannya antara data dan tampilan tabel. Protokol UITableViewDataSource protokol dua metode yang diperlukan yaitu (<b>tableView: cellForRowAtIndexPath</b> dan <b>tableView: numberOfRowsInSection</b>). Melalui penerapan metode ini, Anda memberitahukan kepada "<b>Table View</b>" berapa banyak baris untuk menampilkan dan data dalam setiap baris.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div style="text-align: justify;">
Disisi lain ada UITableViewDelegate, ini berkaitan dengan munculnya UITableView. Metode opsional dari protokol memungkinkan Anda mengatur ketinggian baris tabel, mengkonfigurasi judul bagian dan footer, sel tabel re-order, dan lain-lain. Disini saya tidak mengubah salah satu metode ini dalam contoh ini. Mari kita lihat tutorial berikutnya.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Selanjutnya, pilih "<b>SimpleTableViewController.m</b>" dan mendefinisikan variabel misalnya untuk menangani data tabel.</div>
<div style="text-align: justify;">
<br /></div>
<table cellpadding="0" cellspacing="0" style="border: 0px; color: black; font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 18.1875px; text-align: justify; white-space: nowrap;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div 100="" class="objc codecolorer" style="background-color: #f1f1f1; line-height: 1.4em; padding: 5px;" width:="">
<span style="color: #a61390; line-height: 1.4em;">@implementation</span> SimpleTableViewController<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>tableData;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
</td></tr>
</tbody></table>
</div>
<div>
<div style="text-align: justify;">
Dalam Metode "viewDidLoad", tambahkan kode berikut untuk menginisialisasi array "<b>tableData</b>". Disini kita akan menginisialisasi sebuah array dengan daftar resep.</div>
</div>
<div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<table cellpadding="0" cellspacing="0" style="border: 0px; color: black; font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 18.1875px; white-space: wrap;">
<tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="background-color: #f1f1f1; line-height: 1.4em; padding: 5px;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span><span style="color: #a61390; line-height: 1.4em;">void</span><span style="color: #002200; line-height: 1.4em;">)</span>viewDidLoad<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #002200; line-height: 1.4em;">[</span>super viewDidLoad<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #11740a; font-style: italic; line-height: 1.4em;">// Initialize table data</span><br />
tableData <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSArray</span></a> arrayWithObjects<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Egg Benedict"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Mushroom Risotto"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Full Breakfast"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Hamburger"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Egg Sandwich"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Creme Brelee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"White Chocolate Donut"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Starbucks Coffee"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Vegetable Curry"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Instant Noodle with Egg"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Noodle with BBQ Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Japanese Noodle with Pork"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Green Tea"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Thai Shrimp Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Angry Birds Cake"</span>, <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"Ham and Cheese Panini"</span>, <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
</td></tr>
</tbody></table>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Apa itu Array?</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Array adalah struktur data dasar dalam pemrograman komputer. Anda dapat menganggap sebuah array sebagai kumpulan elemen data. Pertimbangkan array tableData dalam kode di atas, itu merupakan kumpulan elemen-elemen tekstual. </div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Setiap elemen array diidentifikasi atau diakses oleh index. Sebuah array dengan 10 elemen akan memiliki indexdari 0 sampai 9. Itu berarti, tableData [0] mengembalikan elemen pertama dari array "tableData".</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Di Objective C, NSArray adalah kelas untuk menciptakan dan mengelola array. Anda dapat menggunakan NSArray untuk membuat array statis yang ukurannya tetap. Jika Anda membutuhkan sebuah array dinamis, gunakan NSMutableArray sebagai gantinya.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
NSArray menawarkan serangkaian factory method untuk membuat objek array. Dalam kode ini, kita menggunakan "arrayWithObjects" untuk instantiate objek NSArray dan preload dengan unsur-unsur tertentu (misalnya Hamburger).</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Anda juga dapat menggunakan metode built-in lain untuk query dan mengelola array. Kemudian, gunakan "count" metode untuk query jumlah elemen data dalam array. Untuk mempelajari lebih lanjut tentang penggunaan NSArray, Anda selalu dapat merujuk ke <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html">Apple’s official document</a>.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Akhirnya, kita harus menambahkan dua method datasource : "<b>tableView: numberOfRowsInSection</b>" dan "<b>tableView: cellForRowAtIndexPath</b>". Kedua method ini merupakan bagian dari protokol <b>UITableViewDataSource</b>. Ini wajib untuk diterapkan metode ketika kita mengkonfigurasi UITableView. Method pertama digunakan untuk menginformasikan view tabel berapa banyak baris dalam bagian (section). Jadi mari kita tambahkan kode di bawah ini. Method "count" hanya mengembalikan jumlah item dalam array "tableData".</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<table cellpadding="0" cellspacing="0" style="border: 0px; color: black; font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 18.1875px; text-align: justify; white-space: nowrap;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="background-color: #f1f1f1; line-height: 1.4em; padding: 5px;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>NSInteger<span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView numberOfRowsInSection<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>NSInteger<span style="color: #002200; line-height: 1.4em;">)</span>section<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #a61390; line-height: 1.4em;">return</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableData count<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Selanjutnya kita terapkan pada metode lain yang diperlukan.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<table cellpadding="0" cellspacing="0" style="border: 0px; color: black; font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 18.1875px; text-align: justify; white-space: nowrap;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="background-color: #f1f1f1; line-height: 1.4em; padding: 5px;">
<span style="color: #002200; line-height: 1.4em;">-</span> <span style="color: #002200; line-height: 1.4em;">(</span>UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span>UITableView <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>tableView cellForRowAtIndexPath<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #002200; line-height: 1.4em;">(</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSIndexPath_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSIndexPath</span></a> <span style="color: #002200; line-height: 1.4em;">*</span><span style="color: #002200; line-height: 1.4em;">)</span>indexPath<br />
<span style="color: #002200; line-height: 1.4em;">{</span><br />
<span style="color: #a61390; line-height: 1.4em;">static</span> <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/" style="color: #ed702b; line-height: 1.4em; text-decoration: none;"><span style="color: #400080; line-height: 1.4em;">NSString</span></a> <span style="color: #002200; line-height: 1.4em;">*</span>simpleTableIdentifier <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"SimpleTableItem"</span>;<br />
<br style="line-height: 1.4em;" />
UITableViewCell <span style="color: #002200; line-height: 1.4em;">*</span>cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableView dequeueReusableCellWithIdentifier<span style="color: #002200; line-height: 1.4em;">:</span>simpleTableIdentifier<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<br style="line-height: 1.4em;" />
<span style="color: #a61390; line-height: 1.4em;">if</span> <span style="color: #002200; line-height: 1.4em;">(</span>cell <span style="color: #002200; line-height: 1.4em;">==</span> <span style="color: #a61390; line-height: 1.4em;">nil</span><span style="color: #002200; line-height: 1.4em;">)</span> <span style="color: #002200; line-height: 1.4em;">{</span><br />
cell <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span><span style="color: #002200; line-height: 1.4em;">[</span>UITableViewCell alloc<span style="color: #002200; line-height: 1.4em;">]</span> initWithStyle<span style="color: #002200; line-height: 1.4em;">:</span>UITableViewCellStyleDefault reuseIdentifier<span style="color: #002200; line-height: 1.4em;">:</span>simpleTableIdentifier<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #002200; line-height: 1.4em;">}</span><br />
<br style="line-height: 1.4em;" />
cell.textLabel.text <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>tableData objectAtIndex<span style="color: #002200; line-height: 1.4em;">:</span>indexPath.row<span style="color: #002200; line-height: 1.4em;">]</span>;<br />
<span style="color: #a61390; line-height: 1.4em;">return</span> cell;<br />
<span style="color: #002200; line-height: 1.4em;">}</span></div>
</td></tr>
</tbody></table>
</div>
<div>
<div style="text-align: justify;">
"<b>cellForRowAtIndexPath</b>" disebut setiap kali ketika sebuah baris tabel akan ditampilkan. Ilustrasi di bawah ini akan memberikan Anda pemahaman yang lebih baik tentang bagaimana <b>UITableView</b> dan <b>UITableDataSource</b> bekerja.</div>
</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Oke, mari kita tekan tombol "Run" tombol dan coba aplikasi Anda! Jika Anda telah menulis kode dengan benar, Simulator harusnya dapat menjalankan aplikasi Anda seperti ini dibawah ini:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgavNNNawGCoUtBtbkSDEs-NqBVFNe-AeNkpC1FLijGxWrfatSFaFj58DSRyOWdTYaBqHTSbmseFeEZeGNzAMg2t4tgLqSexi3OBE-9zBLF32i4dDGHX0OFFQweUDU-uE2JbcKWmO4iekD7/s1600/SimpleTable-Simulator-Empty.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgavNNNawGCoUtBtbkSDEs-NqBVFNe-AeNkpC1FLijGxWrfatSFaFj58DSRyOWdTYaBqHTSbmseFeEZeGNzAMg2t4tgLqSexi3OBE-9zBLF32i4dDGHX0OFFQweUDU-uE2JbcKWmO4iekD7/s400/SimpleTable-Simulator-Empty.jpg" height="400" width="205" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Mengapa masih kosong? Kami sudah menulis kode untuk menghasilkan data tabel dan menerapkan metode yang diperlukan. Tapi mengapa Table View tidak muncul seperti yang diharapkan?</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Masih ada satu langkah lagi.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<h3 style="text-align: justify;">
Menghubungkan DataSource dan Delegate</h3>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Seperti tombol "Hello World" tombol di tutorial sebelumnya, kita harus membuat sambungan antara Table View dan dua method saja kita buat.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Kembali ke "<b>SimpleTableViewController.xib</b>". Tekan dan tahan tombol <b>Control</b> pada keyboard Anda, pilih TableView dan tarik ke "<b>File's Owner</b>". Layar Anda akan terlihat seperti ini:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyBSGLSWG812-HjcnWzGXJGNV4PS9Iyof9KUtzdRPNsYwHPOtbsOTTI3DOsXGhb6ZGlbdKYblN1f9Qa6Cj4cBTO1em8e_BMpH3gygDiSPC4cUWdZIJtQ6wOY637uLhd-CbVyCa6UQIim_P/s1600/SimpleTable-Connect-Data-Source.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyBSGLSWG812-HjcnWzGXJGNV4PS9Iyof9KUtzdRPNsYwHPOtbsOTTI3DOsXGhb6ZGlbdKYblN1f9Qa6Cj4cBTO1em8e_BMpH3gygDiSPC4cUWdZIJtQ6wOY637uLhd-CbVyCa6UQIim_P/s400/SimpleTable-Connect-Data-Source.jpg" height="350" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Menghubungkan TableView dengan DataSource dan Delegate</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Lepaskan kedua tombol dan dengan menunjukkan arah panah antara "DataSource" & "delegate". Pilih "DataSource" untuk membuat connection antara Table View dan DataSource. Ulangi langkah di atas dan membuat koneksi dengan delegate.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0bGA6k24GMSllLmOaVh8piULU1qqEz14-nyHT2bwVvHZw2oQHrevtY2YIAzA0-rV8_1HaLBaAeshrUbRoVgXpgvUPFqooMzvH2414v0X7-cVnRYM5aFHLKmzwDQ1_CIKXYqnIKRZ5ZM66/s1600/SimpleTable-DataSource-Popup.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0bGA6k24GMSllLmOaVh8piULU1qqEz14-nyHT2bwVvHZw2oQHrevtY2YIAzA0-rV8_1HaLBaAeshrUbRoVgXpgvUPFqooMzvH2414v0X7-cVnRYM5aFHLKmzwDQ1_CIKXYqnIKRZ5ZM66/s1600/SimpleTable-DataSource-Popup.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Koneksi antara koneksi dengan delegate</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Itu saja. Untuk memastikan koneksi terhubung dengan benar, Anda dapat memilih Table View lagi. Di bagian atas area Utility, Anda dapat memastikan koneksi yang ada di "Connection Inspector" (yaitu tab paling kanan).</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Hp0GFXshCGRuznnlVj62EEWnQjMzCc1BLghv7_sGOV4jU4IycbCgCZv02mqwDKJ8T_KZsHsVLH9zWVqjWWxttYaVQje2fBbkAUU1JfqkD8H4Ep8IUcA6wgNJ_AcjJ_96f62aTZG8miFt/s1600/SimpleTable-Connector-Outlet.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3Hp0GFXshCGRuznnlVj62EEWnQjMzCc1BLghv7_sGOV4jU4IycbCgCZv02mqwDKJ8T_KZsHsVLH9zWVqjWWxttYaVQje2fBbkAUU1JfqkD8H4Ep8IUcA6wgNJ_AcjJ_96f62aTZG8miFt/s1600/SimpleTable-Connector-Outlet.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
Tampilan Connections Inspector</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Test Aplikasi Anda</div>
<div style="text-align: justify;">
Cukup tekan tombol "Run" tombol dan jalankan Simulator aplikasi Anda:</div>
<div style="text-align: justify;">
<br /></div>
</div>
<div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu1VnhJt4p1VSLFXjfzydmlmawQzEpuSXrJiQG09NbDIMhDdUgJokj6Brh8ocNGmMoKR9QWPpWMepMwGoOqXbt5PkM3w3CqoMWoG6LalKsLvGiJEtoheOaQdsf1FsvEQUTEOwnxCql95zx/s1600/SimpleTable-App.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu1VnhJt4p1VSLFXjfzydmlmawQzEpuSXrJiQG09NbDIMhDdUgJokj6Brh8ocNGmMoKR9QWPpWMepMwGoOqXbt5PkM3w3CqoMWoG6LalKsLvGiJEtoheOaQdsf1FsvEQUTEOwnxCql95zx/s400/SimpleTable-App.jpg" height="400" width="205" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Menambahkan Thumbnail ke TableView</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Tampilan tabel terlalu polos, kan? Bagaimana menambahkan gambar ke setiap baris? IOS SDK membuatnya sangat mudah untuk melakukan hal ini. Anda hanya perlu menambahkan baris kode untuk memasukkan thumbnail untuk setiap baris.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Pertama, download sampel gambar ini. Atau, Anda dapat menggunakan gambar Anda sendiri tetapi pastikan Anda nama itu "creme_brulee.jpg". Dalam Proyek Navigator, klik kanan "SimplyTable" folder dan pilih "Add File ke SimpleTable ...".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcaJ0BSKocLAZeSWAXeIeRnWt9APBg63M5maoxeks_xy_BJWoReZWIQiusonlagQJHQHXawpEH0VP2zEk815k38_Etwe6Hx7A6rwFge_hiTh-0WlAaOtau5aHISv0qahCvE8W0ppOPzdq_/s1600/SimpleTable-Add-File.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcaJ0BSKocLAZeSWAXeIeRnWt9APBg63M5maoxeks_xy_BJWoReZWIQiusonlagQJHQHXawpEH0VP2zEk815k38_Etwe6Hx7A6rwFge_hiTh-0WlAaOtau5aHISv0qahCvE8W0ppOPzdq_/s400/SimpleTable-Add-File.jpg" height="400" width="391" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Pilih file gambar dan periksa kotak centang "<span style="color: #333333; font-family: Lora, serif; font-size: 16px; line-height: 25px;">Copy items to destination group’s folder</span>". Klik "OK" untuk menambahkan file.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPuUuvWaOIaqGItby9o4Zwghc_rGNzS0Aw_y6xh_yv5kcc_UV1GgFIagZ5Li5C9fIz3AQX-75jySJgfaEHPL0tEujqirI_J4zGN3w3MF6mo6KHzRiYrs0I2vT21PZ7xsMi-4tktXT4XgMb/s1600/SimpleTable-Add-File-Dialog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPuUuvWaOIaqGItby9o4Zwghc_rGNzS0Aw_y6xh_yv5kcc_UV1GgFIagZ5Li5C9fIz3AQX-75jySJgfaEHPL0tEujqirI_J4zGN3w3MF6mo6KHzRiYrs0I2vT21PZ7xsMi-4tktXT4XgMb/s400/SimpleTable-Add-File-Dialog.jpg" height="391" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Sekarang edit "<b>SimpleTableViewController.m</b>" dan tambahkan baris kode berikut di "<b>tableView: cellForRowAtIndexPath</b>" metode:</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<table cellpadding="0" cellspacing="0" style="border: 0px; color: black; font-family: Monaco, 'Lucida Console', monospace; font-size: 13px; line-height: 18.1875px; text-align: justify; white-space: nowrap;"><tbody style="line-height: 1.4em;">
<tr style="line-height: 1.4em;"><td class="line-numbers" style="background-color: #eeeeee; border-right-color: rgb(159, 159, 159); border-right-style: solid; border-width: 0px 1px 0px 0px; color: #888888; line-height: 1.4em; margin: 0px; padding: 5px; text-align: right;"><div style="line-height: 1.4em; width: 23px;">
1</div>
</td><td style="border: 0px; line-height: 1.4em; margin: 0px; padding: 0px;"><div class="objc codecolorer" style="background-color: #f1f1f1; line-height: 1.4em; padding: 5px;">
cell.imageView.image <span style="color: #002200; line-height: 1.4em;">=</span> <span style="color: #002200; line-height: 1.4em;">[</span>UIImage imageNamed<span style="color: #002200; line-height: 1.4em;">:</span><span style="color: #bf1d1a; line-height: 1.4em;">@</span><span style="color: #bf1d1a; line-height: 1.4em;">"creme_brelee.jpg"</span><span style="color: #002200; line-height: 1.4em;">]</span>;</div>
</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Kode Anda akan terlihat seperti ini setelah mengedit:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpTkmoYmEnCNl8f3bcwhmfCCv6_3Jo4dDaVU6UVu6KBxOX-9ZGxEYcXwjEG4t4yTOgbTScsDGUwlfqmUIs_FdPmjm31IipYRtbzDrQWLvFJbk9wfJU3OjN188vgtauKhlELzaeGK_hG7Km/s1600/SimpleTable-Image-Code.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpTkmoYmEnCNl8f3bcwhmfCCv6_3Jo4dDaVU6UVu6KBxOX-9ZGxEYcXwjEG4t4yTOgbTScsDGUwlfqmUIs_FdPmjm31IipYRtbzDrQWLvFJbk9wfJU3OjN188vgtauKhlELzaeGK_hG7Km/s640/SimpleTable-Image-Code.jpg" height="185" width="640" /></a></div>
<div style="text-align: center;">
<div style="text-align: justify;">
Pilih file gambar dan tambahkan ke dalam project</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: left;">
<div style="text-align: justify;">
Baris kode diatas akan meload gambar dan menyimpan di area gambar sel tabel. Sekarang, klik kembai tombol "Run" selanjutnya aplikasi SimpleTable Anda harus menampilkan gambar dalam setiap baris.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Apa selanjutnya?</div>
<div class="separator" style="clear: both; text-align: justify;">
Toturial diatas adalah cara yang paling sederhana untuk membuat tampilan tabel. TabelView adalah salah satu elemen yang paling umum digunakan dalam pemrograman iOS. Jika Anda telah mengikuti tutorial dan membangun aplikasi, Anda harus memiliki gagasan dasar tentang cara membuat tampilan tabel. </div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
</div>
</div>
<div style="text-align: justify;">
<br /></div>
</div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0tag:blogger.com,1999:blog-6834479963228415759.post-84786175965598283962013-05-29T14:39:00.000+07:002013-05-29T14:39:33.358+07:00Objective C: Error Pada Bagian Thread 1 Program Received Signal SIGABRT<br />
<div class="separator" style="clear: both;">
Pada saat saya belajar iOS saya menemukan error ketika diklik tanda (+) maka muncul error pada gambar dibawah ini:</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJwI4gXssSCvG8Wlf26HDXUw9OBBe-1QY9XWj9_4MlORVsf7ctytllmpwJJ_4Sa8_dt8TMr-OhOzPgUtwOol12D2m1u1nE7UZ7eSrngo3zezk-XHLR39wjs7Y-eqLMOlyyXysR-BRyStIZ/s1600/Screen+Shot+2013-05-24+at+15.13.22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJwI4gXssSCvG8Wlf26HDXUw9OBBe-1QY9XWj9_4MlORVsf7ctytllmpwJJ_4Sa8_dt8TMr-OhOzPgUtwOol12D2m1u1nE7UZ7eSrngo3zezk-XHLR39wjs7Y-eqLMOlyyXysR-BRyStIZ/s400/Screen+Shot+2013-05-24+at+15.13.22.png" width="206" /></a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Berikut tampilan errornya:</div>
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1T59UWTdy6r44B7UzsjGFY_Abt_9dj7WY1RMU1ctNH17BdSfJebZ-AQy3IVzxdQN4oXC-x5cl1g_V_1z9U2LhCBFCV2jmv0dk6KF0qtzzaPXgIXZB4sWApKmYmTKW8Lu_EyMK9aYiFJI9/s1600/Screen+Shot+2013-05-24+at+15.17.35.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1T59UWTdy6r44B7UzsjGFY_Abt_9dj7WY1RMU1ctNH17BdSfJebZ-AQy3IVzxdQN4oXC-x5cl1g_V_1z9U2LhCBFCV2jmv0dk6KF0qtzzaPXgIXZB4sWApKmYmTKW8Lu_EyMK9aYiFJI9/s400/Screen+Shot+2013-05-24+at+15.17.35.png" width="400" /></a></div>
<a name='more'></a><br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Saya periksa juga outputnya: </div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="p1">
2013-05-24 15:17:15.661 ScaryBugs[1055:c07] *** <b>Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2380.17/UITableView.m:4460</b></div>
<div class="p1">
<b>2013-05-24 15:17:15.663 ScaryBugs[1055:c07]</b> *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'</div>
<div class="p1">
*** First throw call stack:</div>
<div class="p1">
(0x1c94012 0x10d1e7e 0x1c93e78 0xb67665 0xc76c4 0x26c8 0xd08fb 0xd09cf 0x275f30 0x2807e2 0xbb016 0xb7617 0xc41f6 0xc4235 0x252b 0x10e5705 0x192c0 0x255a64 0x10e5705 0x192c0 0x19258 0xda021 0xda57f 0xd96e8 0x48cef 0x48f02 0x26d4a 0x18698 0x1befdf9 0x1befad0 0x1c09bf5 0x1c09962 0x1c3abb6 0x1c39f44 0x1c39e1b 0x1bee7e3 0x1bee668 0x15ffc 0x1e5d 0x1d85 0x1)</div>
<div class="p1">
libc++abi.dylib: terminate called throwing an exception</div>
<div class="separator" style="clear: both;">
</div>
<div class="p2">
(lldb) </div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Penyebabnya adalah:</div>
<div class="separator" style="clear: both;">
Saya pikir kesalahan ini saya tidak mendaftarkan <b>nib</b> atau sebuah <b>class</b> untuk sebuah <b>identifier</b>.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Sehingga saya dapat menyimpan apa yang saya lakukan di <b>tableView</b>: fungsi <b>cellForRowAtIndexPath</b> kemudian saya tambahkan kode ke <b>viewDidLoad</b> :</div>
<div class="separator" style="clear: both;">
<br /></div>
<pre class="default prettyprint prettyprinted" style="background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto;"><code style="border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;"><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">[</span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">self</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">.</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">tableView registerClass</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:[</span><span class="typ" style="background-color: transparent; border: 0px; color: #2b91af; margin: 0px; padding: 0px; vertical-align: baseline;">UITableViewCell</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> </span><span class="kwd" style="background-color: transparent; border: 0px; color: darkblue; margin: 0px; padding: 0px; vertical-align: baseline;">class</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">]</span><span class="pln" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;"> forCellReuseIdentifier</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">:@</span><span class="str" style="background-color: transparent; border: 0px; color: maroon; margin: 0px; padding: 0px; vertical-align: baseline;">"Cell"</span><span class="pun" style="background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;">];</span></code></pre>
Solusinya:<br />
<div>
Saya pilih <b>storyboard</b> kemudian pilih <b>Master View Controller</b> </div>
<div>
<br />
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9W_S-JlsB5dyoVrlbuE2wqZhOmMbnyK3KT75E5fHNFNaNoPnQudqtd0_h50OdDSviJ5slnaDeAWITmrnFeHppyBOp4BXLpiBSw3Pc0Q4EKOId4GH1kzYDzDfB1TzhtZJ5eSTo6RgsB_q3/s1600/Screen+Shot+2013-05-24+at+15.48.16.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9W_S-JlsB5dyoVrlbuE2wqZhOmMbnyK3KT75E5fHNFNaNoPnQudqtd0_h50OdDSviJ5slnaDeAWITmrnFeHppyBOp4BXLpiBSw3Pc0Q4EKOId4GH1kzYDzDfB1TzhtZJ5eSTo6RgsB_q3/s400/Screen+Shot+2013-05-24+at+15.48.16.png" width="400" /></a></div>
<div>
<br />
<div>
Pastikan identifier misalnya "MyBasicCell" seperti berikut ini:</div>
<div>
<br />
<div>
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicT3MOQQxKjr03e7BeawcXaOlGWnG-KT17JLN7QhuUdwPI8QkXgFmHHi6NEP1yFJVIH9I7pFXRTvVpYXDp_kQiQ6yZenrBXWGeRkSBqFckJatWgH-Q6t1DWbUMbE9tzdzo8goJXS3yGnwQ/s1600/Screen+Shot+2013-05-24+at+15.43.06.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicT3MOQQxKjr03e7BeawcXaOlGWnG-KT17JLN7QhuUdwPI8QkXgFmHHi6NEP1yFJVIH9I7pFXRTvVpYXDp_kQiQ6yZenrBXWGeRkSBqFckJatWgH-Q6t1DWbUMbE9tzdzo8goJXS3yGnwQ/s1600/Screen+Shot+2013-05-24+at+15.43.06.png" /></a></div>
</div>
<div>
<br /></div>
<div>
harus sama nama identifiernya dengan yang ada di <b>dequequeReusableCellWithIdentifier</b>.<br />
<div class="separator" style="clear: both;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi85V5WIKUNwNnrD2dG2MCpabZeHyU3ZzfdoEsbBZt7_zOtbfWkk2JvWArEdOR0HwPAGku-rfpjE7AzYlVz-H7q3PFcFB9asJMUjAgqGIJLeM3PnnU8pFg4ei0BV6iNVkIfI5gTpLA4XnrH/s1600/Screen+Shot+2013-05-24+at+15.43.22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="46" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi85V5WIKUNwNnrD2dG2MCpabZeHyU3ZzfdoEsbBZt7_zOtbfWkk2JvWArEdOR0HwPAGku-rfpjE7AzYlVz-H7q3PFcFB9asJMUjAgqGIJLeM3PnnU8pFg4ei0BV6iNVkIfI5gTpLA4XnrH/s400/Screen+Shot+2013-05-24+at+15.43.22.png" width="400" /></a></div>
</div>
<div>
<br /></div>
<div>
<br />
<div>
<br /></div>
<div>
</div>
</div>
</div>
</div>
</div>
Admin PortalDosenhttp://www.blogger.com/profile/03664958943592614457noreply@blogger.com0