//文件路徑獲取 NSString *Dir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSString *fileName = @"fileName"; NSString *filePath = [NSString stringWithFormat:@"%@/%@", Dir,fileName]; NSBundle *bundle = [NSBundle mainBundle]; NSString *bundleFilePath = [bundle pathForResource:@"chen" ofType:@"plist"]; NSData *data = [NSData dataWithContentsOfFile:bundleFilePath]; NSDictionary *dic = [[NSDictionary alloc] initWithContentsOfFile:bundleFilePath];
clang -rewrite-objc FileName
會在目錄下生成一個cpp文件objective-c
NSNumber *fortyTwo = @42; // 等價於 [NSNumber numberWithInt:42] NSNumber *fortyTwoUnsigned = @42U; // 等價於 [NSNumber numberWithUnsignedInt:42U] NSNumber *fortyTwoLong = @42L; // 等價於 [NSNumber numberWithLong:42L] NSNumber *fortyTwoLongLong = @42LL; // 等價於 [NSNumber numberWithLongLong:42LL] // 浮點數 NSNumber *piFloat = @3.141592654F; // 等價於 [NSNumber numberWithFloat:3.141592654F] NSNumber *piDouble = @3.1415926535; // 等價於 [NSNumber numberWithDouble:3.1415926535] // 布爾值 NSNumber *yesNumber = @YES; // 等價於 [NSNumber numberWithBool:YES] NSNumber *noNumber = @NO; // 等價於 [NSNumber numberWithBool:NO] //NSDictionary NSDictionary *dic = @{}; //NSArray NSArray *array = @[]; //NSMutableArray NSMutableArray *mutableArray = [@[]mutableCopy]; mutableArray[0] = @"object0"; mutableArray[1] = @"object2"; [mutableArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSLog(@"%@",obj); }]; //NSMutableDictionary NSMutableDictionary *mutableDic = [@{} mutableCopy]; mutableDic[@0] = @"dic0"; mutableDic[@1] = @"dic1"; [mutableDic enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { NSLog(@"%@",key); }];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { AVAudioSessionRouteDescription *des = [[AVAudioSession sharedInstance] currentRoute]; NSArray *a = des.outputs; for (AVAudioSessionPortDescription *s in a) { if ([s.portType isEqualToString:AVAudioSessionPortHeadsetMic] || [s.portType isEqualToString:AVAudioSessionPortHeadphones]) { NSLog(@"耳機"); return YES; } } } else { CFStringRef route; UInt32 propertySize = sizeof(CFStringRef); AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &route); if((route == NULL) || (CFStringGetLength(route) == 0)){ // Silent Mode NSLog(@"AudioRoute: SILENT, do nothing!"); } else { NSString* routeStr = (__bridge NSString*)route; NSLog(@"AudioRoute: %@", routeStr); /* Known values of route: * "Headset" * "Headphone" * "Speaker" * "SpeakerAndMicrophone" * "HeadphonesAndMicrophone" * "HeadsetInOut" * "ReceiverAndMicrophone" * "Lineout" */ NSRange headphoneRange = [routeStr rangeOfString : @"Headphone"]; NSRange headsetRange = [routeStr rangeOfString : @"Headset"]; if (headphoneRange.location != NSNotFound) { return YES; } else if(headsetRange.location != NSNotFound) { return YES; } } } return NO;
__weak SomeObjectClass *weakSelf = self;
dispatch_group_t group = dispatch_group_create(); dispatch_group_async(group, dispatch_get_global_queue(0,0), ^{ // 並行執行的線程一 }); dispatch_group_async(group, dispatch_get_global_queue(0,0), ^{ // 並行執行的線程二 }); dispatch_group_notify(group, dispatch_get_global_queue(0,0), ^{ // 彙總結果 });
+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect
+ (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect
+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:
+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii corners:枚舉值,能夠選擇某個角 cornerRadii:圓角的大小
參數: center:弧線中心點的座標 radius:弧線所在圓的半徑 startAngle:弧線開始的角度值 endAngle:弧線結束的角度值 clockwise:是否順時針畫弧線
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint 參數: endPoint:曲線的終點 controlPoint:畫曲線的基準點
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2 參數: endPoint:曲線的終點 controlPoint1:畫曲線的第一個基準點 controlPoint2:畫曲線的第二個基準點