First Objective C
//
// main.m
// hello-objc
//
// Created by test5d on 14-9-29.
// Copyright (c) 2014年 test5d. All rights reserved.
// #import <Foundation/Foundation.h> @interface Fraction : NSObject -(void) print;
-(void) setNumberator: (int) n;
-(void) setDenominator:(int) d; @end @implementation Fraction
{
int numberator;
int denominator;
}
-(void) print{
NSLog(@"%i/%i",numberator,denominator);
}
-(void) setNumberator:(int)n{
numberator = n;
}
-(void)setDenominator:(int)d{
denominator = d;
} @end int main(int argc, const char * argv[]) {
@autoreleasepool {
Fraction *frac1 = [[Fraction alloc] init];
[frac1 setNumberator: 3];
[frac1 setDenominator: 4];
[frac1 print];
}
return 0;
}
First Objective C的更多相关文章
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- Objective C中的ARC的修饰符的使用---- 学习笔记九
#import <Foundation/Foundation.h> @interface Test : NSObject /** * 默认的就是__strong,这里只是做示范,实际使用时 ...
- Objective的字符串拼接 似乎没有Swift方便,但也可以制做一些较为方便的写法
NSString *str1 = @"字符串1"; NSString *str2 = @"字符串2"; //在同样条件下,Objective的字符串拼接 往往只 ...
- [转] 从 C 到 Objective C 入门1
转自: http://blog.liuhongwei.cn/iphone/objective-c/ 进军iPhone开发,最大的难点之一就是怪异的Objective C语法了.不过,了解之后才发现,原 ...
- Objective C运行时(runtime)
#import <objc/runtime.h> void setBeingRemoved(id __self, SEL _cmd) { NSLog(@"------------ ...
- Objective C ARC 使用及原理
手把手教你ARC ,里面介绍了ARC的一些特性, 还有将非ARC工程转换成ARC工程的方法 ARC 苹果官方文档 下面用我自己的话介绍一下ARC,并将看文档过程中的疑问和答案写下来.下面有些是翻译,但 ...
- Objective -C学习笔记之字典
//字典:(关键字 值) // NSArray *array = [NSArray array];//空数组 // NSDictionary *dictionary = [NSDictionary d ...
- 刨根问底Objective-C Runtime
http://chun.tips/blog/2014/11/05/bao-gen-wen-di-objective%5Bnil%5Dc-runtime-(2)%5Bnil%5D-object-and- ...
- Objective-C( Foundation框架 一 字符串)
Objective-C 中核心处理字符串的类是 NSString 与 NSMutableString ,这两个类最大的区别就是NSString 创建赋值以后该字符串的内容与长度不能在动态的更改,除非重 ...
- Objective C类方法load和initialize的区别
Objective C类方法load和initialize的区别 过去两个星期里,为了完成一个工作,接触到了NSObject中非常特别的两个类方法(Class Method).它们的特别之处,在于 ...
随机推荐
- java锁对象
在Java5中,专门提供了锁对象,利用锁可以方便的实现资源的封锁,用来控制对竞争资源并发访问的控制,这些内容主要集中在java.util.concurrent.locks 包下面,里面有三个重要的接口 ...
- 【JSP EL】使用EL表达式比较 动态选中 select中的option
<option value="${k.key }" ${KPIThis.parent.parent.thisId == k.key ? "selected" ...
- 九.Spring Boot JPAHibernateSpring Data
1.项目结构 2.导入jar包 <!-- 添加Spring-data-jpa依赖. --> <dependency> <groupId>org.springfram ...
- 利用pycharm进行重构学习记录
pycharm是非常强大的pythonIDE,集成了很多实用的功能,其中就包括重构Refactor 记录下使用pycharm的重构 pycharm的Refactor默认在主菜单上就有了 Refacto ...
- oracle 10g函数大全--数值型函数
ABS(x) [功能]返回x的绝对值 [参数]x,数字型表达式 [返回]数字 [示例] select abs(100),abs(-100) from dual; sign(x) [功能]返回x的正负值 ...
- POJ 1511 链式前向星+SPFA
#include<iostream> #include<cstdio> #include<cstdlib> using namespace std; const i ...
- python中子类调用父类的方法
1子类调用父类构造方法 class Animal(object): def __init__(self): print("init Animal class~") def run( ...
- 转:mac 设置root 密码
终端中输:sudo passwd rootpasswd root是修改root的命令,unix下sudo是以当前用户的身份执行root的命令,以避免输入root的密码但是sudo依赖于配置文件/etc ...
- 猜想:一组勾股数a^2+b^2=c^2中,a,b之一必为4的倍数。
证明: 勾股数可以写成如下形式 a=m2-n2 b=2mn c=m2+n2 而m,n按奇偶分又以下四种情况 m n 奇 偶 ① 偶 奇 ② 偶 偶 ③ 奇 奇 ④ 上面①②③三种情况中,mn中存在至少 ...
- Telnet服务配置
telnet:远程连接,使用未加密的用户/密码组进行验证,由xinetd服务管理.配置文件为/etc/xinetd.d/telnet Telnet服务的配置步骤如下: 一.安装telnet软件包 #r ...