当前位置:  编程技术>移动开发
本页文章导读:
    ▪Learn Object C(一) Learn Objective-C in Day 6 - 1 ~ 3        Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3 Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3What is Objective-CObjective-C is a strict superset of C, we are free to use C in an Objective-C file and it will compile fine.What will I need?S.........
    ▪ Java UML类图基准的总结        Java UML类图标准的总结 http://webservices.ctocio.com.cn/java/246/9194746.shtml以前在做一个项目之前总是在UML的一些概念上花费极大的功夫,得出的图形反而让自己都含糊不清。这两天一口气在网上查.........
    ▪ cygwin的装配       cygwin的安装 Android开发要用到NDK,装了一个虚拟机,老是不行。 后来安装了一个cygwin,安装完毕后unset home,再export NDK,就可以使用了,非常方便,不用像虚拟机那样经常切换。 ......

[1]Learn Object C(一) Learn Objective-C in Day 6 - 1 ~ 3
    来源: 互联网  发布时间: 2014-02-18
Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3

Learn Object C(1) Learn Objective-C in Day 6 - 1 ~ 3

What is Objective-C
Objective-C is a strict superset of C, we are free to use C in an Objective-C file and it will compile fine.

What will I need?
Since I installed Xcode on my MAC, I already have GCC.

Compiling your code
Open the MAC terminal and go to the work directory.
>cd /Users/carl/work/objective-c
>vi First.m
#include <stdio.h>
int main(){
    printf("Hello World\n");
    return 0;
}

>gcc First.m -o First
The system will compile the codes in First.m to machine codes into First.

Then I can run the codes with these commands>
>./First

I can get the println Hello World. I am a good student when I was in university while studying the C language.
That should be awesome to study objective-c from my understanding.

The Basics
int main(){
    printf("Hello World\n");
    return 0;
}

By convention, returning '0' signals to the calling program that our program finished execution without any errors.

Variables
int - for storing integers with no decimal point
char - for storing a character
float - for storing numbers with decimal points
double - same as float but double the accuracy

If we are not using variables, we are using constants. For instance, 123 + 2 = 125

Almost the same way of C language>
#include <stdio.h>
int main(){
     int someNumber = 123;
     printf("My number is %i \n", someNumber);
     return 0;
}

%i integer, %f float, %e double, %c char

Conditionals
int main(){
     if(1 == 1){
          //...snip...
     }
     return 0;
}

Loops
for (x = 0; x < 9; x++){
     printf("Count is: %i\n", x);
}

while ( x < 10){
     x++;
     printf("Count is: %i\n", x);
}

do {
     x++;
     printf("Count is: %i\n", x);
} while(x < 10);

Pointers
Pointers point to a location. Specifically, locations in computer memory. We have a variable named foo with value 123, we can also have a point points to foo.
int foo = 123;
int *ptr = &foo;

Wrapping Up
…snip…

Object Orientated Programming
Classes are made up of methods and attributes.

Interface and Implementation
Interface is a file that ends with a suffix of .h. Implementation is a file that ends with a suffix of .m.

Interface
@interface Car: NSObject 
@property (weak, nonatomic) IBoutlet UILabel *display;
- (void) addGas;
@end

Car is extends from Object NSObject

The "-" indicates that this is an instance method, not a class method.

Implementation
#import "Car.h"
@implementation Car
- (void) addGas {
}
@end

Classes from Apple
NS is abbreviation for NextStep.

NSString     immutable string
NSMutableString      mutable string
NSArray      immutable array
NSMutableArray       mutable array
NSNumber

Pointers and Initializing
File --> New Project ---> Mac OS X--> Application ---> Command Line Tool ----> Type: Foundation
#import <Foundation/Foundation.h>

int main(int argc, constchar * argv[]) {   

NSString *testString;                  

//pointer to NSString   

testString = [[NSString alloc] init];  

//have instance of NSString   

testString = @"sillycat test String";  

//@ a sign of NSString   

NSLog(@"only string= %@",testString);  

//%@ means an Objetive-C object   

return 0;
}

