Leaving   Behind
Hello.


• Jake Behrens
• iPhone/Mobile Developer
• UI Designer
Hello.



• Freelancer (as of last Friday!)
Moments



• Choose, but choose wisely.
• Do it for the experience.
30,000 Ft.
Why?

• Knowledge.
• Code reuse.
• Performance.
• Custom = code.
• Tidbits here and there...
A Story
Delegates
Delegates



    Outlets
Delegates
              Location

    Outlets
Time
Code Reuse
Code vs. GUI

CGRect submitButtonFrame = CGRectMake(10.0, 276.0, 300.0, 130.0);
UIImage *tempSubmitButtonUp = [UIImage ima...
Snippets




www.snippetapp.com
Performance
Performance



• Benchmarks.
Performance

• View-based application
Performance

• View-based application
• With IB: 37ms
Performance

• View-based application
• With IB: 37ms
• Without IB: 23ms
Performance

• View-based application w/
  UIImageView
Performance

• View-based application w/
  UIImageView
• With IB: 47ms
Performance

• View-based application w/
  UIImageView
• With IB: 47ms
• Without IB: 25ms
Performance
Performance
Performance

1. Build your app.
2. Run
   > Run with Performance Tool
         > Core Animation
Performance
Performance
Performance

• 14 elements in each cell.
Performance

• 14 elements in each cell.
• With IB: 13-23 FPS
Performance

• 14 elements in each cell.
• With IB: 13-23 FPS
• Without IB: 43-60 FPS
Customizing


   Iʼm a button!!
Iʼm
      a
          bu
            tto
               n!
                  !
                      Customizing
Customizing

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0];
[UIView setAnimationDelegate:self]...
Customizing


   Iʼm a button!!
Iʼm
      a
          bu
            tto
               n!
                  !
                      Customizing
Tidbits &
Food 4 Thought
Source Control
<string key="NSFrame">{{20, 20}, {280, 37}}</string>
<string key="NSFrame">{{20, 20}, {280, 37}}</string>
myButton.frame = CGRectMake(20.0, 20.0, 280.0, 37.0);
myButton.frame = CGRectMake(20.0, 20.0, 280.0, 37.0);
Refactor...



• When changing a method name.
• IB doesnʼt fix your action.
Bug Report



• Great opportunity to tell Apple.
“Premature
optimization is the root
      of all evil.”
So now what?
Tutorials!
View-based Application
Resources



• Remove .xib files.
main.m

#import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool al...
main.m

#import <UIKit/UIKit.h>


