Objective-C的入门学习笔记

2020-01-15 15:14:56于丽

@property (retain, nonatomic)IBOutlet UITabBarController *tabBarController;  
@end  

 

2.来看头文件得格式和申明

#import这个关键字没啥说的,java中叫导入。就是引入你当前类所要用到得依赖库和类。

@interface 申明开头关键字。 后面紧跟的是定义额类名  :后面的是继承得类 UIResponder ,< xxxxxxxxx>有点类似于java中得接口,当然 OC中有个

更加准确得定义就叫协议 ,<>放协议类。 整个申明最后都以@end结束。

{ }里面就是常说得申明成员变量。

@property 属性,我暂时理解为也有点成员变量的意思。 这个属性更多是和后面得m文件中的的synthesize关键字有密切联系。

(retain ,nonatomic)属性的一些参数。这个具体可以去看文档,估计C语言额同学应该不陌生,我不是很明确每个参数比较适合得场合。

IBOutlet 关键字,这个是和nib文件息息相关得,只要在nib文件中需要关联的对象,用这个修饰(比如我nib文件中有个window控件,要和代码中这个对象联系起来

,那么就用这个关键字申明),申明完后会看到这段代码最左端有个空心圆圈,当你和nib文件中控件关联后,就实心圆圈了。

复制代码
//  
//  NonoAppDelegate.m  
//  MultiViews  
//  
//  Created by Nono on 12-4-19.  
//  Copyright (c) 2012年 NonoWithLilith. All rights reserved.  
//  
  
#import "NonoAppDelegate.h"  
  
@implementation NonoAppDelegate  
  
@synthesize window;  
@synthesize tabBarController;  
  
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions  
{  
  //  self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  
    // Override point for customization after application launch.  
   // self.window.backgroundColor = [UIColor whiteColor];  
    self.window.rootViewController = self.tabBarController;  
    [self.window makeKeyAndVisible];  
    return YES;