Learn Objective C(2)Learn Objective-C in Day 6 - 4 ~ 6
Car Example
Command-N (File ----> New File) ----> Cocoa Class under Mac OS X and select Objective-C
Name the class as SimpleCar and make it inherent from NSObject.
Interface and Implementation Coding
#import <Foundation/Foundation.h>
@interface SimpleCar : NSObject
@property (weak, nonatomic) NSString *make;
@property (weak, nonatomic) NSString *model;
@property (weak, nonatomic) NSNumber *vin;
-(void) setMake:(NSString*)newMake
andModel:(NSString*)newModel;
@end
That is the interface.
#import "SimpleCar.h"
@implementation SimpleCar
@synthesize make, model, vin;
-(void) setMake:(NSString *)newMake
andModel:(NSString *)newModel{
[selfsetMake: newMake];
[selfsetModel: newModel];
}
@end
Here is the implementation. @properties and @synthesize make it easy to do something like getter and setter.
References:
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-4/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-5/
http://mobile.tutsplus.com/tutorials/iphone/learn-objective-c-day-6/
Objective C Book from Apple
https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html
http://blog.sina.com.cn/s/blog_61bd8a8b01018tla.html
服务摘要 saeapns(SAE - Apple Push Notification Service),是SAE为iOS开发者提供的可以 快速、简单实现苹果的消息推送的服务。 应用场景 快速实现iOS的消息推送 (Apple Push Notification Service) PHP调用方式 使用指南
include_once("saeapns.class.php"); /* int $cert_id 许可证序号(1-10)*/ $cert_id = 12345; /* string $device_token 设备令牌 */ $device_token = 'xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx'; /* string $message 消息内容 */ $message = date('Y-m-d H:i:s') . ": \n" . '测试消息 from SAE'; /* array $body 消息体(包括消息、提醒声音等等),格式请参考示例和Apple官方文档 */ $body = array( 'aps' => array('alert' => $message, 'badge' => 1, 'sound' => 'in.caf'), 'others' => array() ); //实例化SaeAPNS $apns = new SaeAPNS(); //推送消息 $result = $apns->push($cert_id, $body, $device_token); if ($result !== false) { echo '发送成功'; } else { echo '发送失败'; var_dump($apns->errno(), $apns->errmsg()); }
详细介绍:http://saeapns.sinaapp.com/doc.html
上传的地址:
http://sae.sina.com.cn/?m=push&app_id=这里改成你的应用ID&ver=1
文档看http://saeapns.sinaapp.com/doc.html 这个
MicroUSB图
--------------------------------------------------------------------------------------------------
MiniUSB图
-------------------------------------------------------------------------------------------------
充电线:按上图只接5V正负极即可。可以给移动电源、大部份手机平板充电。
(有极个别的充电器的MiniUSB接头是把5V正极与4脚短接了,只需把4脚线剪断就行了)
数据线:接图中标示接上4条线即可。
工程线:在数据线基础上,把4脚与5V正极短接即可。
OTG线:在数据线基础上,把4脚与5V负极短接即可。