int main(int argc, char *argv[]) {

    NSAutoreleasePool * pool = [[NSAutoreleasePool a...
AppDelegate.h

#import <UIKit/UIKit.h>

@class DemoViewController;

@interface AppDelegate : NSObject <UIApplicationDelega...
AppDelegate.h

#import <UIKit/UIKit.h>

@class DemoViewController;

@interface AppDelegate : NSObject <UIApplicationDelega...
AppDelegate.m


- (void)applicationDidFinishLaunching:(UIApplication *)application {

    // Override point for customizat...
AppDelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    window = [[UIWindow alloc] initWit...
Custom Xcode
  Templates
Why?



• Set it up the way you want it.
• Include libraries you use.
Path of Originals
AppDelegate.h

#import <UIKit/UIKit.h>

@class ___PROJECTNAMEASIDENTIFIER___ViewController;

@interface ___PROJECTNAMEASID...
Points of Interest



• Delete the build folder.
• .xcodeproj
Issues with updates...
Path to Customs
http://github.com/withfoam
Graphical Elements
     In Code
.h

#import <UIKit/UIKit.h>

@interface DemoViewController : UIViewController {
! UILabel *displayText;
}

@property (nona...
.m
#import "DemoViewController.h"

@implementation DemoViewController

@synthesize displayText;

#pragma mark -
#pragma ma...
.m

- (void)dealloc {
! [displayText release];
  [super dealloc];
}
Yay...
.m

- (void)loadView {
! [super loadView];
!
! displayText = [[UILabel alloc] init];
! [displayText setFrame:CGRectMake(20...
Yay...
UIButton...again.

CGRect submitButtonFrame = CGRectMake(10.0, 276.0, 300.0, 130.0);
UIImage *tempSubmitButtonUp = [UIImag...
RE:cap


• Increased performance.
• Organization.
• Little things.
Tuts


• Revert apps created for IB.
• Create customized project templates.
• Create graphical elements and
  objects in c...
Yell at me.

• http://jakebehrens.com

• @withfoam
• http://withfoam.com
• http://github.com/withfoam
Feel lucky?
• R634EJ39MA44
• 77Y7YEL9F6AR
• 3EKR3FAETJPF
• 4KT7EMWHP47P
• EMM4H9XTF6JT
• ERMFPKRR69X6
Hecklers? Questions?
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Leaving Interface Builder Behind
Upcoming SlideShare
Loading in...5
×

Leaving Interface Builder Behind

3,384

Published on

Want to squeeze every last bit of performance out of your apps? I will show you how to let go of using Interface Builder to create better performing, more optimized, and leaner apps. I'll walk you through why it's better, how to create and move projects off of IB, building your UI in code, and how to gain a better understanding of how your code works from the ground up.

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,384
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
92
Comments
1
Likes
8
Embeds 0
No embeds

No notes for slide

Transcript of "Leaving Interface Builder Behind"

  1. 1. Leaving Behind
  2. 2. Hello. • Jake Behrens • iPhone/Mobile Developer • UI Designer
  3. 3. Hello. • Freelancer (as of last Friday!)
  4. 4. Moments • Choose, but choose wisely. • Do it for the experience.
  5. 5. 30,000 Ft.
  6. 6. Why? • Knowledge. • Code reuse. • Performance. • Custom = code. • Tidbits here and there...
  7. 7. A Story
  8. 8. Delegates
  9. 9. Delegates Outlets
  10. 10. Delegates Location Outlets
  11. 11. Time
  12. 12. Code Reuse
  13. 13. Code vs. GUI CGRect submitButtonFrame = CGRectMake(10.0, 276.0, 300.0, 130.0); UIImage *tempSubmitButtonUp = [UIImage imageNamed:@"SubmitButton_Up.png"]; UIImage *tempSubmitButtonDown = [UIImage imageNamed:@"SubmitButton_Down.png"]; submitButton = [UIButton buttonWithType:UIButtonTypeCustom]; [submitButton setImage:tempSubmitButtonUp forState:UIControlStateNormal]; [submitButton setImage:tempSubmitButtonDown forState:UIControlStateHighlighted]; [submitButton setFrame:submitButtonFrame]; [submitButton addTarget:self action:@selector(submitReport) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:submitButton];
  14. 14. Snippets www.snippetapp.com
  15. 15. Performance
  16. 16. Performance • Benchmarks.
  17. 17. Performance • View-based application
  18. 18. Performance • View-based application • With IB: 37ms
  19. 19. Performance • View-based application • With IB: 37ms • Without IB: 23ms
  20. 20. Performance • View-based application w/ UIImageView
  21. 21. Performance • View-based application w/ UIImageView • With IB: 47ms
  22. 22. Performance • View-based application w/ UIImageView • With IB: 47ms • Without IB: 25ms
  23. 23. Performance
  24. 24. Performance
  25. 25. Performance 1. Build your app. 2. Run > Run with Performance Tool > Core Animation
  26. 26. Performance
  27. 27. Performance
  28. 28. Performance • 14 elements in each cell.
  29. 29. Performance • 14 elements in each cell. • With IB: 13-23 FPS
  30. 30. Performance • 14 elements in each cell. • With IB: 13-23 FPS • Without IB: 43-60 FPS
  31. 31. Customizing Iʼm a button!!
  32. 32. Iʼm a bu tto n! ! Customizing
  33. 33. Customizing [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0]; [UIView setAnimationDelegate:self]; myButton.transform = CGAffineTransformMakeRotation ([Utilities degreesToRadians:45]); [UIView commitAnimations];
  34. 34. Customizing Iʼm a button!!
  35. 35. Iʼm a bu tto n! ! Customizing
  36. 36. Tidbits & Food 4 Thought
  37. 37. Source Control
  38. 38. <string key="NSFrame">{{20, 20}, {280, 37}}</string>
  39. 39. <string key="NSFrame">{{20, 20}, {280, 37}}</string>
  40. 40. myButton.frame = CGRectMake(20.0, 20.0, 280.0, 37.0);
  41. 41. myButton.frame = CGRectMake(20.0, 20.0, 280.0, 37.0);
  42. 42. Refactor... • When changing a method name. • IB doesnʼt fix your action.
  43. 43. Bug Report • Great opportunity to tell Apple.
  44. 44. “Premature optimization is the root of all evil.”
  45. 45. So now what?
  46. 46. Tutorials!
  47. 47. View-based Application
  48. 48. Resources • Remove .xib files.
  49. 49. main.m #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; }
  50. 50. main.m #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @”AppDelegate”); [pool release]; return retVal; }
  51. 51. AppDelegate.h #import <UIKit/UIKit.h> @class DemoViewController; @interface AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; DemoViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet DemoViewController *viewController; @end
  52. 52. AppDelegate.h #import <UIKit/UIKit.h> @class DemoViewController; @interface AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; DemoViewController *viewController; } @property (nonatomic, retain) UIWindow *window; @property (nonatomic, retain) DemoViewController *viewController; @end
  53. 53. AppDelegate.m - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; }
  54. 54. AppDelegate.m - (void)applicationDidFinishLaunching:(UIApplication *)application { window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; ! ! viewController = [[DemoViewController alloc] init]; ! // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; }
  55. 55. Custom Xcode Templates
  56. 56. Why? • Set it up the way you want it. • Include libraries you use.
  57. 57. Path of Originals
  58. 58. AppDelegate.h #import <UIKit/UIKit.h> @class ___PROJECTNAMEASIDENTIFIER___ViewController; @interface ___PROJECTNAMEASIDENTIFIER___AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; ___PROJECTNAMEASIDENTIFIER___ViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet ___PROJECTNAMEASIDENTIFIER___ViewController *viewController; @end
  59. 59. Points of Interest • Delete the build folder. • .xcodeproj
  60. 60. Issues with updates...
  61. 61. Path to Customs
  62. 62. http://github.com/withfoam
  63. 63. Graphical Elements In Code
  64. 64. .h #import <UIKit/UIKit.h> @interface DemoViewController : UIViewController { ! UILabel *displayText; } @property (nonatomic, retain) UILabel *displayText; @end
  65. 65. .m #import "DemoViewController.h" @implementation DemoViewController @synthesize displayText; #pragma mark - #pragma mark Application lifecycle - (void)loadView { ! [super loadView]; ! ! displayText = [[UILabel alloc] init]; ! [displayText setFrame:CGRectMake(20.0, 20.0, 280.0, 30.0)]; ! [displayText setText:@"Hello 360iDev!"]; ! [displayText setFont:[UIFont fontWithName:@"Helvetica" size:14.0]]; ! [self.view addSubview:displayText]; }
  66. 66. .m - (void)dealloc { ! [displayText release]; [super dealloc]; }
  67. 67. Yay...
  68. 68. .m - (void)loadView { ! [super loadView]; ! ! displayText = [[UILabel alloc] init]; ! [displayText setFrame:CGRectMake(20.0, 20.0, 280.0, 30.0)]; ! [displayText setText:@"Hello 360iDev!"]; ! [displayText setFont:[UIFont fontWithName:@"Helvetica" size:24.0]]; ! [displayText setBackgroundColor:[UIColor blackColor]]; ! [displayText setTextColor:[UIColor greenColor]]; ! [displayText setTextAlignment:UITextAlignmentCenter]; ! [self.view addSubview:displayText]; }
  69. 69. Yay...
  70. 70. UIButton...again. CGRect submitButtonFrame = CGRectMake(10.0, 276.0, 300.0, 130.0); UIImage *tempSubmitButtonUp = [UIImage imageNamed:@"SubmitButton_Up.png"]; UIImage *tempSubmitButtonDown = [UIImage imageNamed:@"SubmitButton_Down.png"]; submitButton = [UIButton buttonWithType:UIButtonTypeCustom]; [submitButton setImage:tempSubmitButtonUp forState:UIControlStateNormal]; [submitButton setImage:tempSubmitButtonDown forState:UIControlStateHighlighted]; [submitButton setFrame:submitButtonFrame]; [submitButton addTarget:self action:@selector(submitReport) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:submitButton];
  71. 71. RE:cap • Increased performance. • Organization. • Little things.
  72. 72. Tuts • Revert apps created for IB. • Create customized project templates. • Create graphical elements and objects in code.
  73. 73. Yell at me. • http://jakebehrens.com • @withfoam • http://withfoam.com • http://github.com/withfoam
  74. 74. Feel lucky? • R634EJ39MA44 • 77Y7YEL9F6AR • 3EKR3FAETJPF • 4KT7EMWHP47P • EMM4H9XTF6JT • ERMFPKRR69X6
  75. 75. Hecklers? Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×