oc 学习
来源:互联网 发布:2016年nba季后赛数据 编辑:程序博客网 时间:2024/06/06 07:17
#import<Foundation/Foundation.h>
#include<studio.h>
int main(int argc, char *argv[])
{
NSLog(@"hello the Cruel world!");
printf("hello world\n");
return 0;
}
clang -framework Foundation first.m -o app
./app
2.
使用NSDate打印系统时间
类方法alloc
实例方法init,dealloc
#import<Foundation/Foundation.h>
#include<studio.h>
int main(int argc, char *argv[])
{
NSDate *now = [NSDate alloc];
now = [now init]
NSLog(@"current time is %@", now);
NSLog(@"hello the Cruel world!");
printf("hello world\n");
[now dealloc];
return 0;
}
#import<Foundation/Foundation.h>
#include<studio.h>
int main(int argc, char *argv[])
{
char * s1="jeeedu.com";
char * s2="jeeedu.com";
if (0 == strcmp(s1,s2))
printf("equal\n");
else
printf("not equal\n");
NSString *c1= @"hello Jeapedu.com";
NSString *c2= @"hello Jeapedu.com";
if (c1 isEqual c2)
printf("equal\n");
else
printf("not equal\n");
return 0;
}
#import<Foundation/Foundation.h>
#include<studio.h>
@interface Horse : NSObject
{
float weight;
NSString *color;
float hegiht;
}
- (void) run;
- (void) carry;
@end
@implementation Horse
{
float price;
}
- (void) run
{
NSLog("a horse is running")
}
- (void) cray
{
NSLog("a horse is cray")
}
@end
int main(int argc, char *argv[])
{
Horse * ahorse = [Horse alloc];
ahorse = [ahosrs init];
[ahorse run];
ahorse cray];
return 0;
}
cat.h
#import <Foundation/Foundation.h>
@interface Cat : NSObject
{
NSString * catname;
}
+(void) descript;
-(void) mew : (int) times;
-(void) eat :(float) weight;
@end
cat.m
#import <Foundation/Foundation.h>
#import "cat.h"
@interface Cat
{
float price;
}
+(void) descript;
{
NSLog(@"class cat");
}
-(void) mew : (int) times
{
NSLog(@"class mew %d times", times);
}
-(void) eat :(float) weight
{
NSLog(@"class cat %f", weight);
}
@end
clang -c cat.m
#import<Foundation/Foundation.h>
#import "cat.h"
int main(int argc, char *argv[])
{
Cat * puppy = [Cat alloc];
puppy = [puppy init];
[Cat descript];
[puppy mew : 3];
[pup eat : 23.5];
NSLog(@"hello the Cruel world!");
printf("hello world\n");
return 0;
}
clang -framework Foundation -o app fourth.m cat.m
@property (assign) int z;
#include<studio.h>
int main(int argc, char *argv[])
{
NSLog(@"hello the Cruel world!");
printf("hello world\n");
return 0;
}
clang -framework Foundation first.m -o app
./app
2.
使用NSDate打印系统时间
类方法alloc
实例方法init,dealloc
#import<Foundation/Foundation.h>
#include<studio.h>
int main(int argc, char *argv[])
{
NSDate *now = [NSDate alloc];
now = [now init]
NSLog(@"current time is %@", now);
NSLog(@"hello the Cruel world!");
printf("hello world\n");
[now dealloc];
return 0;
}
#import<Foundation/Foundation.h>
#include<studio.h>
int main(int argc, char *argv[])
{
char * s1="jeeedu.com";
char * s2="jeeedu.com";
if (0 == strcmp(s1,s2))
printf("equal\n");
else
printf("not equal\n");
NSString *c1= @"hello Jeapedu.com";
NSString *c2= @"hello Jeapedu.com";
if (c1 isEqual c2)
printf("equal\n");
else
printf("not equal\n");
return 0;
}
#import<Foundation/Foundation.h>
#include<studio.h>
@interface Horse : NSObject
{
float weight;
NSString *color;
float hegiht;
}
- (void) run;
- (void) carry;
@end
@implementation Horse
{
float price;
}
- (void) run
{
NSLog("a horse is running")
}
- (void) cray
{
NSLog("a horse is cray")
}
@end
int main(int argc, char *argv[])
{
Horse * ahorse = [Horse alloc];
ahorse = [ahosrs init];
[ahorse run];
ahorse cray];
return 0;
}
cat.h
#import <Foundation/Foundation.h>
@interface Cat : NSObject
{
NSString * catname;
}
+(void) descript;
-(void) mew : (int) times;
-(void) eat :(float) weight;
@end
cat.m
#import <Foundation/Foundation.h>
#import "cat.h"
@interface Cat
{
float price;
}
+(void) descript;
{
NSLog(@"class cat");
}
-(void) mew : (int) times
{
NSLog(@"class mew %d times", times);
}
-(void) eat :(float) weight
{
NSLog(@"class cat %f", weight);
}
@end
clang -c cat.m
#import<Foundation/Foundation.h>
#import "cat.h"
int main(int argc, char *argv[])
{
Cat * puppy = [Cat alloc];
puppy = [puppy init];
[Cat descript];
[puppy mew : 3];
[pup eat : 23.5];
NSLog(@"hello the Cruel world!");
printf("hello world\n");
return 0;
}
clang -framework Foundation -o app fourth.m cat.m
@property (assign) int z;
0 0
- oc 学习
- oc 学习
- OC学习
- OC学习
- OC学习
- OC学习
- OC学习:OC字典NSDictionary
- OC学习:OC中的协议
- OC学习备忘
- Oc 学习笔记
- OC 基础学习笔记
- OC语法学习小结
- OC-0724学习总结
- OC学习之多态初解
- OC学习之NSString
- OC学习之NSArray
- OC学习之NSNumber
- OC学习之NSdate
- Tomcat设置默认访问项目及项目重复加载问题处理
- 如何在PC浏览器上看wap网站源码?
- Java中的反射逻辑
- ecshop ajax请求验证captcha(验证码)
- 转自http://www.cnblogs.com/hanyonglu/archive/2011/04/12/2014212.html C/C++堆、栈及静态数据区详解
- oc 学习
- The method of type must override a superclass method解决方式
- 百度面试:删除ansi编码中的字母和数字
- 几点上看到几点上看到浪费看电视看
- 配置一个ubuntu,任我玩耍任我游 (四)(转)
- 如何在Windows上安装Apache,MySQL和PHP
- 金属大师就开始考虑到
- 时间都冻死了健康的时刻
- 内存资源和内存泄漏