<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Samer's Development Blog</title>
        <link>http://geekswithblogs.net/samerpaul/Default.aspx</link>
        <description>Development Blog for C#, .NET and Obj-C</description>
        <language>en-US</language>
        <copyright>samerpaul</copyright>
        <managingEditor>samer@capparsa.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <image>
            <title>Samer's Development Blog</title>
            <url>http://geekswithblogs.net/images/RSS2Image.gif</url>
            <link>http://geekswithblogs.net/samerpaul/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <item>
            <title>Putting Game logic in a plist file</title>
            <category>ios development</category>
            <category>iOS games</category>
            <category>cocos2d</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2013/06/01/putting-game-logic-in-a-plist-file.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2013/06/01/putting-game-logic-in-a-plist-file.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2013/06/01/putting-game-logic-in-a-plist-file.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Since "Doodle Fighter" (working title) is the first game I've ever worked on, a lot of the code started off as you might expect: tons of things cobbled together, none of it properly encapsulated, and a lot of it hard coded. &lt;/p&gt;
&lt;p&gt;The last week I've been focused on pulling a lot of this data out and I decided that one thing I wanted to do (after reading that others recommended doing this) is put a lot of the game logic and design choices into a plist that comes loaded with the app. This lets me do a couple of cool things:&lt;/p&gt;
&lt;p&gt;1. It lets me create different plists for shipping, testing, and experimental versions of the game without changing a single line of code.&lt;/p&gt;
&lt;p&gt;2. It lets me tweak game settings quickly. In fact, depending on how motivated you are, you can program the game to live-update settings without doing a rebuild of your code. For example, every time you un-pause (in testing mode), your app could re-read the plist and get the updated values. That gives you great testing speed and power to tweak all those details that will make or break your game.&lt;/p&gt;
&lt;p&gt;The actual code to read a plist is trivial stuff:&lt;/p&gt;
&lt;p&gt;NSBundle *bundle = [NSBundle mainBundle];&lt;br /&gt; NSString *plistPath = [bundle pathForResource:@"GameDesignInformation" ofType:@"plist"];&lt;br /&gt; &lt;br /&gt; NSDictionary *plistDictionary = [NSDictionary dictionaryWithContentsOfFile:plistPath];&lt;/p&gt;
&lt;p&gt;Then you can enumerate the dictionary using blocks:&lt;/p&gt;
&lt;p&gt;    [plistDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { &lt;br /&gt;// Do things here&lt;/p&gt;
&lt;p&gt;}];&lt;/p&gt;
&lt;p&gt;How you decide to design your plist is up to you. I created a few arrays for ship types, levels, and then a dictionary defining general game modifiers. I read them into a singleton called LevelManager that stores them in memory while the app is open, so that I don't have to constantly read off the disk. &lt;/p&gt;
&lt;p&gt;When I started with this plist, I first used it to create the game modifiers dictionary as well as a basic array of enemy ship types. Then I expanded it to include things like starting default values, costs for upgrades for my ships, developer only things (like putting on invincibility mode), and other useful testing things like multipliers on speed of enemies, laser firings, and so on. &lt;/p&gt;
&lt;p&gt;It was several hours of doing this work, but because of that I can tweak and modify my game with great ease now!&lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/153032.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2013/06/01/putting-game-logic-in-a-plist-file.aspx</guid>
            <pubDate>Sat, 01 Jun 2013 23:22:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/153032.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2013/06/01/putting-game-logic-in-a-plist-file.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/153032.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/153032.aspx</trackback:ping>
        </item>
        <item>
            <title>My Doodle iPhone Game: Part 1</title>
            <category>cocos2d</category>
            <category>iphone</category>
            <category>ios development</category>
            <category>iOS games</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2013/05/30/my-doodle-iphone-game-part-1.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2013/05/30/my-doodle-iphone-game-part-1.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2013/05/30/my-doodle-iphone-game-part-1.aspx&lt;/a&gt;&lt;/p&gt;&lt;p style="text-align: left;"&gt;I've been working on developing my first iPhone game for a couple of months now but recently I've been able to commit more time to coding it, since I finished school earlier this month. In short, the game is like Galaga, but it's with doodle graphics and includes the ability to upgrade your ship throughout the levels.&lt;/p&gt;
&lt;p&gt;The idea will be that your ship is a fighter escorting a delivery freighter through the "doodle space zone". Every delivery will take longer than the last and become more treacherous. You earn money with each delivery (naturally) which you can spend to upgrade your ship's defenses/offenses.&lt;/p&gt;
&lt;p&gt;Coding a game has been something I've wanted to do since I first starting working on iOS several years ago. I started with a few Cocos tutorials (located at &lt;a href="http://www.raywenderlich.com/tutorials"&gt;http://www.raywenderlich.com/tutorials&lt;/a&gt; ) and then decided it was time to just start creating something. I sketched out a ton of ideas but settled on a fun space shooter game that included RPG elements. I've always enjoyed games that let me change my player in some way throughout the game, so that as I got better and got to harder levels, I could have a better character to deal with the challenge (and something to show for it).&lt;/p&gt;
&lt;p&gt;Right now, you can upgrade the ship's shield, regen time (since the shield regenerates through time), and its weapon systems. It's been so much fun coding this game and has been such a huge challenge too. I felt like I was starting to learn how to code all over again working in game development and design, vs. all the work I've done doing productivity based apps.&lt;/p&gt;
&lt;p&gt;If this game works out, I'm going to be hard pressed to not continue working on games exclusively!&lt;/p&gt;
&lt;p&gt;I'm going to be blogging about some of the technical things I've learned as well as the general lessons learned from learning how to code games using Cocos2d. &lt;/p&gt;
&lt;p&gt;Here's a screenshot of the game right now (yes, it says 0HP, but since it's in testing ,the ship is invincible right now :) )&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" title="Doodle space shooter game.png" src="https://gwb.blob.core.windows.net/samerpaul/Doodle space shooter game.png" alt="DoodleSpaceShooterGame" width="320" height="480" border="0" /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/153017.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2013/05/30/my-doodle-iphone-game-part-1.aspx</guid>
            <pubDate>Fri, 31 May 2013 01:56:46 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/153017.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2013/05/30/my-doodle-iphone-game-part-1.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/153017.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/153017.aspx</trackback:ping>
        </item>
        <item>
            <title>Migrating Core Data to new UIManagedDocument in iOS 5</title>
            <category>Tutorials</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2012/06/05/migrating-core-data-to-new-uimanageddocument-in-ios-5.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2012/06/05/migrating-core-data-to-new-uimanageddocument-in-ios-5.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2012/06/05/migrating-core-data-to-new-uimanageddocument-in-ios-5.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I have an app that has been on the store since iOS 3.1, so there is a large install base out there that still uses Core Data loaded up in my AppDelegate. In the most recent set of updates, I raised the minimum version to 4.3 but still kept the same way of loading the data. Recently, I decided it's time to make the minimum version 5.1 (especially with 6 around the corner), so I wanted to start using the new fancy UIManagedDocument way of using Core Data.&lt;/p&gt;
