[object-c 2.0 程序设计]object-c review (一)
//
// main.m
// cmdTry
//
// Created by Calos Chen on 2017/8/21.
// Copyright © 2017年 Calos Chen. All rights reserved.
// #import <Foundation/Foundation.h> @class Fraction;
@interface Fraction : NSObject
{
int numberator;
int denominator;
NSString* name;
double price;
Fraction *myf;
}
@property double price;
-(void) print;
-(void) setNumberator: (int)n;
-(void) setName: (NSString*)na;
-(void) setInfo: (int) id name:(NSString*)name; @end @implementation Fraction @synthesize price; -(void) print
{
NSLog(@"%i it is %@",numberator,name);
}
-(void) setNumberator:(int)n
{
price=5;
numberator=n;
}
-(void)setName:(NSString *)na{
name=na;
} -(void) setInfo:(int)id name:(NSString *)na{
id=id;
name=na;
} @end //---- program section ---- int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
NSLog(@"who are you!");
} NSLog(@"why is it");
Fraction *myf= [[Fraction alloc] init];
[myf setName:@"calos"];
[myf print]; int a1=5;
float a2=3.23;
double a3=3.44;
char a4='c';
int a5=(int)a2;
for (int b=1; b<10;b++ ) {
a5+=b;
}
myf.price=88;
double b1=myf.price;
BOOL isPrime=NO;
NSLog(@"%i %f %e %c %i %c %g",a1,a2,a3,a4,a5,isPrime,b1);
NSLog(@"end........"); return 0;
} //for today: 2017-08-21, I have read and practiced the first 153 pages of the object-c 2.0, now, I have known object-c classes and data types, and how to announce and implement the classes and class members, as well as functions in the class implementation. also property synthesize methods. loops.
//homework: implement a new class, and new interface and fill the class with members and all tangible members, then use all of them. @class declaration. So, write a console program with object-c.
今天在 object-c 方面取得了一定的进展, 既然不能左右时间,不如静心来好好打一番基础,感觉这个 oc 的基础是不会过时的. 现在已经能做到的是,object-c 的基本语法,类,数据类型,基本使用方法, 方法,属性,格式化等的声明.
[object-c 2.0 程序设计]object-c review (一)的更多相关文章
- document.forms[0].submit object is not a function
今天在做项目的时候发现了一个问题:document.forms[0].submit object is not a function. 这个问题是在用JavaScript 代码来提交一个表单时发生的. ...
- Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
报错: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlace ...
- * -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]’
错误描述: * -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object fr ...
- 原型相关的方法isPrototypeOf、Object.getPrototypeOf、hasOwnProperty、Object.getOwnPropertyName、Object.keys
在看<高程3>第六章的<面向对象的程序设计>的原型那一节时,有一下5个函数,功能较为接近,但是又都很基础,很重要 所以在此,加以说明,以便日后复习 function Perso ...
- Android学习笔记_46_Android的intent之间Object、List、List<Object>和全局变量数据的传递(Parcelable Serializable)
转http://blog.csdn.net/pku_android/article/details/7456305 一.传递List<String>和List<Integer> ...
- List<List<Object>> list = new ArrayList<List<Object>>(); 求回答补充问题 list.get(position).add(Object);为什么会报错啊我想在对应的list里面添加对象
public static void main(String[] args){ List<List<Object>> list = new ArrayList<List& ...
- PHP json_decode object时报错Cannot use object of type stdClass as array
PHP json_decode object时报错Cannot use object of type stdClass as array php再调用json_decode从字符串对象生成json对象 ...
- 自己写的demo。List<HashMap<String,Object>>=new ArrayList<HashMap<String,Object>>
package com.pb.collection; import java.util.ArrayList; import java.util.HashMap; import java.util.It ...
- 关于 warning CS0659:“***”重写Object.Equals(object o)但不重写Object.GetHashCode()
对象相等性和同一性 System.Object 类型提供了以下方法, namespace System { // // 摘要: // 支持 .NET Framework 类层次结构中的所有类,并为派生 ...
- Object类 任何类都是object类的子类 用object对象接收数组 object类的向上向下转型
任何类都是object类的子类 用object对象接收数组 object类的向上向下转型
随机推荐
- 激活Windows Server 2008R2
1. 用管理员身份运行mini-KMS_Activator_v1.053_ENG 2. 点击倒数第二个菜单Activation Windows VL 选择数字1 下一步选择Y 不管后面报不报错 3. ...
- MySQL高可用之PXC安装部署(续)
Preface Yesterday I implemented a three-nodes PXC,but there were some errors when proceeding ...
- spring mvc 返回xml格式数据
1.问题 : 因为业务需要,需要发送xml格式的数据,使用spring mvc 自己解析,就不用费心去自己搞这些东西. 2.解决: 新建一个实体类,直接在实体类中添加注解即可,如下: @XmlRoot ...
- Spring 整合 Shiro
一.引入依赖 <!-- spring start --> <dependency> <groupId>org.springframework</groupId ...
- springMVC前后台数据交互
假设项目需求是在springMVC框架下,后台要传送一个list到前台,那我们就要做以下几个步骤: 1 在web.xml文件中进行springMVC的配置: <?xml version=&quo ...
- WIN8/8.1/10换系统常见的几个问题
1.如果高级选项中没有UEFI固件设置,这该怎么进入BIOS呢? 答:还有一种方法是,首先关闭快速启动,然后重启,开机画面出来之后按F1,F2,F12,delete,总有一个是对的(不确定的话可以四个 ...
- 第四次JAVA作业
public class TvbDog { public static void main(String[] args) { Dog per=new Dog("陈狗"," ...
- ps学习笔记(二)
1)选择所有图层: Ctrl+Alt+A2)查找层:ctrl+alt+shift+f,需要在层面板输入查找层名,可自动查找层:3)隔离层:可将选择图层,更改为隔离,只对选择的层编辑:注:图层面板中有一 ...
- kibana和ElasticSearch的信息查询检索
使用kibana来进行ElasticSearch的信息查询检索 大家经常会听到使用ELK搭建日志管理平台.完成日志聚合检索的功能,那么这个平台到底是个什么概念,怎么搭建,怎么使用呢? ELK包括Ela ...
- SPOJ Repeats(后缀数组+RMQ-ST)
REPEATS - Repeats no tags A string s is called an (k,l)-repeat if s is obtained by concatenating k& ...