2014年7月28日 星期一

改變Estimote beacon的uuid

Here is how to do this:
1. First, start ranging for the beacons using startRangingBeaconsInRegion: with the ESTBeaconManager class: http://estimote.github.io/iOS-SDK/Classes/ESTBeaconManager.html
2. Then use connectToBeacon method in ESTBeacon class:  http://estimote.github.io/iOS-SDK/Classes/ESTBeacon.html
3. Finally change the UUID using
writeBeaconProximityUUID:withCompletion: method in ESTBeacon class:http://estimote.github.io/iOS-SDK/Classes/ESTBeacon.html
This way you can change:
- UUID only
- UUID and major
- UUID, major and minor

2014年7月25日 星期五

如果不想show出scrollview的目前拖拉位置時

self.scrollView.showsVerticalScrollIndicator   = NO;
self.scrollView.showsHorizontalScrollIndicator = NO;

2014年7月23日 星期三

有時候會因為找不到segue的identifier name而crach

http://stackoverflow.com/questions/11874200/nsinvalidargumentexception-receiver-has-no-segue-with-identifier

這似乎是因為xcode的bug造成的,上面的回答是如果你run之前先clean專案,就會正常。

2014年7月21日 星期一

取得app版本和build

the "Version":
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
and the "Build":
NSString *build = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];

2014年7月20日 星期日

isKindOfClass, respondsToSelector

-(BOOL) isKindOfClass: classObj 判斷是否為某個類別或是其子類別的instance
-(BOOL) isMemberOfClass: classObj 判斷是否為某個類別的instance
-(BOOL) respondsToSelector: selector 判斷該instance是否有實作該命名的方法
+(BOOL) instancesRespondToSelector: selector 判斷該類別是否有實作該命名的方法
-(id) performSelector: selector

 //將你的方法包成selector
SEL sel = @selector (start:) ;
//判斷該instance是否有start:方法
if ([obj respondsToSelector:sel]) 
{
//執行selector方法
[obj performSelector:sel withObject:self]; 

2014年7月11日 星期五

利用Notification判斷裝置是否進入背景執行

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActiveBackground:) name:UIApplicationDidBecomeActiveNotification object:nil];
}

-(void)appDidEnterBackground:(NSNotification *)_notification
{
    isAppInBackground = YES;
    NSLog(@"App is in background");
}

-(void)appDidBecomeActiveBackground:(NSNotification *)_notification
{
    isAppInBackground = NO;
    NSLog(@"App is in foreground");
    [[UIApplication sharedApplication] cancelAllLocalNotifications];

}

2014年7月10日 星期四

還原程式碼工具

//反組譯工具 Java Decompiler
JD-GUI0.3.6_Portable.exe

//反解apk工具 apkstudio
vpz-apkstudio-net-3.5

//利用url抓取apk
http://apps.evozi.com/apk-downloader/