&lt;p&gt;The issue with this though is that the old database file is still sitting in the iOS app, so there is no migrating to the new document. You have to basically subclass UIManagedDocument with a new model class, and override a couple of methods to do it for you. Here's a tutorial on what I did for my app &lt;a href="http://itunes.apple.com/us/app/timetag/id386891007?mt=8"&gt;TimeTag&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt; &lt;strong&gt;Step One: Add a new class file in Xcode and subclass "UIManagedDocument"&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Go ahead and also add a method to get the managedObjectModel out of this class. It should look like:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #7041a7;"&gt;&lt;span style="color: #892462;"&gt;@interface&lt;/span&gt;&lt;span style="color: #000000;"&gt; TimeTagModel : &lt;/span&gt;UIManagedDocument&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;- (&lt;span style="color: #7041a7;"&gt;NSManagedObjectModel&lt;/span&gt; *)managedObjectModel;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #892462;"&gt;@end&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #892462;"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Step two: Writing the methods in the implementation file (.m)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I first added a shortcut method for the applicationsDocumentDirectory, which returns the URL of the app directory. &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;- (&lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt; *)applicationDocumentsDirectory&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #892462;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; [[[&lt;/span&gt;&lt;span style="color: #7041a7;"&gt;NSFileManager&lt;/span&gt;defaultManager&lt;span style="color: #000000;"&gt;] &lt;/span&gt;URLsForDirectory&lt;span style="color: #000000;"&gt;:&lt;/span&gt;NSDocumentDirectoryinDomains&lt;span style="color: #000000;"&gt;:&lt;/span&gt;NSUserDomainMask&lt;span style="color: #000000;"&gt;] &lt;/span&gt;lastObject&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt; &lt;/p&gt;
&lt;p&gt;The next step was to pull the managedObjectModel file itself (.momd file). In my project, it's called "minimalTime".&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;- (&lt;span style="color: #7041a7;"&gt;NSManagedObjectModel&lt;/span&gt; *)managedObjectModel&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #7041a7;"&gt;NSString&lt;/span&gt;&lt;span style="color: #000000;"&gt; *path = [[&lt;/span&gt;&lt;span style="color: #7041a7;"&gt;NSBundle&lt;/span&gt;mainBundle&lt;span style="color: #000000;"&gt;] &lt;/span&gt;pathForResource&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #9b2320;"&gt;@"minimalTime"&lt;/span&gt;ofType&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #9b2320;"&gt;@"momd"&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt; *momURL = [&lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;fileURLWithPath&lt;/span&gt;:path];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #7041a7;"&gt;NSManagedObjectModel&lt;/span&gt; *managedObjectModel = [[&lt;span style="color: #7041a7;"&gt;NSManagedObjectModel&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #3d227f;"&gt;initWithContentsOfURL&lt;/span&gt;:momURL];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt;    &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #892462;"&gt;return&lt;/span&gt; managedObjectModel;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt; &lt;/p&gt;
&lt;p&gt;After that, I need to check for a legacy installation and migrate it to the new UIManagedDocument file instead. This is the overridden method:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;- (&lt;span style="color: #892462;"&gt;BOOL&lt;/span&gt;)configurePersistentStoreCoordinatorForURL:(&lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt; *)storeURL ofType:(&lt;span style="color: #7041a7;"&gt;NSString&lt;/span&gt; *)fileType modelConfiguration:(&lt;span style="color: #7041a7;"&gt;NSString&lt;/span&gt; *)configuration storeOptions:(&lt;span style="color: #7041a7;"&gt;NSDictionary&lt;/span&gt; *)storeOptions error:(&lt;span style="color: #7041a7;"&gt;NSError&lt;/span&gt; **)error&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;// If legacy store exists, copy it to the new location&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt; *legacyPersistentStoreURL = [[&lt;span style="color: #892462;"&gt;self&lt;/span&gt; &lt;span style="color: #33595d;"&gt;applicationDocumentsDirectory&lt;/span&gt;] &lt;span style="color: #3d227f;"&gt;URLByAppendingPathComponent&lt;/span&gt;:&lt;span style="color: #9b2320;"&gt;@"minimalTime.sqlite"&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt;    &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #7041a7;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;NSFileManager&lt;span style="color: #000000;"&gt;* fileManager = [&lt;/span&gt;NSFileManager&lt;span style="color: #3d227f;"&gt;defaultManager&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #892462;"&gt;if&lt;/span&gt; ([fileManager &lt;span style="color: #3d227f;"&gt;fileExistsAtPath&lt;/span&gt;:legacyPersistentStoreURL.&lt;span style="color: #7041a7;"&gt;path&lt;/span&gt;])     {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #9b2320;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;@"Old db exists"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        &lt;span style="color: #7041a7;"&gt;NSError&lt;/span&gt;* thisError = &lt;span style="color: #892462;"&gt;nil&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;        [fileManager &lt;/span&gt;replaceItemAtURL&lt;span style="color: #000000;"&gt;:storeURL &lt;/span&gt;withItemAtURL&lt;span style="color: #000000;"&gt;:legacyPersistentStoreURL &lt;/span&gt;backupItemName&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #892462;"&gt;nil&lt;/span&gt;options&lt;span style="color: #000000;"&gt;:&lt;/span&gt;NSFileManagerItemReplacementUsingNewMetadataOnlyresultingItemURL&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #892462;"&gt;nil&lt;/span&gt;error&lt;span style="color: #000000;"&gt;:&amp;amp;thisError];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt;    &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #892462;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; [&lt;/span&gt;&lt;span style="color: #892462;"&gt;super&lt;/span&gt;configurePersistentStoreCoordinatorForURL&lt;span style="color: #000000;"&gt;:storeURL &lt;/span&gt;ofType&lt;span style="color: #000000;"&gt;:fileType &lt;/span&gt;modelConfiguration&lt;span style="color: #000000;"&gt;:configuration &lt;/span&gt;storeOptions&lt;span style="color: #000000;"&gt;:storeOptions &lt;/span&gt;error&lt;span style="color: #000000;"&gt;:error];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt; &lt;/p&gt;
&lt;p&gt;Basically what's happening above is that it checks for the minimalTime.sqlite file inside the app's bundle on the iOS device. &lt;/p&gt;
&lt;p&gt;If the file exists, it tells you inside the console, and then tells the fileManager to replace the storeURL (inside the method parameter) with the legacy URL. This basically gives your app access to all the existing data the user has generated (otherwise they would load into a blank app, which would be disastrous).&lt;/p&gt;
&lt;p&gt;It returns a YES if successful (by calling it's [super] method).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Final step: Actually load this database&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Due to how my app works, I actually have to load the database at launch (instead of shortly after, which would be ideal). I call a method called loadDatabase, which looks like this:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;-(&lt;span style="color: #892462;"&gt;void&lt;/span&gt;)loadDatabase&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #892462;"&gt;static&lt;/span&gt; &lt;span style="color: #7041a7;"&gt;dispatch_once_t&lt;/span&gt; onceToken;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt;    &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;// Only do this once!&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    &lt;span style="color: #77492d;"&gt;dispatch_once&lt;/span&gt;(&amp;amp;onceToken, ^{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;// Get the URL&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;// The minimalTimeDB name is just something I call it&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #33595d;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #7041a7;"&gt;NSURL&lt;/span&gt;&lt;span style="color: #000000;"&gt; *url = [[&lt;/span&gt;&lt;span style="color: #892462;"&gt;self&lt;/span&gt;applicationDocumentsDirectory&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;URLByAppendingPathComponent&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #9b2320;"&gt;@"minimalTimeDB"&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;// Init the TimeTagModel (our custom class we wrote above) with the URL&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        &lt;span style="color: #892462;"&gt;self&lt;/span&gt;.&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt; = [[&lt;span style="color: #508186;"&gt;TimeTagModel&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #3d227f;"&gt;initWithFileURL&lt;/span&gt;:url];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;// Setup the undo manager if it's nil&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        &lt;span style="color: #892462;"&gt;if&lt;/span&gt; (&lt;span style="color: #892462;"&gt;self&lt;/span&gt;.&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt;.&lt;span style="color: #7041a7;"&gt;undoManager&lt;/span&gt; == &lt;span style="color: #892462;"&gt;nil&lt;/span&gt;){&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;            &lt;span style="color: #7041a7;"&gt;NSUndoManager&lt;/span&gt; *undoManager = [[&lt;span style="color: #7041a7;"&gt;NSUndoManager&lt;/span&gt;  &lt;span style="color: #3d227f;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #3d227f;"&gt;init&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;            [&lt;span style="color: #892462;"&gt;self&lt;/span&gt;.&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;setUndoManager&lt;/span&gt;:undoManager];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; min-height: 19.0px;"&gt;        &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;// You have to actually check to see if it exists already (for some reason you can't just call "open it, and if it's not there, create it")&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;        &lt;/span&gt;&lt;span style="color: #892462;"&gt;if&lt;/span&gt;&lt;span style="color: #000000;"&gt; ([[&lt;/span&gt;&lt;span style="color: #7041a7;"&gt;NSFileManager&lt;/span&gt;defaultManager&lt;span style="color: #000000;"&gt;] &lt;/span&gt;fileExistsAtPath&lt;span style="color: #000000;"&gt;:[url &lt;/span&gt;path&lt;span style="color: #000000;"&gt;]]) {&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;            &lt;/span&gt;// If it does exist, try to open it, and if it doesn't open, let the user (or at least you) know!&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;            [&lt;span style="color: #892462;"&gt;self&lt;/span&gt;.&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;openWithCompletionHandler&lt;/span&gt;:^(&lt;span style="color: #892462;"&gt;BOOL&lt;/span&gt; success){&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                &lt;span style="color: #892462;"&gt;if&lt;/span&gt; (!success) {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                    &lt;span style="color: #2e7d35;"&gt;// Handle the error.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #9b2320;"&gt;&lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;@"Error opening up the database"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                &lt;span style="color: #892462;"&gt;else&lt;/span&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #9b2320;"&gt;&lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;@"Opened the file--it already existed"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                    [&lt;span style="color: #892462;"&gt;self&lt;/span&gt; &lt;span style="color: #33595d;"&gt;refreshData&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;            }];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        &lt;span style="color: #892462;"&gt;else&lt;/span&gt; {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #2e7d35;"&gt;&lt;span style="color: #000000;"&gt;            &lt;/span&gt;// If it doesn't exist, you need to attempt to create it&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #3d227f;"&gt;&lt;span style="color: #000000;"&gt;            [&lt;/span&gt;&lt;span style="color: #892462;"&gt;self&lt;/span&gt;&lt;span style="color: #000000;"&gt;.&lt;/span&gt;&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt;saveToURL&lt;span style="color: #000000;"&gt;:url &lt;/span&gt;forSaveOperation&lt;span style="color: #000000;"&gt;:&lt;/span&gt;UIDocumentSaveForCreatingcompletionHandler&lt;span style="color: #000000;"&gt;:^(&lt;/span&gt;&lt;span style="color: #892462;"&gt;BOOL&lt;/span&gt;&lt;span style="color: #000000;"&gt; success){&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                &lt;span style="color: #892462;"&gt;if&lt;/span&gt; (!success) {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                    &lt;span style="color: #2e7d35;"&gt;// Handle the error.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #9b2320;"&gt;&lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;@"Error opening up the database"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                &lt;span style="color: #892462;"&gt;else&lt;/span&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #9b2320;"&gt;&lt;span style="color: #000000;"&gt;                    &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;NSLog&lt;/span&gt;&lt;span style="color: #000000;"&gt;(&lt;/span&gt;@"Created the file--it did not exist"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                    [&lt;span style="color: #892462;"&gt;self&lt;/span&gt; &lt;span style="color: #33595d;"&gt;refreshData&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;                }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;            }];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;        }&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    });&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt; &lt;/p&gt;
&lt;p&gt;If you're curious what refreshData looks like, it sends out a NSNotification that the database has been loaded:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;-(&lt;span style="color: #892462;"&gt;void&lt;/span&gt;)refreshData {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica; color: #7041a7;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;NSNotification&lt;span style="color: #000000;"&gt;* refreshNotification = [&lt;/span&gt;NSNotification&lt;span style="color: #3d227f;"&gt;notificationWithName&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #77492d;"&gt;kNotificationCenterRefreshAllDatabaseData &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;object&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #892462;"&gt;self&lt;/span&gt;&lt;span style="color: #000000;"&gt;.&lt;/span&gt;&lt;span style="color: #508186;"&gt;timeTagDB&lt;/span&gt;&lt;span style="color: #000000;"&gt;.&lt;/span&gt;managedObjectContext&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #3d227f;"&gt;userInfo&lt;/span&gt;&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #892462;"&gt;nil&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;    [[&lt;span style="color: #7041a7;"&gt;NSNotificationCenter&lt;/span&gt; &lt;span style="color: #3d227f;"&gt;defaultCenter&lt;/span&gt;] &lt;span style="color: #3d227f;"&gt;postNotification&lt;/span&gt;:refreshNotification];    &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px Helvetica;"&gt; &lt;/p&gt;
&lt;p&gt;The kNotificationCenterRefreshAllDatabaseData is just a constant I have defined elsewhere that keeps track of all the NSNotification names I use.&lt;/p&gt;
&lt;p&gt;I pass the managedObjectContext of the newly created file so that my view controllers can have access to it, and start passing it around to one another.&lt;/p&gt;
&lt;p&gt;The reason we do this as a Notification is because this is being run in the background, so we can't know exactly when it finishes. Make sure you design your app for this! Have some kind of loading indicator, or make sure your user can't attempt to create a record before the database actually exists, because it will crash the app.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/149824.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2012/06/05/migrating-core-data-to-new-uimanageddocument-in-ios-5.aspx</guid>
            <pubDate>Tue, 05 Jun 2012 18:44:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/149824.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2012/06/05/migrating-core-data-to-new-uimanageddocument-in-ios-5.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/149824.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/149824.aspx</trackback:ping>
        </item>
        <item>
            <title>UITableView and UIViewcontroller as a subview</title>
            <category>Quick Tips</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2011/04/20/uitableview-and-uiviewcontroller-as-a-subview.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2011/04/20/uitableview-and-uiviewcontroller-as-a-subview.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2011/04/20/uitableview-and-uiviewcontroller-as-a-subview.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This drove me nuts for a few hours, but finally figured it out. I wanted to go ahead and share, since the web results I found when I was searching were only a few pieces here and there, and still didn't offer a final solution.&lt;/p&gt;
&lt;p&gt;So the scenario I encountered was that I have a UIViewController that will sometimes host a subview (that is another viewcontroller) and it has a UITableView in it. The idea is that sometimes the user will tap a button, and it will add a subview of that UIViewController.&lt;/p&gt;
&lt;p&gt;Originally I created a file that subclassed UITableViewController but I've recently found that I prefer to create UIViewControllers that have tableViews in them. They're easier to manage, and give you more control over the view. For example, you can add subviews a lot easier to a UIViewController than you can a UITableViewController.&lt;/p&gt;
&lt;p&gt;The major issue I was having was that the UITableView did not resize properly when added as a subview. It would show some of the rows, but when the list became very long, it wouldn't let the user flick down to them. In general it was just being very strange and didn't seem to respond to any kind of frame setting.&lt;/p&gt;
&lt;p&gt;What worked was that I created a new UIViewController (&lt;strong&gt;without a nib file)&lt;/strong&gt; and implemented the following code in the loadView:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008517;"&gt;// Implement loadView to create a view hierarchy programmatically, without using a nib.&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;- (&lt;span style="color: #bd23a0;"&gt;void&lt;/span&gt;)loadView&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #743aa7;"&gt;UIView&lt;/span&gt; *contentView = [[&lt;span style="color: #743aa7;"&gt;UIView&lt;/span&gt; &lt;span style="color: #411a7f;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #411a7f;"&gt;initWithFrame&lt;/span&gt;:&lt;span style="color: #411a7f;"&gt;CGRectMake&lt;/span&gt;(&lt;span style="color: #3724d4;"&gt;0&lt;/span&gt;, &lt;span style="color: #3724d4;"&gt;0&lt;/span&gt;, &lt;span style="color: #3724d4;"&gt;320&lt;/span&gt;, &lt;span style="color: #3724d4;"&gt;480&lt;/span&gt;)];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;contentView.&lt;span style="color: #743aa7;"&gt;autoresizesSubviews&lt;/span&gt; = &lt;span style="color: #bd23a0;"&gt;YES&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; contentView.&lt;/span&gt;&lt;span style="color: #743aa7;"&gt;autoresizingMask&lt;/span&gt;&lt;span style="color: #000000;"&gt; = (&lt;/span&gt;UIViewAutoresizingFlexibleWidth&lt;span style="color: #000000;"&gt; | &lt;/span&gt;UIViewAutoresizingFlexibleHeight&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;contentView.&lt;span style="color: #743aa7;"&gt;backgroundColor&lt;/span&gt; = [&lt;span style="color: #743aa7;"&gt;UIColor&lt;/span&gt; &lt;span style="color: #411a7f;"&gt;clearColor&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;[&lt;span style="color: #bd23a0;"&gt;self&lt;/span&gt; &lt;span style="color: #411a7f;"&gt;setView&lt;/span&gt;:contentView];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;[contentView &lt;span style="color: #411a7f;"&gt;release&lt;/span&gt;];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; = [[&lt;/span&gt;&lt;span style="color: #743aa7;"&gt;UITableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;alloc&lt;span style="color: #000000;"&gt;] &lt;/span&gt;initWithFrame&lt;span style="color: #000000;"&gt;:&lt;/span&gt;CGRectMake&lt;span style="color: #000000;"&gt;(&lt;/span&gt;&lt;span style="color: #3724d4;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #3724d4;"&gt;0&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #3724d4;"&gt;320&lt;/span&gt;&lt;span style="color: #000000;"&gt;, &lt;/span&gt;&lt;span style="color: #3724d4;"&gt;440&lt;/span&gt;&lt;span style="color: #000000;"&gt;) &lt;/span&gt;style&lt;span style="color: #000000;"&gt;:&lt;/span&gt;UITableViewStylePlain&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; [&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;setAutoresizesSubviews&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #bd23a0;"&gt;YES&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; [&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;setAutoresizingMask&lt;span style="color: #000000;"&gt;:(&lt;/span&gt;UIViewAutoresizingFlexibleWidth&lt;span style="color: #000000;"&gt; | &lt;/span&gt;UIViewAutoresizingFlexibleHeight&lt;span style="color: #000000;"&gt;)];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt;[&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;setDataSource&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #bd23a0;"&gt;self&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; [&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;setDelegate&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #bd23a0;"&gt;self&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt; [[&lt;/span&gt;&lt;span style="color: #bd23a0;"&gt;self&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;view&lt;span style="color: #000000;"&gt;] &lt;/span&gt;addSubview&lt;span style="color: #000000;"&gt;:&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #411a7f;"&gt;&lt;span style="color: #000000;"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt; &lt;/p&gt;
&lt;p&gt;So in the loadView method, I create a UIView programmatically and set it to a full size frame. I then create a tableView and this is where I create the custom frame size that my app required. (I set it to be 440 instead of the full 480 for height). If you wanted, you could make this a variable that you initialize the UIViewController with.&lt;/p&gt;
&lt;p&gt;If you're curious what the header file looks like, here it is:&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #743aa7;"&gt;&lt;span style="color: #bd23a0;"&gt;@interface&lt;/span&gt;&lt;span style="color: #000000;"&gt; SelectPeopleViewController : &lt;/span&gt;UIViewController&lt;span style="color: #000000;"&gt; &amp;lt;&lt;/span&gt;UITableViewDelegate&lt;span style="color: #000000;"&gt;, &lt;/span&gt;UITableViewDataSource&lt;span style="color: #000000;"&gt;&amp;gt; {&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #743aa7;"&gt; UITableView&lt;/span&gt; *tableView;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #bd23a0;"&gt;@property&lt;span style="color: #000000;"&gt; (&lt;/span&gt;nonatomic&lt;span style="color: #000000;"&gt;, &lt;/span&gt;retain&lt;span style="color: #000000;"&gt;) &lt;/span&gt;&lt;span style="color: #743aa7;"&gt;UITableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; *tableView;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;By doing this, I was finally able to add the UIViewController as a subview and have it be sized properly, and the tableview finally rendered the list properly.&lt;/p&gt;
&lt;p&gt;Hope this info helps!&lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/144975.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2011/04/20/uitableview-and-uiviewcontroller-as-a-subview.aspx</guid>
            <pubDate>Wed, 20 Apr 2011 19:21:27 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/144975.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2011/04/20/uitableview-and-uiviewcontroller-as-a-subview.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/144975.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/144975.aspx</trackback:ping>
        </item>
        <item>
            <title>Creating an In-App Help Menu with a .plist file</title>
            <link>http://geekswithblogs.net/samerpaul/archive/2011/04/05/creating-an-in-app-help-menu-with-a-.plist-file.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2011/04/05/creating-an-in-app-help-menu-with-a-.plist-file.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2011/04/05/creating-an-in-app-help-menu-with-a-.plist-file.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;This is just a quick tutorial to help you write in an in-app help menu using a .plist file. As apps become more complicated (especially if you continue to add onto your 1.0 version with more features), it's easy to get lost in them. And a good built-in support system is appreciated by everyone. I also prefer to keep it in-app because then it's formatted properly and your users won't have to open up a browser and check, which isn't always available (or isn't always formatted properly).&lt;/p&gt;
&lt;p&gt;Ok so I decided to use a .plist file because it'd be the easiest way to structure the document and make changes. If you wanted to get really fancy, you could host the .plist file online (and have it pull from there) so that you can make edits to it without having to re-submit the app. But that's out of the scope of this particular post.&lt;/p&gt;
&lt;p&gt;Begin by adding the .plist to your project. You can do this easily by right clicking on your project and clicking "Add.." and then "Add New File..." :&lt;/p&gt;
&lt;p&gt;&lt;img title="AddNewPlist.jpg" src="http://prematuredeallocation.files.wordpress.com/2011/02/addnewplist.jpg" border="0" alt="AddNewPlist.jpg" width="600" height="488" /&gt;&lt;/p&gt;
&lt;p&gt;For my plist, I decided to make the root object an array and have each object in that array be a dictionary. The reason for choosing an Array (instead of the default Dictionary) is that you can order the menu items in the file itself, without having to do any extra work once you parse it. Dictionaries result in un-ordered lists, which would be silly, since you typically would want your help menu to be organized in a logical manner (going from the most basic to advanced features, for example.) So in each dictionary, I make the first item keyed to "Title" with the value of the title that the section will have. In this manner, I can create a help menu that uses the UITableViewGroup display, and have several sections with rows in each. (Once you see some pictures, I think it'll be pretty clear.)&lt;/p&gt;
&lt;p&gt;Here is what my final demo plist looks like. I've used my app (Compositions) as an example: &lt;img title="PlistFile.jpg" src="http://prematuredeallocation.files.wordpress.com/2011/02/plistfile.jpg" border="0" alt="PlistFile.jpg" width="590" height="257" /&gt;&lt;/p&gt;
&lt;p&gt;And just as a preview of what this will end up looking like, here is the final tableview in my app:&lt;/p&gt;
&lt;p&gt;&lt;img title="FinalHelpTableView.jpg" src="http://prematuredeallocation.files.wordpress.com/2011/02/finalhelptableview.jpg" border="0" alt="FinalHelpTableView.jpg" width="308" height="600" /&gt;&lt;/p&gt;
&lt;p&gt;Ok, so to get from the file to that screenshot is actually pretty easy. I added a new UITableViewController to my project and named it HelpViewController. I checked the box to subclass it from the UITableViewController class so that it would add in the methods that I need.&lt;/p&gt;
&lt;p&gt;I am using a custom class that I wrote called "MenuItem". MenuItem is a generic class I use for any time I need to write a custom UITableView item list. It has the ability to chain indefinitely, so that I can easily create sections and rows with it, and also include a subtitle, description, item name, a key (which is useful when your positioning is independent of the order you add the items), etc. Here is the class definition:&lt;/p&gt;
&lt;p&gt;As I mentioned, the subMenuItems is useful to add another array of MenuItems, so that I can easily create a hierarchy in a menu.&lt;/p&gt;
&lt;pre&gt;&lt;span style="color: #8c1a62;"&gt;@interface&lt;/span&gt; MenuItem : NSObject {

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;NSUInteger&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #4e8187;"&gt;itemKey&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #743aa7;"&gt;NSString&lt;/span&gt;&lt;span style="color: #000000;"&gt; *&lt;/span&gt;itemDescription&lt;span style="color: #000000;"&gt;;&lt;/span&gt;

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #743aa7;"&gt;NSString&lt;/span&gt;&lt;span style="color: #000000;"&gt; *&lt;/span&gt;itemSubtitle&lt;span style="color: #000000;"&gt;;&lt;/span&gt;

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;NSMutableArray&lt;span style="color: #000000;"&gt; *&lt;/span&gt;&lt;span style="color: #4e8187;"&gt;subMenuItems&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;

}

&lt;span style="color: #8c1a62;"&gt;@property&lt;/span&gt; (&lt;span style="color: #8c1a62;"&gt;nonatomic&lt;/span&gt;, &lt;span style="color: #8c1a62;"&gt;assign&lt;/span&gt;) NSUInteger itemKey;

&lt;span style="color: #8c1a62;"&gt;@property&lt;/span&gt; (&lt;span style="color: #8c1a62;"&gt;nonatomic&lt;/span&gt;, &lt;span style="color: #8c1a62;"&gt;retain&lt;/span&gt;) NSString *itemDescription;

&lt;span style="color: #8c1a62;"&gt;@property&lt;/span&gt; (&lt;span style="color: #8c1a62;"&gt;nonatomic&lt;/span&gt;, &lt;span style="color: #8c1a62;"&gt;retain&lt;/span&gt;) NSString *itemSubtitle;

&lt;span style="color: #8c1a62;"&gt;@property&lt;/span&gt; (&lt;span style="color: #8c1a62;"&gt;nonatomic&lt;/span&gt;, &lt;span style="color: #8c1a62;"&gt;retain&lt;/span&gt;) NSMutableArray *subMenuItems;


&lt;/pre&gt;
&lt;p&gt;Back to my HelpViewController! I create a NSMutableArray to hold my menu items:&lt;/p&gt;
&lt;pre&gt;&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;NSMutableArray&lt;span style="color: #000000;"&gt; *&lt;/span&gt;&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;p style="font: 13px 'Helvetica Neue'; color: #7c1fae; margin: 0;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;And I initialize it in my -(id)init method:&lt;/p&gt;
&lt;pre&gt;-(&lt;span style="color: #980063;"&gt;id&lt;/span&gt;)init {
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[&lt;/span&gt;&lt;span style="color: #980063;"&gt;super&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;initWithStyle&lt;span style="color: #000000;"&gt;:&lt;/span&gt;UITableViewStyleGrouped&lt;span style="color: #000000;"&gt;];&lt;/span&gt;
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt;&lt;span style="color: #000000;"&gt; = [[&lt;/span&gt;NSMutableArray&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #460085;"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #460085;"&gt;init&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;return&lt;span style="color: #000000;"&gt; &lt;/span&gt;self&lt;span style="color: #000000;"&gt;;&lt;/span&gt;
}

&lt;span style="font-family: Helvetica;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="font-family: 'Helvetica Neue'; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;I'm choosing to create the actual menu in my ViewDidLoad method, so that if I run low on memory while I'm off the screen, I can dump it and re-create it if they come back to it.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here is the code to build the menu, using my custom class and the plist file. I'll explain everything after:&lt;/p&gt;
&lt;pre&gt;-(&lt;span style="color: #980063;"&gt;void&lt;/span&gt;)loadHelpChapters {
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;NSBundle&lt;/span&gt; *bundle = [&lt;span style="color: #7c1fae;"&gt;NSBundle&lt;/span&gt; &lt;span style="color: #460085;"&gt;mainBundle&lt;/span&gt;];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;NSString&lt;/span&gt; *plistPath = [bundle &lt;span style="color: #460085;"&gt;pathForResource&lt;/span&gt;:&lt;span style="color: #ab0003;"&gt;@"HelpList"&lt;/span&gt; &lt;span style="color: #460085;"&gt;ofType&lt;/span&gt;:&lt;span style="color: #ab0003;"&gt;@"plist"&lt;/span&gt;];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;NSArray&lt;/span&gt; *rootArray = [[&lt;span style="color: #7c1fae;"&gt;NSArray&lt;/span&gt; &lt;span style="color: #460085;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #460085;"&gt;initWithContentsOfFile&lt;/span&gt;:plistPath];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; *mi = &lt;span style="color: #980063;"&gt;nil&lt;/span&gt;;
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #980063;"&gt;int&lt;/span&gt; k = &lt;span style="color: #2a00ff;"&gt;0&lt;/span&gt;;

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #980063;"&gt;for&lt;/span&gt; (&lt;span style="color: #7c1fae;"&gt;NSDictionary&lt;/span&gt;* chapter &lt;span style="color: #980063;"&gt;in&lt;/span&gt; rootArray ) {
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;NSString&lt;/span&gt; *chapTitle = [chapter &lt;span style="color: #460085;"&gt;valueForKey&lt;/span&gt;:&lt;span style="color: #ab0003;"&gt;@"Title"&lt;/span&gt;];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;mi = [[&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; &lt;span style="color: #460085;"&gt;alloc&lt;/span&gt;] &lt;span style="color: #225a5f;"&gt;initWithKey&lt;/span&gt;:k &lt;span style="color: #225a5f;"&gt;andDescription&lt;/span&gt;:chapTitle];

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[chapter &lt;span style="color: #460085;"&gt;enumerateKeysAndObjectsUsingBlock&lt;/span&gt;:^(&lt;span style="color: #980063;"&gt;id&lt;/span&gt; key, &lt;span style="color: #980063;"&gt;id&lt;/span&gt; obj, &lt;span style="color: #980063;"&gt;BOOL&lt;/span&gt; *stop) {
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #980063;"&gt;if&lt;/span&gt; (![key &lt;span style="color: #460085;"&gt;isEqualToString&lt;/span&gt;:&lt;span style="color: #ab0003;"&gt;@"Title"&lt;/span&gt;]) {

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt;&lt;span style="color: #000000;"&gt; *subMi = [[&lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #460085;"&gt;alloc&lt;/span&gt;&lt;span style="color: #000000;"&gt;] &lt;/span&gt;initWithKey&lt;span style="color: #000000;"&gt;:k &lt;/span&gt;andDescription&lt;span style="color: #000000;"&gt;:key &lt;/span&gt;andSubtitle&lt;span style="color: #000000;"&gt;: obj];&lt;/span&gt;
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[[mi &lt;span style="color: #225a5f;"&gt;subMenuItems&lt;/span&gt;] &lt;span style="color: #460085;"&gt;addObject&lt;/span&gt;:subMi];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[subMi &lt;span style="color: #460085;"&gt;release&lt;/span&gt;];

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;}

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;}];

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt; &lt;span style="color: #460085;"&gt;addObject&lt;/span&gt;:mi];

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[mi &lt;span style="color: #460085;"&gt;release&lt;/span&gt;]; mi = &lt;span style="color: #980063;"&gt;nil&lt;/span&gt;;

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;k++;

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;}&lt;span style="white-space: pre;"&gt; &lt;/span&gt;

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[rootArray &lt;span style="color: #460085;"&gt;release&lt;/span&gt;];

}

&lt;span style="font-family: Helvetica;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="font-family: 'Helvetica Neue'; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;So what's happening here?  First I'm getting a reference to my bundle (which is your packaged app, essentially) and then getting the address of the actual .plist. I've named my HelpList so that's what's happening in line 2. I then initialize an array (which is the root object of the file) using NSArray's initWithContentsOfFile: method. That will open up the file and load all the root objects into an array.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Each object is now a NSDictionary, which I'm calling "chapter". I'm going to enumerate through each one and do a couple things.&lt;/p&gt;
&lt;p&gt;First I'm going to create my section MenuItem. This is going to represent the tableView section and will have several rows in it. I ask for dictionary for the "Title" value and initialize a MenuItem with that. I am not using the key for anything in this instance (the key is just an int value) but I am adding an int k to it, just in case I ever want to use its position for anything.&lt;/p&gt;
&lt;p&gt;Next comes the really cool part--using blocks! I need to go through the rest of the dictionary, getting everything but the Title value, to add each row to this section. I use the method -enumerateKeysAndObjectsUsingBlock which essentially goes through each dictionary item and exposes both its key and value. The key in this case is the section title, and the value in my example is the text that will appear when the user taps on the item.&lt;/p&gt;
&lt;p&gt;For each of these enumerated dictionary values, I create a child MenuItem (called subMi) and add it to my current section MenuItem. Once added, I release it.&lt;/p&gt;
&lt;p&gt;Once I'm done enumerating, I add this section MenuItem to my ViewController's array and release that as well, to be a good memory citizen.&lt;/p&gt;
&lt;p&gt;Once it's done going through all the root objects, I release the rootArray object I created, freeing up that memory as well.&lt;/p&gt;
&lt;p&gt;Now for the tableView methods. As I've mentioned, we now have a top level array of MenuItems that represents all the sections. And inside each of those, we have children MenuItems that represent rows. So this is basically an exact mirror to how tableViews work, with NSIndexPath. So it's pretty simple:&lt;/p&gt;
&lt;pre&gt;- (&lt;span style="color: #7c1fae;"&gt;NSInteger&lt;/span&gt;)numberOfSectionsInTableView:(&lt;span style="color: #7c1fae;"&gt;UITableView&lt;/span&gt; *)&lt;span style="color: #7c1fae;"&gt;tableView&lt;/span&gt; {
&lt;span style="color: #000000;"&gt; &lt;/span&gt;// Return the number of sections, which is just how many items we have in our menuItems array.
&lt;span style="color: #980063;"&gt;return&lt;/span&gt; [&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt; &lt;span style="color: #460085;"&gt;count&lt;/span&gt;];
}

- (&lt;span style="color: #7c1fae;"&gt;NSInteger&lt;/span&gt;)tableView:(&lt;span style="color: #7c1fae;"&gt;UITableView&lt;/span&gt; *)&lt;span style="color: #7c1fae;"&gt;tableView&lt;/span&gt; numberOfRowsInSection:(&lt;span style="color: #7c1fae;"&gt;NSInteger&lt;/span&gt;)section {
&lt;span style="color: #000000;"&gt; &lt;/span&gt;// Return the number of rows in the section.
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// First get the top level item using section
&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; *mi = [&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt; &lt;span style="color: #460085;"&gt;objectAtIndex&lt;/span&gt;:section];
// Then return the number of children items from the top level one.
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #980063;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; [[mi &lt;/span&gt;subMenuItems&lt;span style="color: #000000;"&gt;] &lt;/span&gt;&lt;span style="color: #460085;"&gt;count&lt;/span&gt;&lt;span style="color: #000000;"&gt;];&lt;/span&gt;
}

 - (&lt;span style="color: #7c1fae;"&gt;UITableViewCell&lt;/span&gt; *)tableView:(&lt;span style="color: #7c1fae;"&gt;UITableView&lt;/span&gt; *)&lt;span style="color: #7c1fae;"&gt;tableView&lt;/span&gt; cellForRowAtIndexPath:(&lt;span style="color: #7c1fae;"&gt;NSIndexPath&lt;/span&gt; *)indexPath {

&lt;span style="color: #980063;"&gt;static&lt;/span&gt; &lt;span style="color: #7c1fae;"&gt;NSString&lt;/span&gt; *CellIdentifier = &lt;span style="color: #ab0003;"&gt;@"Cell"&lt;/span&gt;;
&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: #000000;"&gt; *cell = [&lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;tableView&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;dequeueReusableCellWithIdentifier&lt;span style="color: #000000;"&gt;:CellIdentifier];&lt;/span&gt;

&lt;span style="color: #980063;"&gt;if&lt;/span&gt; (cell == &lt;span style="color: #980063;"&gt;nil&lt;/span&gt;) {
&lt;span style="color: #000000;"&gt; cell = [[[&lt;/span&gt;&lt;span style="color: #7c1fae;"&gt;UITableViewCell&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;alloc&lt;span style="color: #000000;"&gt;] &lt;/span&gt;initWithStyle&lt;span style="color: #000000;"&gt;:&lt;/span&gt;UITableViewCellStyleDefault&lt;span style="color: #000000;"&gt; &lt;/span&gt;reuseIdentifier&lt;span style="color: #000000;"&gt;:CellIdentifier] &lt;/span&gt;autorelease&lt;span style="color: #000000;"&gt;];&lt;/span&gt;
}
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// Get the top level first from the section
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; *mi = [&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt; &lt;span style="color: #460085;"&gt;objectAtIndex&lt;/span&gt;:[indexPath &lt;span style="color: #460085;"&gt;section&lt;/span&gt;]];
&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// Then get the child level item from the row

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; *subMi = [[mi &lt;span style="color: #225a5f;"&gt;subMenuItems&lt;/span&gt;] &lt;span style="color: #460085;"&gt;objectAtIndex&lt;/span&gt;:[indexPath &lt;span style="color: #460085;"&gt;row&lt;/span&gt;]];
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;[[cell &lt;span style="color: #460085;"&gt;textLabel&lt;/span&gt;] &lt;span style="color: #460085;"&gt;setText&lt;/span&gt;:[subMi &lt;span style="color: #225a5f;"&gt;itemDescription&lt;/span&gt;]];

&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #980063;"&gt;return&lt;/span&gt; cell;
}

-(&lt;span style="color: #7c1fae;"&gt;NSString&lt;/span&gt; *)tableView:(&lt;span style="color: #7c1fae;"&gt;UITableView&lt;/span&gt; *)&lt;span style="color: #7c1fae;"&gt;tableView&lt;/span&gt; titleForHeaderInSection:(&lt;span style="color: #7c1fae;"&gt;NSInteger&lt;/span&gt;)section {

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;// Pull from the top level to get the section title
&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #3d8389;"&gt;MenuItem&lt;/span&gt; *mi = [&lt;span style="color: #3d8389;"&gt;menuItems&lt;/span&gt; &lt;span style="color: #460085;"&gt;objectAtIndex&lt;/span&gt;:section];

&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #980063;"&gt;return&lt;/span&gt;&lt;span style="color: #000000;"&gt; [mi &lt;/span&gt;itemDescription&lt;span style="color: #000000;"&gt;];&lt;/span&gt;
}

&lt;span style="font-family: Helvetica;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="font-family: 'Helvetica Neue'; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;I hope this proves helpful for someone! It might seem like a lot of work, but it's really not too bad. And as I said, now you have a code-independent method of adding and removing help items. You can do all your text editing in your .plist editor, and even put it online to update it there. You could design a system that checks for an updated help file on load (if network is present) and pull it down real quick. Plists are small text files essentially, so it would be pretty quick.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/144714.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2011/04/05/creating-an-in-app-help-menu-with-a-.plist-file.aspx</guid>
            <pubDate>Tue, 05 Apr 2011 14:52:13 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/144714.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2011/04/05/creating-an-in-app-help-menu-with-a-.plist-file.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/144714.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/144714.aspx</trackback:ping>
        </item>
        <item>
            <title>_OBJ_CLASS_$ Error (Symbol(s) missing) with Full and Free iOS apps</title>
            <category>Quick Tips</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2010/10/25/_obj_class_-error-symbols-missing-with-full-and-free-ios-apps.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2010/10/25/_obj_class_-error-symbols-missing-with-full-and-free-ios-apps.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2010/10/25/_obj_class_-error-symbols-missing-with-full-and-free-ios-apps.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I am currently working on making a free version of my iOS application. I followed a fantastic tutorial a while back (﻿&lt;a href="http://www.bit-101.com/blog/?p=2098"&gt;http://www.bit-101.com/blog/?p=2098&lt;/a&gt; ) which got me up and running with a free and regular version, sharing the same code base. This is great, because changes made will be mirrored across both versions, so you don't have the nightmare of maintaining two sets of code.&lt;/p&gt;
&lt;p&gt;I shelved the free version for a while and then decided to come back to it, and hopefully get it out in time for 4.2's release next month. I had added several new classes and some views since the last time I built the free version and thought it would compile just fine. I was wrong!&lt;/p&gt;
&lt;p&gt;I ran into the error with several of those new classes/views (OBJ_CLASS_$) saying the symbols were missing. I was confused, since I saw them right there in my project.&lt;/p&gt;
&lt;p&gt;Turns out that I had to manually copy these over to the free version so that it would build along with all the other classes. XCode doesn't automatically do this if you've been working in one target and then switch to the other.&lt;/p&gt;
&lt;p&gt;It's a simple fix though. Lets say you're getting an error that a class called "ProgramSettings" is referenced but missing. Follow these steps:&lt;/p&gt;
&lt;p&gt;1) Find "Targets" in the left side of your Xcode window ,and expand it. You should see something like "MyApp" and "MyApp Free".&lt;/p&gt;
&lt;p&gt;2) Expand the "MyApp Free" (or whatever version that you're getting the error in).&lt;/p&gt;
&lt;p&gt;3) You should see lots of folders, named "Copy Bundle Resources", "Compile Sources", and "Link Binary With Libraries." You will want to find the class (ProgramSettings.m) in your project above, and simply drag and drop them into "Compile Sources", along with all the other classes.&lt;/p&gt;
&lt;p&gt;You can repeat step #3 for what is missing. Classes go in the Compile Sources and nibs (.xib) go in the Copy Resource Bundle.&lt;/p&gt;
&lt;p&gt;4) Clean, build and launch!&lt;/p&gt;
&lt;p&gt;it should now be error free, assuming you had no other errors on build and in your code.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/142442.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2010/10/25/_obj_class_-error-symbols-missing-with-full-and-free-ios-apps.aspx</guid>
            <pubDate>Mon, 25 Oct 2010 17:53:25 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/142442.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2010/10/25/_obj_class_-error-symbols-missing-with-full-and-free-ios-apps.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/142442.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/142442.aspx</trackback:ping>
        </item>
        <item>
            <title>quick fix: Predicatebuilder not stacking queries issue inside for loop</title>
            <link>http://geekswithblogs.net/samerpaul/archive/2010/08/19/quick-fix-predicatebuilder-not-stacking-queries-issue-inside-for-loop.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2010/08/19/quick-fix-predicatebuilder-not-stacking-queries-issue-inside-for-loop.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2010/08/19/quick-fix-predicatebuilder-not-stacking-queries-issue-inside-for-loop.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;I ran into this problem this morning and thought I’d share in case someone else has this issue .So I’m using PredicateBuilder with the EntityFramework and doing some pretty basic query building.&lt;/p&gt;
&lt;p&gt;I have a list of business types that the person can select (a checkboxlist) and then it returns everything that matches. I was having an issue because it was only ever returning the businesses that matched the last item I selected—it wasn’t stacking the query at all.&lt;/p&gt;
&lt;p&gt;Finally, I noticed what was going on. Inside my for loop:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; bTypeId &lt;span class="kwrd"&gt;in&lt;/span&gt; businessTypeIds)
            {
              
                businessTypes = SearchHelper.Or(businessTypes,
                    m =&amp;gt; m.BusinessType.BusinessTypeID == bTypeId);
                businessFiltered = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            }&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --&gt;
&lt;p&gt;I was never casting bTypeId to its own variable. So if I ran a query to search for business type Ids 23 and 24, it was going through once ,and asking for == 23. Then it went through the second time, and changed the reference to both to be == 24. So the query ended up just saying does the business type equal 24 two times, instead of saying does it equal 23 or 24.&lt;/p&gt;
&lt;p&gt;The quick fix? Add in a temporary variable and use that instead:&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; bTypeId &lt;span class="kwrd"&gt;in&lt;/span&gt; businessTypeIds)
            {
                &lt;span class="kwrd"&gt;int&lt;/span&gt; tempId = bTypeId;
                businessTypes = SearchHelper.Or(businessTypes,
                    m =&amp;gt; m.BusinessType.BusinessTypeID == tempId);
                businessFiltered = &lt;span class="kwrd"&gt;true&lt;/span&gt;;
            }&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;!-- .csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --&gt;
&lt;p&gt;Now the tempId holds the proper Id for each type, and the query will essentially read “does it equal 23 or 24”.&lt;/p&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/141389.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2010/08/19/quick-fix-predicatebuilder-not-stacking-queries-issue-inside-for-loop.aspx</guid>
            <pubDate>Thu, 19 Aug 2010 15:40:42 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/141389.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2010/08/19/quick-fix-predicatebuilder-not-stacking-queries-issue-inside-for-loop.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/141389.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/141389.aspx</trackback:ping>
        </item>
        <item>
            <title>UIViewController not being unloaded in ViewDidUnload</title>
            <category>Quick Tips</category>
            <link>http://geekswithblogs.net/samerpaul/archive/2010/07/27/uiviewcontroller-not-being-unloaded-in-viewdidunload.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2010/07/27/uiviewcontroller-not-being-unloaded-in-viewdidunload.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2010/07/27/uiviewcontroller-not-being-unloaded-in-viewdidunload.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The past few months I've been working in objective-C since I've been doing some contract iPhone development work. I actually really like the platform. iOS is pretty fun to code for. However, it can also be incredibly frustrating--especially coming from using Visual Studio and C#.&lt;/p&gt;
&lt;p&gt;One of the things that stopped me for a while was that I noticed that my views were not being properly unloaded in a UINavigationController setup. Whenever I popped the view, I noticed that the retain count on it stayed above 0. If I pushed on a new view, it would add 1 to it and continue until I hit a memory error.&lt;/p&gt;
&lt;p&gt;I knew something was holding onto it but I had no idea what--I was sending release statements to everything I retained. Then after some digging around, I discovered what was going on.&lt;/p&gt;
&lt;p&gt;By accident, I had my custom delegates I wrote marked with (retain) in the property. This lead to one of those nasty retain cycles, which means that even though I was releasing the view, the delegate still owned it.&lt;/p&gt;
&lt;p&gt;So I changed it to (assign) and re-loaded the app. Success! It now properly completely released and deallocated the view. Here's a quick code snippet:&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px 'Helvetica Neue';"&gt;&lt;span style="color: #8c1a62;"&gt;﻿@property&lt;/span&gt; (&lt;span style="color: #8c1a62;"&gt;assign&lt;/span&gt;) &lt;span style="color: #8c1a62;"&gt;id&lt;/span&gt;&amp;lt;MyCustomDelegate&amp;gt; customDelegate;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px 'Helvetica Neue';"&gt;&lt;span style="font-family: Helvetica;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="font-family: 'Helvetica Neue'; font-size: large;"&gt;&lt;span style="font-size: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;
 &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/141092.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2010/07/27/uiviewcontroller-not-being-unloaded-in-viewdidunload.aspx</guid>
            <pubDate>Wed, 28 Jul 2010 03:03:46 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/141092.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2010/07/27/uiviewcontroller-not-being-unloaded-in-viewdidunload.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/141092.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/141092.aspx</trackback:ping>
        </item>
        <item>
            <title>Contract Work - Lessons Learned</title>
            <link>http://geekswithblogs.net/samerpaul/archive/2010/06/04/contract-work---lessons-learned.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2010/06/04/contract-work---lessons-learned.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2010/06/04/contract-work---lessons-learned.aspx&lt;/a&gt;&lt;/p&gt;&lt;p style="clear: both"&gt;I thought I would write a post of a different nature today, but still relevant to the tech world. I do a lot of contract jobs myself and really enjoy it. It's nice to keep jumping from project to project, and not having to go to an office or keep regular hours, etc. I really enjoy it. I have learned a lot in the past few years of doing it (both from experience and from help given to me from others, and the internet) so I thought I'd share some of that knowledge/experience today.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div&gt;So here's my own personal "lesson's learned" that hopefully will help you if you find yourself doing contract work:&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;Should I take the job?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Ok, so this is the first step. Assuming you were given sufficient information about what they want, then you should really think about what you're capable of doing and whether or not you should take this job. Personally, my rule is, &lt;strong&gt;if I know it's possible, I'll say yes, even if I don't yet know how to do it. &lt;/strong&gt; That's because the internet is such a great help, it would be rare to run into an issue that you can't figure out with some help. So if your clients are asking for something that you don't yet know how to program, but you know you &lt;em&gt;can&lt;/em&gt; do it on the platform then go for it. How else are you going to learn?&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Use this rule with some limitation, however. If you're really lacking the expertise or foundation in something, then unless you have tons of time to complete the project, then I wouldn't say yes. For example, I haven't personally done any 3d/openGL programming yet so I wouldn't say yes to a project that extensively uses it. &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;OK, so I want the job, but how much do I charge?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;This part can be tricky. There is no set formula really, but I have some tips for pricing that will hopefully give you a better idea on how to confidently ask your price and have them accept. Here are some personal guidelines&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style="clear: both"&gt;&lt;li&gt;&lt;em&gt;How much time do you have to complete the project?&lt;/em&gt; If it's shorter than average, then charge more. You can even make a subtle note about this (or not so subtle if they still don't get it.) If it seems too short of a time (i.e. near impossible to complete), be sure to say that. It looks bad to promise a time that you can't keep--and it makes it less likely for them to return to you for work.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;Your Hourly rate:&lt;/em&gt; How long have you been working in that language? Do you have existing projects to back you up? Or previous contacts that can vouch for your work? Are there very few people with your particular skill set? All of these things will lend themselves to setting an hourly rate. I'd also try out a quick google search of what your line of work is, to see what the industry standard is at that point in time.&lt;br /&gt;&lt;br /&gt;I wouldn't price too low, because you want to make your time worth it. You also want them to feel like they're paying for quality work (assuming you can deliver it :) ). Finally, think about your client. If it's a small business, then don't price it too high if you want the job. If it's an enterprise (like a &lt;em&gt;Fortune&lt;/em&gt; company), then don't be afraid to price higher. They have the budget for it.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;Fixed price: &lt;/em&gt;If they want a fixed price project, then you need to think about how many hours it will take you to complete it and multiply it by the hourly rate you set for yourself. Then, honestly, I would add 10-20% on top of that. Why? Because nothing ever works exactly how you want it to. There are lots of times that something "trivial" is way harder than it should be, or something that "should work" doesn't for hours and it eats away at your hourly rate. I can't count the number of times I encountered a logical bug that took away an entire's day work because debuggers don't help in those cases. By adding that padding in, it's still OK to have those days where you don't get as much done as you want. &lt;br /&gt;&lt;br /&gt;And another useful tip: Depending on your client, and the scope, you most likely want to set that you both sign off on a specification sheet before doing any work, and that any changes will result in a re-evaulation of the price. This is to help protect you from being handed a huge new addition to the project half-way in, without any extra payment.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;em&gt;Scope of project: &lt;/em&gt;Finally, is it a huge project? Is it really small/fast? This affects how much your client will be willing to pay. If it sounds big, they will be willing to pay more for it. If it seems really small, then you won't be able to get away with a large asking price (as easily).&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;strong&gt;Ok, I priced it, now what?&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;So now that you have the price, you want to make sure it feels justified to your client. I never set a price before I can really think about everything. For example, if you're still in your introduction phase, and they want a price, don't give one! Just comment that you will send them a proposal sheet with all the features outlined, and a price for everything. You don't want to shout out a low number and then deliver something that is way higher. You also don't want to shock them with a big number before they feel like they are getting a great product.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Make up a proposal document in a word editor. Personally, I leave the price till the very end. Why? Because by the time they reach the end, you've already discussed all the great features you plan to implement, and how it's the best product they'll ever use, etc etc...so your price comes off as a steal! If you hit them up front with a price, they will read through the document with a negative bias. Think about those commercials on TV. They always go on about their product, then at the end, ask "What would you pay for something like this? $100? $50? How about $20!!". This is not by accident.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;Scenario: I finished the job way earlier than expected&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;You have two options then. You can either polish the hell out of the application, and even throw in a few bonus features (assuming they are in-line with the customer's needs) or you can sit and wait on it until you near your deadline. &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Why don't you want to turn it in too early? Because you should treat that extra time as a surplus. If you said it is going to take you 3 weeks, and it took you only 1, you have a surplus of 2 weeks. I personally don't want to let them know that I can do a 3 week project in 1 week. Why not? Because that may not always be the case! I may later have a 3 week project that takes all 3 weeks, but if I set a precedent of delivering super early, then the pressure is on for that longer project. It also makes it harder to quote longer times if you keep delivering too early.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Feel free to deliver early, but again, don't do it too early. They may also wonder why they paid you for 3 weeks of work if you're done in 1. They may further wonder if the product sucks, or what is wrong with it, if it's done so early, etc.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;I would just polish the application. Everyone loves polish in their applications. The smallest details are what make an application go from "functional" to "fantastic". And since you are still delivering on time, then they are still going to be very happy with you.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;Scenario: It's taking way too long to finish this, and the deadline is nearing/here!&lt;/strong&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;So this is not a fun scenario to be in, but it'll happen. Sometimes the scope of the project gets out of hand. The best policy here is &lt;strong&gt;OPENNESS/HONESTY&lt;/strong&gt;. Tell them that the project is taking longer than expected, and give a reasonable time for when you think you'll have it done. I typically explain it in a way that makes it sound like it isn't something that I did wrong, but it's just something about the nature of the project. &lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;This really goes for any scenario, to be honest. Just continue to stay open and communicative about your progress. This doesn't mean that you should email them every five minutes (unless they want you to), but it does mean that maybe every few days or once a week, give them an update on where you're at, and what's next. They'll be happy to know they are paying for progress, and it'll make it easier to ask for an extension when something goes wrong, because they know that you've been working on it all along.&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;Final tips and thoughts:&lt;br /&gt;&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;In general, contract work is really fun and rewarding. It's nice to learn new things all the time, as mandated by the project ,and to challenge yourself to do things you may not have done before. The key is to build a great relationship with your clients for future work, and for recommendations. I am always very honest with them and I never promise something I can't deliver. Again, under promise, over deliver!&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I hope this has proved helpful!&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Cheers,&lt;br /&gt;samerpaul&lt;/div&gt;&lt;br class="final-break" style="clear: both" /&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/140234.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2010/06/04/contract-work---lessons-learned.aspx</guid>
            <pubDate>Fri, 04 Jun 2010 18:38:01 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/140234.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2010/06/04/contract-work---lessons-learned.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/140234.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/140234.aspx</trackback:ping>
        </item>
        <item>
            <title>Delegates: A Practical Understanding</title>
            <link>http://geekswithblogs.net/samerpaul/archive/2010/05/20/delegates-a-practical-understanding.aspx</link>
            <description>&lt;p&gt;Originally posted on: &lt;a href='http://geekswithblogs.net/samerpaul/archive/2010/05/20/delegates-a-practical-understanding.aspx'&gt;http://geekswithblogs.net/samerpaul/archive/2010/05/20/delegates-a-practical-understanding.aspx&lt;/a&gt;&lt;/p&gt;&lt;p style="clear: both"&gt;It's been a while since I have written on this blog, and I'm planning on reviving it this summer, since I have more time to do so again.&lt;/p&gt;&lt;p style="clear: both"&gt;I've also recently started working on the iPhone platform, so I haven't been as busy in .NET as before.&lt;/p&gt;&lt;p style="clear: both"&gt;In either case, today's blog post applies to both C# and Objective-C, because it's more about a practical understanding of delegates than it is about code. When I was learning coding, I felt like delegates was one of the hardest things to conceptually understand, and a lot of books don't really do a good job (in my opinion) of explaining it. So here's my stab at it.&lt;/p&gt;&lt;p style="clear: both"&gt;&lt;strong&gt;A Real Life Example of Delegates&lt;/strong&gt;&lt;/p&gt;&lt;p style="clear: both"&gt;Let's say there are three of you. You, your friend, and your brother. You're each in a different room in your house so you can't hear each other, even if you shout. &lt;/p&gt;&lt;p style="clear: both"&gt;1)You are playing a computer game&lt;br /&gt;2) Friend is building a puzzle&lt;br /&gt;3) Brother is napping&lt;/p&gt;&lt;p style="clear: both"&gt;Now, you three are going to stay in your room but you want to be informed if anything interesting is happening to the one of you. Let's say you (playing the computer game) want to know when your brother wakes up.&lt;/p&gt;&lt;p style="clear: both"&gt;You &lt;em&gt;could&lt;/em&gt; keep walking to the room, checking to see if he's napping, and then walking back to your room. But that would waste a lot of time / resources, and what if you miss when he's awake before he goes back to sleep? That would be bad.&lt;/p&gt;&lt;p style="clear: both"&gt;Instead, you hand him a 2-way radio that works between your room and his room. And you inform him that when he wakes up, he should press a button on the radio and say "I'm awake". You are going to be listening to that radio, waiting for him to say he's awake. This, in essence, is how a delegate works.&lt;/p&gt;&lt;p style="clear: both"&gt;You're creating an "object" (the radio) that allows you to listen in on an event you specify. You don't want him to send any other messages to you right now, except when he wakes up. And you want to know immediately when he does, so you can go over to his room and say hi. (the methods that are called when a delegate event fires). You're also currently specifying that only you are listening on his radio.&lt;/p&gt;&lt;p style="clear: both"&gt;Let's say you want your friend to come into the room at the same time as you, and do something else entirely, like fluff your brother's pillow. You will then give him an identical radio, that also hooks into your brother's radio, and inform him to wait and listen for the "i'm awake" signal.&lt;/p&gt;&lt;p style="clear: both"&gt;Then, when your brother wakes up, he says "I'm awake!" and both you and your friend walk into the room. You say hi, and your friend fluffs the pillow, then you both exit.&lt;/p&gt;&lt;p style="clear: both"&gt;Later, if you decide you don't care to say hi anymore, you turn off your radio. Now, you have no idea when your brother is awake or not, because you aren't listening anymore.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="clear: both"&gt;So again, you are each classes in this example, and each of you have your own methods. You're playing a computer game (PlayComputerGame()), your friend is building a puzzle (BuildPuzzle()) and your brother is napping (Napping()). &lt;/p&gt;&lt;p style="clear: both"&gt;You create a delegate (ImAwake) that you set your brother to do, when he wakes up. You listen in on that delegate (giving yourself a radio and turning it on), and when you receive the message, you fire a new method called SayHi()). Your friend is also wired up to the same delegate (using an identical radio) and fires the method FluffPillow().&lt;/p&gt;&lt;p style="clear: both"&gt;Hopefully this makes sense, and helps shed some light on how delegates operate. Let me know! Feel free to drop me a line at Twitter (preferred method of contact) here: &lt;a href="http://www.twitter.com/samerabousalbi"&gt;samerabousalbi&lt;/a&gt;&lt;/p&gt;&lt;p style="clear: both"&gt;&lt;/p&gt;&lt;br class="final-break" style="clear: both" /&gt; &lt;img src="http://geekswithblogs.net/samerpaul/aggbug/139976.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>samerpaul</dc:creator>
            <guid>http://geekswithblogs.net/samerpaul/archive/2010/05/20/delegates-a-practical-understanding.aspx</guid>
            <pubDate>Thu, 20 May 2010 18:01:00 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/samerpaul/comments/139976.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/samerpaul/archive/2010/05/20/delegates-a-practical-understanding.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/samerpaul/comments/commentRss/139976.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/samerpaul/services/trackbacks/139976.aspx</trackback:ping>
        </item>
    </channel>
</rss>