This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class func askDevice() -> NSData?{ | |
// devicePacket packet = {PACKET_HEADER_HEAD,0,PACKET_HEADER_DEVICE_ID_UNKNOWN,COMMAND_ASK_DEVICE,0}; | |
// | |
// size_t headerSize = sizeof(packet.deviceHeader); | |
// size_t contentSize = 0; | |
// size_t size = headerSize + contentSize; | |
// packet.deviceHeader.len = contentSize; | |
// | |
// packet.deviceHeader.checksum = [self checksumWithBytes:(Byte *)&packet.deviceHeader WithSize:(int)size]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class packetFactory{ | |
class func sender<T where T:Constructible, T:Packable>(command:devicePacketHeader.commandType,content:T) -> devicePacketSender<T>?{ | |
var header:devicePacketHeader | |
switch (command,content){ | |
case (.ASK_DEVICE,let TAsk) where TAsk is devicePacketNil: | |
header = devicePacketHeader(deviceID: .UNKNOWN, command: command, len:Int16(sizeof(T))) | |
// case (_,let TNil) where TNil is devicePacketNil: | |
// fallthrough |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol Constructible { | |
init() | |
} | |
struct devicePacketHeader{ | |
var head:Byte = 1; | |
var checksum:Byte = 2; | |
var deviceID:Byte = 3; | |
var command:Byte = 4; | |
var len:Int16 = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface XARC : NSObject | |
@property(nonatomic,strong) NSString* text; | |
@end | |
@implementation XARC | |
//-(NSString *)text{ | |
// return _text; | |
//} | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source : http://blog.csdn.net/yiya1989/article/details/7849588 | |
#define myprintf(...) printk("[lch]:File:%s, Line:%d, Function:%s," \ | |
__VA_ARGS__, __FILE__, __LINE__ ,__FUNCTION__); | |
//source : http://stackoverflow.com/questions/969130/how-to-print-out-the-method-name-and-line-number-and-conditionally-disable-nslog | |
#ifdef DEBUG | |
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) | |
#else | |
# define DLog(...) | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// VerticallyAlignedLabel.m | |
// | |
#import "VerticallyAlignedLabel.h" | |
@implementation VerticallyAlignedLabel | |
@synthesize verticalAlignment = verticalAlignment_; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// VerticallyAlignedLabel.h | |
// | |
#import <Foundation/Foundation.h> | |
typedef enum VerticalAlignment { | |
VerticalAlignmentTop, | |
VerticalAlignmentMiddle, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Label2.mm | |
// (c) 2009 Ivan Misuno, www.cuberoom.biz | |
#import "Label2.h" | |
@implementation Label2 | |
-(id)initWithFrame:(CGRect)frame | |
{ | |
self = [super initWithFrame:frame]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Label2.h | |
// (c) 2009 Ivan Misuno, www.cuberoom.biz | |
#import <UIKit/UIKit.h> | |
typedef enum | |
{ | |
VerticalAlignmentTop = 0, // default | |
VerticalAlignmentMiddle, | |
VerticalAlignmentBottom, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeAlert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert]; | |
UIAlertController* __weak weakAlert = changeAlert; | |
UIAlertAction *alertActionOk = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { | |
UITextField *t = [[weakAlert textFields] firstObject]; | |
DLog(@"%@",t.text); | |
[weakAlert dismissViewControllerAnimated:YES completion:nil]; | |
}]; | |
UIAlertAction *alertActionCancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { | |
DLog(@"%@",action); |