<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog d&#039;un développeur multi-support &#187; objective c</title>
	<atom:link href="http://www.oni-ecchi.info/blog/tag/objective-c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.oni-ecchi.info/blog</link>
	<description>[DIM] pour les intimes :)</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:51:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Iphone &amp; UITableView &amp; UISearchBar</title>
		<link>http://www.oni-ecchi.info/blog/iphone/iphone-uitableview-uisearchbar.html</link>
		<comments>http://www.oni-ecchi.info/blog/iphone/iphone-uitableview-uisearchbar.html#comments</comments>
		<pubDate>Sun, 14 Feb 2010 10:50:44 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[astuce]]></category>
		<category><![CDATA[découverte]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[tutoriel]]></category>
		<category><![CDATA[UISearchBar]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=514</guid>
		<description><![CDATA[Bonjour, je recommence à développer sur iphone après quelques mois d&#8217;arrêt, j&#8217;en profite aussi pour tester l&#8217;Ipad (sur simulateur :p). Cette semaine j&#8217;ai cherché à faire fonctionner une UISearchBar avec le controller qui va bien et j&#8217;ai eu quelque souci. Si techniquement c&#8217;est assez simple à mettre en place, graphiquement j&#8217;ai eu quelque souci. Mon [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour, je recommence à développer sur <a href="http://www.oni-ecchi.info/blog/tag/iphone" class="st_tag internal_tag" rel="tag" title="Voir les articles classés avec iPhone">iphone</a> après quelques mois  d&#8217;arrêt, j&#8217;en profite aussi pour tester l&#8217;Ipad (sur simulateur :p).</p>
<p>Cette  semaine j&#8217;ai cherché à faire fonctionner une UISearchBar avec le  controller qui va bien et j&#8217;ai eu quelque souci. Si techniquement c&#8217;est  assez simple à mettre en place, graphiquement j&#8217;ai eu quelque souci.</p>
<h3>Mon architecture :</h3>
<p>Mon application a une UITabBar, puis sur une des sous vue j&#8217;ai une  liste de résultat avec la SearchBar. Cet écran n&#8217;est pas  directement  une UITableView, c&#8217;est un navigation controller qui contient une UITableView.</p>
<p><img src="http://www.oni-ecchi.info/blog/wp-content/uploads/2010/02/Capture-decran-2010-02-14-a`-09.15.34.png" alt="Mon archi" border="0" width="480" height="128" /></p>
<p>Ma UITableView est crée directement en code et est à hauteur fixe, et mes cellules ont une hauteur de 60:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p514code4'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5144"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p514code4"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>viewDidLoad <span style="color: #009900;">&#123;</span>  
	CGRect frame <span style="color: #339933;">=</span> CGRectMake<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">75</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">320</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">262</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// Initialise une table view.</span>
	myTableView <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>UITableView alloc<span style="color: #009900;">&#93;</span> initWithFrame<span style="color: #339933;">:</span>frame<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	myTableView.<span style="color: #202020;">rowHeight</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">60</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Ajout la tableView à l'écran et autres par la suite</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h4> Mes soucis </h4>
<p>?Les soucis viennent quand j&#8217;utilise la barre de recherche:</p>
<ul>
<li>
		Les cellules sont bien réutilisées mais la hauteur est celle par défaut du coup tout mes items sont mal 		placés. Joli bug graphique.
	</li>
<li>
		Mes résultats sont bien filtrés, mais il est impossible de scroller. La liste revient toujours en haut. Comme si ma liste avait une hauteur tellement grande que le scroll était inefficace.
	</li>
</ul>
<h4> Solutions</h4>
<p>Bon, j&#8217;en suis pas vraiment fier, ça tient plus de hooks qu&#8217;autres choses mais ça a le mérite de marcher et ça n&#8217;a pas l&#8217;air trop lourd en terme de performance sur mon 3GS.</p>
<p>En fait c&#8217;est simple, à chaque fois il faut refixer les hauteurs au moment oppertun.</p>
<ul>
<li> Pour les cellules, c&#8217;est à leur initialisation :

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p514code5'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5145"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p514code5"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>CGFloat<span style="color: #009900;">&#41;</span> tableView<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>UITableView <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> tableView heightForRowAtIndexPath<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>NSIndexPath <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> indexPath
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">60</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
<li>
		Pour la liste, c&#8217;est quand on lance une recherche :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p514code6'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p5146"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p514code6"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>filterContentForSearchText<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>searchText scope<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSString<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>scope
<span style="color: #009900;">&#123;</span>
	CGRect frame <span style="color: #339933;">=</span> CGRectMake<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">75</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">320</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">262</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>self searchDisplayController<span style="color: #009900;">&#93;</span> searchResultsTableView<span style="color: #009900;">&#93;</span> setFrame<span style="color: #339933;">:</span>frame<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// faire sa recherche ensuite</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</li>
</ul>
<p>Donc en terme de performance y doit y avoir moyen de fixer ses tailles une fois pour toute mais je n&#8217;ai pas trouvé comment. Si quelqu&#8217;un a la solution je suis preneur.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/iphone/iphone-uitableview-uisearchbar.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone &amp; Delegate</title>
		<link>http://www.oni-ecchi.info/blog/iphone/iphone-delegate.html</link>
		<comments>http://www.oni-ecchi.info/blog/iphone/iphone-delegate.html#comments</comments>
		<pubDate>Mon, 06 Apr 2009 16:21:10 +0000</pubDate>
		<dc:creator>Guillaume chave</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[classe]]></category>
		<category><![CDATA[delegate]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[protocol]]></category>

		<guid isPermaLink="false">http://www.oni-ecchi.info/blog/?p=323</guid>
		<description><![CDATA[Bonjour, Voici juste un petit &#171;&#160;How to&#160;&#187; pour comprendre et jour avec les delegate sur cocoa. Admettons vous avez une classe &#171;&#160;ListingController&#160;&#187; qui hérite d&#8217;une UIViewController qui gère une liste d&#8217;élément et que vous avez une classe &#171;&#160;DetailController&#160;&#187; qui hérite aussi d&#8217;une UIViewController mais qui donne le detail de l&#8217;élément cliqué. Vous voulez que lorsqu&#8217;on [...]]]></description>
			<content:encoded><![CDATA[<p>Bonjour,</p>
<p>Voici juste un petit &laquo;&nbsp;How to&nbsp;&raquo; pour comprendre et jour avec les <a href="http://www.oni-ecchi.info/blog/tag/delegate" class="st_tag internal_tag" rel="tag" title="Voir les articles classés avec delegate">delegate</a> sur cocoa.</p>
<p>Admettons vous avez une classe &laquo;&nbsp;ListingController&nbsp;&raquo; qui hérite d&#8217;une UIViewController qui gère une liste d&#8217;élément et que vous avez une classe &laquo;&nbsp;DetailController&nbsp;&raquo; qui hérite aussi d&#8217;une UIViewController mais qui donne le detail de l&#8217;élément cliqué.</p>
<p>Vous voulez que lorsqu&#8217;on click sur un bouton posé sur la vue Détail revenir à la liste principal, puis la recharger. Revenir à la vue principal est assez simple il suffit de crée une méthode &laquo;&nbsp;IBAction&nbsp;&raquo; dans le controller Detail, liée le bouton à cette méthode via Interface builder puis écrire  :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code15'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32315"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p323code15"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>goHome <span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#91;</span>self.<span style="color: #202020;">view</span> removeFromSuperview<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Et le tour est joué mais bon, la liste n&#8217;est pas rechargé pour autant et il n&#8217;y a pas eu la levé d&#8217;un évènement pour la classe &laquo;&nbsp;Liste&nbsp;&raquo;. C&#8217;est là que les delegate peuvent nous être utile.</p>
<blockquote><p>Le principe est de définir des méthodes sur la classe de Detail puis les appeller/utiliser lors du click mais c&#8217;est la classe Liste qui les implémentera effectivement.</p>
</blockquote>
<p>Voici la marche à suivre :</p>
<ol>
<li>Dans la classe Detail : Définir une ou plusieurs méthodes dite &laquo;&nbsp;delegate&nbsp;&raquo; qui devront être implémenter. On appelle ce genre de déclaration un &laquo;&nbsp;protocole&nbsp;&raquo;.</li>
<li>Dans la classe Detail : Définir une propriété de classe de type &laquo;&nbsp;id&nbsp;&raquo; qui utilise le protocole. Cette propriété représente un lien vers la classe &laquo;&nbsp;parente&nbsp;&raquo; qui implémentera effectivement notre protocole.</li>
<li>Dans la classe Detail : Appeller lors du click les méthodes &laquo;&nbsp;delegate&nbsp;&raquo; sur notre protocole.</li>
<li>Dans la classe Liste : Implémenter les méthodes delegate dans notre classe &laquo;&nbsp;parente&nbsp;&raquo;.</li>
</ol>
<h3>Etape 1 :</h3>
<p>Dans le fichier &laquo;&nbsp;DetailController.h&nbsp;&raquo;, <strong>juste après</strong> les #import <strong>et avant </strong>@interface DetailController : UIViewController { } :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code16'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32316"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p323code16"><pre class="c" style="font-family:monospace;">@protocol DetailControllerDelegate
@required
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>RetourListe<span style="color: #339933;">;</span>
@end</pre></td></tr></table></div>

<h3>Etape 2 :</h3>
<p>Toujours dans le fichier &laquo;&nbsp;DetailController.h&nbsp;&raquo;, après &laquo;&nbsp;@interface DetailController : UIViewController {&nbsp;&raquo; nous définissons une propriété que nous appellerons &laquo;&nbsp;delegate&nbsp;&raquo; :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code17'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32317"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p323code17"><pre class="c" style="font-family:monospace;">id delegate<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>puis après l&#8217;accolade définissant l&#8217;interface :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code18'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32318"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p323code18"><pre class="c" style="font-family:monospace;">@property <span style="color: #009900;">&#40;</span>nonatomic<span style="color: #339933;">,</span>assign<span style="color: #009900;">&#41;</span> id <span style="color: #339933;">&lt;</span> DetailControllerDelegate <span style="color: #339933;">&gt;</span> delegate<span style="color: #339933;">;</span>
&nbsp;
@end</pre></td></tr></table></div>

<p>Notre propriété &laquo;&nbsp;delegate&nbsp;&raquo; est de type &laquo;&nbsp;id&nbsp;&raquo; mais &laquo;&nbsp;implémente&nbsp;&raquo; le protocole précédement utilisé.</p>
<h3>Etape 3 :</h3>
<p>Nous avons définit une propriété dans le fichier &laquo;&nbsp;.h&nbsp;&raquo;, il faut maintenant s&#8217;en servir dans notre fichier &laquo;&nbsp;DetailController<strong>.m</strong>&nbsp;&raquo; :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code19'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32319"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p323code19"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#import &quot;DetailController.h&quot;</span>
@implementation DetailController
@synthesize delegate<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//synthetisé une propriété signifie que le sdk créera les getters/setters pour nous</span>
<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>IBAction<span style="color: #009900;">&#41;</span>goHome
<span style="color: #009900;">&#123;</span>
	NSLog<span style="color: #009900;">&#40;</span>@<span style="color: #ff0000;">&quot;Go home Liste&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#91;</span>self.<span style="color: #202020;">delegate</span> RetourListe<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// dispatch l'évènement à la classe parente.</span>
	<span style="color: #009900;">&#91;</span>self.<span style="color: #202020;">view</span> removeFromSuperview<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// supprime la vue courante</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>C&#8217;est fini pour notre classe Detail  ! Vous remarquerez qu&#8217;à aucun moment il n&#8217;y a de lien vers la classe &laquo;&nbsp;Liste&nbsp;&raquo;. Le couplage est donc très faible entre ces classes. Ce principe de couplage faible est assez puissant si on y réfléchi à deux fois vu que nos classes sont, de fait, totalement indépendantes vis à vis de leur &laquo;&nbsp;parent&nbsp;&raquo; (ou du contexte d&#8217;execution pour être plus bien parlant). Bon bref ça c&#8217;était le coup de pub raté pour la puissance du modèle objet.</p>
<h3>Etape 4</h3>
<p>Implémentons les méthodes ! Dans le fichier &laquo;&nbsp;ListingController.h&nbsp;&raquo; nous déclarons notre interface comme ceci :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code20'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32320"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p323code20"><pre class="c" style="font-family:monospace;">@interface ListingController <span style="color: #339933;">:</span> UIViewController <span style="color: #339933;">&lt;</span> DetailControllerDelegate <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// some code</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Et dans notre fichier &laquo;&nbsp;ListingController.m&nbsp;&raquo; il suffit d&#8217;implémenter la méthode &laquo;&nbsp;RetourListe&nbsp;&raquo;. Surtout, ne pas la déclarer dans l&#8217;interface (le fichier .h) sinon le programme se mélangera les pinceaux ! (Oui, vous utilisez deux méthodes avec le même nom ayant des portés différentes ..)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code21'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32321"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p323code21"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>RetourListe
<span style="color: #009900;">&#123;</span>
    NSLog<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;coucou&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// some code</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><b>Edit</b> : Oups, erreur. On crée la méthode mais à un aucun moment on dit que notre classe Listing va implémenter les méthodes de detail hormis dans la déclaration (fichier.h). Il faut donc qu&#8217;à notre objet &laquo;&nbsp;DetailController&nbsp;&raquo;, juste après qu&#8217;il soit instanciée, au moment du click par exemple faire un :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p323code22'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p32322"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p323code22"><pre class="c" style="font-family:monospace;">DetailController<span style="color: #339933;">*</span>myView <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#91;</span>DetailControlleralloc<span style="color: #009900;">&#93;</span> initWithNibName<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;DetailView&quot;</span> bundle<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>NSBundle mainBundle<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
myView.<span style="color: #202020;">delegate</span> <span style="color: #339933;">=</span> self<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p> On définit que c&#8217;est la classe Listing (self) va implémenter les méthodes delegate de détail.</p>
<p>Et voilà, normallement ça doit marcher.</p>
<p>Ce &laquo;&nbsp;How to&nbsp;&raquo; a été écrit à partir d&#8217;un projet personnel, je ne pourrais donc pas donnée des sources qui utilisent ce concept. A l&#8217;heure où j&#8217;écrit ce billet je n&#8217;ai pas de Mac à ma disposition.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oni-ecchi.info/blog/iphone/iphone-delegate.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

