iOS 5 app designing

Discussion in 'iOS Programming' started by rahulratthen91, May 4, 2012.

  1. rahulratthen91, May 4, 2012
    Last edited by a moderator: May 4, 2012

    rahulratthen91 macrumors newbie

    Joined:
    May 4, 2012
    #1
    Guys,
    I am new to app designing. I've been through several tutorials but most of them are for lesser versions of Xcode. I am breaking my head as what the problem would be in this code!
    Code:
    - (BOOL)application: (UIApplication * )application didFinishLaunchingWithOptions: (NSDictionary * )launchOptions
    {
        // Override point for customization after application launch.
        UILabel *mylabel;
        mylabel=[[UILabel alloc]initWithFrame:CGRectMake(25,25,100,100)];
        mylabel.text=@"hi";
        mylabel.font=[UIFont systemFontOfSize:20];
        [_window addSubview:mylabel];
        [mylabel release];
        [_window makeKeyAndVisible];
        return YES;
    }
    
    i disabled Objective-C Automatic Reference Count feature since "release" was a problem. Now my code compiles and runs yet i dont find the "hi" on my iphone simulator.


    And also i was going through the Nib files creation. I created a subclass of UIView and created an empty Nib file. Just dragged a view and a label into it and connected it with the UILabel variable declared in the .h file.Also connected the IBOutlet label with the view. Added the linking lines
    Code:
    NSArray *screens=[[NSBundle mainBundle] loadNibNamed:@"mynib" owner:self options:nil];          
    [self addSubview:[screens objectAtIndex:0]];
    
    in the .m file. Yet i get a plain white screen in IPhone simulator.

    Glad if someone can help me with these basics,

    Thanking in advance,
    Rahul

    Intel MBP 13' , OSx 10.7.3 , Xcode 4.3.2
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    Is _window nil? You do not create a window so are assuming one is created else where (main nib?)
     
  3. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    Novi, MI
    #3
    Shouldn't you just call self.window or just window
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Really yes.

    I am assuming they have declared _window as the variable and synthesized the property as window = _window. But that still leaves the possibility that nothing is actually assigned to _window.
     

Share This Page