xcode禁用代码分析的警告和内存泄漏

在使用xcode进行iphone应用开发时,经常需要添加一些第三方的类库,而一些第三方的类库由于缺少维护,从而导致类库中含有各种警告和各种内存泄漏,但并不影响运行.


倘若我们需要用到第三方库,而由不想在代码分析时看到这些库的警告或内存泄漏,我需要这样做:

“-Wincompatible-pointer-types”为警告类型

clang为编译器名,这里也可以替换为GCC

#pragma clang diagnostic ignored后面只能跟一个忽略警告类型

如果需要同时忽略多种警告,需要这样写

另外使用xcode的Analyze进行代码分析时,xcode会检查出程序的内存泄漏,这个不属于编译警告,我们需要添加一个宏来把这些代码忽略

ios上的开源正则扩展类 RegexKitLite 就是一个充满各种内存泄漏的类,尽管作者已经在该类上注释说可以忽略这些内存泄漏的提示,但作为一个有代码洁癖的程序员,我还是不想看到这些内存泄漏的警告提示.

警告代码查找方法如下图

http://blog.waaile.com/clang-diagnostic-ignored/

项目地址

http://sourceforge.net/projects/devkitpro/files/

Previous Entry

ios应用开发中使用最多的控件莫过于就是UITableView了,而用于显示UITableView行的就是UITableViewCell.

UITableViewCell类默认有

1.创建一个新项目,选择SingleView模版.Product Name 输入 CustomCell ,Device Family 选择 iphone.

2.创建完毕后可见目录结构如下

3.打开CCViewController.xib,拖一个UITableView在view上,右击UITableView,分别dataSource和delegate链接到File’s Owner处.这里的FIle’s Owner就是CCViewController.

4.在CCViewControlller.m上添加以下代码
#import “CCViewController.h”

@interface CCViewController () <UITableViewDataSource,UITableViewDelegate>

@end

@implementation CCViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[...]

Next Entry

原文地址:https://www.cnblogs.com/zsw-1993/p/4879892.html