随笔分类 - iOS
摘要:原文:http://blog.sunnyxx.com/2014/08/02/objc-weird-code/[娱乐向]objc最短的方法声明先来个娱乐向的。方法声明时有一下几个trick:返回值的- (TYPE)如果不写括号,编译器默认认为是- (id)类型:12- init;- (id)init;...
阅读全文
摘要:原文地址:http://blog.sunnyxx.com/2014/09/15/objc-attribute-cleanup/编译器属性__attribute__用于向编译器描述特殊的标识、检查或优化,几个常用的用法看《mattt大神的文章》就好。今天发现一个名为cleanup的黑魔法属性,简单介绍...
阅读全文
摘要:判断一个对象是否实现了某方法,而非继承而来。#import - (BOOL)realRespondsToSelector:(SEL)selector{ BOOL result = NO; u_int count; Method *methods= class_copyMethodL...
阅读全文
摘要:http://shaheengandhi.com/controlling-thread-exit/While most concurrency can be dealt with by using GCD dispatch queues, there are some things for which you will want to use a separateNSThread. For instance, concurrent network programming remains mostly in this area. You may consider using the popula
阅读全文
摘要:NSOutputStream-保存网络资源到本地_filePath= [[NetworkManagersharedInstance]pathForTemporaryFileWithPrefix:@"Get"];_fileStream= [NSOutputStreamoutputStreamToFileAtPath:self.filePathappend:NO];[_fileStreamopen];2.进行网络请求,并返回网络的数据。通过输出流对象,将数据写入到指定的文件中。- (void)connection:(NSURLConnection*)connection did
阅读全文
摘要:https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40013501-CH1-SW1Table 1-1Size and alignment of integer data types in OS X and iOSInteger data typeILP32 sizeILP32 alignmentLP64 sizeLP64 alignmentchar1 b
阅读全文
摘要:- (void)drawRectFor7{#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_7_0 UIFont *font = [UIFont boldSystemFontOfSize:_fontSize]; NSDictionary *attributes = nil; NSDictionary *strokeAttributes = nil; if (_useLightText) { strokeAttributes = [NSDictionary dictionaryWithObj...
阅读全文
摘要:原文:http://www.tanhao.me/pieces/1104.htmlNSLog(NSString *format, ...)+(id)arrayWithObjects:(id)firstObj, ...+(id)dictionaryWithObjectsAndKeys:(id)firstObject , ...需要用到C语言中关于变参的一组宏:va_start,va_arg,va_end函数调用:[self method:@"1",@"2",@"3",nil];像大多数变参函数一样,未尾一定要加上nil,因为这一组宏都没有
阅读全文
摘要:原文:http://db-in.com/blog/2011/07/universal-framework-iphone-ios-2-0/原文废话太多啊,自己总结一下,因为我是在原有的静态库工程基础上建立的,所以新建一个target就好了。1 新建target,macOS中的bundle:2 接下来设置bundle的build setting:(直接复制了)Base SDK: Latest iOS (iOS X.X) (in the X.X will appear the number of the lastest iOS SDK installed on your machine).Archi
阅读全文
摘要:1.下载文件 (http://code.google.com/p/protobuf/ )并解压到本地文件夹。2.确认安装过GCC(可以在终端下输入gcc - -version 测试).如果电脑上没有安装过GCC的话,你在下面步骤中会看到提示"$PATH路径中没有C编译器"(原话不记得怎么写的了,就是这个意思)。通常做开 发的MAC上都装过Xcode,很多人都说装过Xcode默认都有GCC,但我发现并不是这样,可以这样再单独安装:Xcode->Preferences->Downloads下的Components下,选择安装Command Line Tools。3.
阅读全文
摘要:Memory ManagementAll memory in a computer program must be allocated before it can be used and if you want to reuse that memory later for another purpose, it must be deallocated when you are done with it.In garbage collected environments, programmers don't need to handle the allocation and deallo
阅读全文
摘要:概述UIView对象在屏幕中定义了一个复杂区域和界面来管理这个区域的内容视图的职责:画图和动画。布局和子视图管理。事件处理。1、创建一个视图对象CGRect viewRect = CGRectMake(10,10,100,100);UIView* myView = [[UIView alloc] initWithFrame:viewRect];[self.window addSubview :myView];//将视图作为子视图添加到window中2、动画改变一些视图属性将会使用到动画,改变属性时创建一个动画,用于给用户传递在较短时间内的变化。UIView类做了动画展现的大部分工作,但是你仍然
阅读全文
摘要:#ifdef DEBUG #define MALog(...) NSLog(__VA_ARGS__); #define MALog_Func(x) NSLog(@"%s: L%d :%@", __func__, __LINE__, (x)); #define MALogStack NSLog(@"%s: L%d :%@", __func__, __LINE__, [NSThread callStackSymbols]);#else #define MALOG(...); #define MALog_Func(x); #define MALogStack;
阅读全文
摘要:首先设定环境变量:真机:export IPHONEOS_DEPLOYMENT_TARGET="4.3"export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"export CFLAGS="-arch armv7 -arch armv7s -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Develope
阅读全文
摘要:#import"GTMBase64.h"//utf-7 需要用到GTMBase64- (NSString *)stringFromUTF7String:(NSString *)utf7String{ NSMutableString *result = [NSMutableString string]; NSInteger location = 0; NSInteger len = 0; BOOL isBase64 = NO; for (int i = 0; i < utf7String.length; i++) { unichar ch = [utf7String c
阅读全文
摘要:1+ (AFTwitterAPIClient *)sharedClient { static AFTwitterAPIClient *_sharedClient = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ _sharedClient = [[AFTwitterAPIClientalloc] initWithBaseURL:[NSURLURLWithString:kAFTwitterAPIBaseURLString]]; }); return _sharedClient;}2stat...
阅读全文
摘要:-initWithNibName:bundle: 里面不要执行内容。
阅读全文
摘要:有些时候我们想让UIButton的title居左对齐,我们设置btn.textLabel.textAlignment = UITextAlignmentLeft是没有作用的,我们需要设置btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;但是问题又出来,此时文字会紧贴到做边框,我们可以设置btn.contentEdgeInsets = UIEdgeInsetsMake(0,10,0,0);使文字距离做边框保持10个像素的距离。
阅读全文
摘要:下载文件之前获得文件大小[m_pASIHTTPRequest setDidReceiveResponseHeadersSelector:@selector(didReceiveResponseHeaders:)];- (void)didReceiveResponseHeaders:(ASIHTTPRequest *)request{NSLog(@"didReceiveResponseHeaders %@",[m_request.responseHeaders valueForKey:@"Content-Length"]);}
阅读全文
摘要:在Info.plist里添加一行配置信息即可设置Application supports iTunes file sharing为YES.以下是返回该目录下文件路径的代码:-(NSString*)shareFilePath:(NSString*)filePath {NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString *documentsDirectory = [paths objectAtIndex:0];return [documents
阅读全文

浙公网安备 33010602011771号