IOS基础笔记(一)
来源:互联网 发布:通达信软件公式函数 编辑:程序博客网 时间:2024/04/30 12:06
XCode是一种集成环境(IDE),文本编辑器。
编写代码也就需要编译器,连接器,调试等构成了IDE的核心。
编译器的功能:检查语法错误。
连接器:CRT ( c runtime ) 检查代码种的一些定义,声明等等 多了,少了什么。
调试器:找逻辑上的错误(设置断点,单步执行)。
Cocoa Touch: 基于移动开发的库的集合
IOS :移动设备的操作系统
Mac OS X:苹果PC设备的操作系统,开发工具的使用环境
.h:存放声明
.m:实现方法(函数)
@interface 用来定义类
@end代码类的结束
堆里的对象的一个类存单元,返回的就是类存单元的首地址
alloc 动态分配了一个类存
init 初始化
1、initWithFormat是实例办法
只能经由过程 NSString* str = [[NSString alloc] initWithFormat:@"%@",@"Hello World"] 调用,然则必须手动release来开释内存资料
2、stringWithFormat是类办法
可以直接用 NSString* str = [NSString stringWithFormat:@"%@",@"Hello World"] 调用,内存经管上是autorelease的,不消手动显式release
#import <Foundation/Foundation.h>@interface Student : NSObject{ NSString *name; NSString *gender; NSInteger age;}@end
#import "Student.h"@implementation Student-(id)init{ if (self=[super init]) { name = @"Tom"; gender =@"male"; age=20; } return self;}-(NSString *)description{ return [NSString stringWithFormat:@"name=%@,gender=%@,age=%ld",name,gender,age];}@end
#import <Foundation/Foundation.h>#import "Student.h"int main(int argc, const char * argv[]){ Student * stu1 = [[Student alloc] init]; NSLog(@"%@",stu1); return 0;}
2014-12-10 21:14:59.870 OCText1[764:303] name=Tom,gender=male,age=20
//// Teacher.h// OSHw1//// Created by Nesusoft on 14-12-10.// Copyright (c) 2014年 IOS. All rights reserved.//#import <Foundation/Foundation.h>@class Student;@interface Teacher : NSObject{ NSString *name; NSString *teach; Student *student;}@end
//// Teacher.m// OSHw1//// Created by Nesusoft on 14-12-10.// Copyright (c) 2014年 IOS. All rights reserved.//#import "Teacher.h"#import "Student.h"@implementation Teacher-(id)init{ if (self=[super init]) { name=@"Lidan"; teach=@"OCLanguege"; student =[[Student alloc]init]; } return self;}-(NSString *)description{ return [NSString stringWithFormat:@"name=%@,tech=%@,student=%@",name,teach,student];}@end
//// Student.h// OSHw1//// Created by Nesusoft on 14-12-10.// Copyright (c) 2014年 IOS. All rights reserved.//#import <Foundation/Foundation.h>@interface Student : NSObject{ NSString *name; NSString *gender; NSInteger age; NSInteger idCard; NSInteger number;}-(void)hobby;@end
//// Student.m// OSHw1//// Created by Nesusoft on 14-12-10.// Copyright (c) 2014年 IOS. All rights reserved.//#import "Student.h"@implementation Student-(id)init{ if (self=[super init]) { name=@"Jack"; gender=@"female"; age=20; idCard=34123536; number=1100; } return self;}-(NSString *)description{ return [NSString stringWithFormat:@"name=%@,gender=%@,age=%ld,id=%ld,number=%ld",name,gender,age,idCard,number];}-(void)hobby{ NSLog(@"self in hobby %p",self); NSLog(@"play!!!");}@end
//// main.m// OSHw1//// Created by Nesusoft on 14-12-10.// Copyright (c) 2014年 IOS. All rights reserved.//#import <Foundation/Foundation.h>#import "Student.h"#import "Teacher.h"int main(int argc, const char * argv[]){ Student *stu=[[Student alloc]init]; NSLog(@"%@",stu); NSLog(@"stu=%p®\n",stu); [stu hobby]; Student *stu1=[[Student alloc]init]; NSLog(@"%@",stu1); NSLog(@"stu1=%p®\n",stu1); [stu1 hobby]; Teacher *teacher=[[Teacher alloc]init]; NSLog(@"%@\n",teacher); return 0;}
0 0
- IOS基础笔记(一)
- IOS基础学习笔记一:UIView学习
- iOS 复习笔记 UISlider基础篇(一)
- iOS开发学习笔记 (一)表视图基础 Table Views
- 黑马程序员:iOS基础——个人笔记(一)
- iOS UI学习笔记(一)UIView基础
- iOS学习笔记41-Swift(一)基础部分
- IOS学习笔记——object-C基础 (一)
- IOS学习笔记——基础界面 (一)
- 一、iOS初学笔记之swift的基础语法
- ios学习笔记一之Object-c基础
- ios(一) OC基础
- iOS基础一 NSNumber
- iOS基础一 NSString
- iOS基础一 NSArray
- iOS基础一 NSDictionary
- iOS基础一 NSSet
- iOS基础一 NSFileManager
- 算法与数据结构面试题(3)-求子数组的最大和
- C++输出缓冲区刷新
- Android SDK Manager国内下载缓慢的问题
- mactex+sublime text3+skim环境搭建
- win8 PL2303驱动的问题
- IOS基础笔记(一)
- python简介
- Android 4.4从图库选择图片,获取图片路径并裁剪
- 机器学习中的范数规则化
- 作品展示
- 4G的未来是什么?—LTE-Hi
- 矩阵 快速幂
- primefaces的selectonemenu的奇怪的规定
- Xampp安装过程总结(主要针对mysql和phpmyadmin)-很全的了