Inheritance
NSObject ---> NSString ----> NSMutableString
               ---> NSArray -----> NSMutableArray
               ---> NSValue -----> NSNumber


References:
http://www.otierney.net/objective-c.html.zh-tw.big5
http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/_index.html
http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/chapters/Introduction.html
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-1/

http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-2/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-3/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-4/

Objective C Book from Apple
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html


    
[2] Java UML类图基准的总结
    来源: 互联网  发布时间: 2014-02-18
Java UML类图标准的总结
http://webservices.ctocio.com.cn/java/246/9194746.shtml

以前在做一个项目之前总是在UML的一些概念上花费极大的功夫,得出的图形反而让自己都含糊不清。这两天一口气在网上查了很多相关文章,
  在图书管也翻了几本书,给自己定义了一个UML严格的标准。现在拿到网上来,兄弟们帮我看看有那些地方又不妥当的地方。相互学习....
  首先弄清楚类图是个什么东西:
  类图(class diagram)描述了模型的静态结构,包括模型中的类的类的内部结构以及于其他类的关系,在结构化设计一个系统的时候类图可以让我们的思路更加清晰。
  类的内部结构就不用说了,没什么好说的。
  一个类与其他的类常见的关系(我所接触到的关系)有:
  1.一般化关系
  2.关联关系
  3.聚合关系
  4.组合关系(合成关系)
  5.依赖关系
  其中,聚合关系合成关系又属于关联关系。
  一般化关系表现是与类之间是(is a)的关系。也就是类与类之间的继承,接口于接口之间的继承或者是对一个接口的实现。表示方法是用一个空心箭头+实线,箭头指向父类。或用空心肩头加虚线(如果富父类是接口的话)
  如图1,User定义了系统中一个用户的原型,客户Customer继承了User类并且有自己特有的方法。管理员Manager类也继承了User类,并且又自己特有的方法,而且Manager为了能够管理客户还实现了Cmanage这个接口,也就具备了Cmanage的所有功能,可以对客户的余额进行操作,而且还可以删除一个客户。
  
  关联关系表现为类与类之间的(has a)关系。它使一个类知道另一个类的属性和方法。关联关系表示的是类与类之间的持久关系,这种关系一般是表示一种业务逻辑上的关系,需要保存到数据库中的。
  如图2.学生Student中存在一个班级Class的引用。在student中可以直接根据引用访问到Class.同时在数据库中存在两张表tb_student,tb_class,在表tb_student中有一个字段存储了所关联的class记录的id。用箭头+实指向被关联的类
  
  聚合关系是关联的一种,是一种强关联关系。聚合关系还体现了一种整体与个体的关系。如图3:
  商品ShangPin是独立的,一张进货单JinHuoDan内可以又很多个商品。可以说进货单JinHuoDan是整体,商品ShangPin是个体。可以由进货单JinHuoDan导航到每个进货单包含的商品。空心菱形+实线+箭头指向部分。
  
  依赖关系是表现为类与类之间的一种(use a)的关系。一个类用到了另一个类,为了完成一特定的操作。但是类与类之间不存在业务逻辑上的关系。依赖关系是针对于程序来说的。依赖关系体现在程序中主要是些局部变量、方法参数、或对一个类方法的调用。如图四:
  商品管理类ShangPinManager主要对上提供查询商品,删除商品的功能,而这些功能的实现必须调用Dao类的某些方法来实现(一种调用关系)但是他和我们数据库持久类Dao没有业务上的关系,更不可能把这两个类存到数据库中去。虚线+箭头指向被调用的类。
  
  另外我个人觉得利用聚合足以体现合成,没必要分的那么详细。UML本身是一种工具,没必要把太多时间花费在工具的一些概念上面。

    
[3] cygwin的装配
    来源: 互联网  发布时间: 2014-02-18
cygwin的安装

Android开发要用到NDK,装了一个虚拟机,老是不行。 后来安装了一个cygwin,安装完毕后unset home,再export NDK,就可以使用了,非常方便,不用像虚拟机那样经常切换。


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截... iis7站长之家
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3