随笔分类 - iOS
摘要:assign: 简单赋值,不更改索引计数copy: 建立一个索引计数为1的对象,然后释放旧对象retain:释放旧的对象,将旧对象的值赋予输入对象,再提高输入对象的索引计数为1Copy其实是建立了一个相同的对象,而retain不是:比如一个NSString对象,地址为0×1111,内容为@”STR”Copy到另外一个NSString之 后,地址为0×2222,内容相同,新的对象retain为1, 旧有对象没有变化retain到另外一个NSString之 后,地址相同(建立一个指针,指针拷贝),内容当然相同,这个对象的retain值+1也就是说,retain是指针拷贝,cop
阅读全文
摘要:----------------------- Page 1----------------------- Daniel's Objective-C Coding Style Guidelines From: 杨德升 /http://desheng.me/desheng.young@gmail.com Date: 2010.10.31 参考资料: • Apple:Coding Guidelines for Cocoa • Google:Objective-C Style Guide • Three20:Source code style guildelines 正文: • 格式化代码
阅读全文
摘要:.h#import <UIKit/UIKit.h>#import <CoreLocation/CoreLocation.h>#import <MapKit/MapKit.h>@interface SecondViewController : UIViewController<CLLocationManagerDelegate,MKMapViewDelegate,NSURLConnectionDataDelegate,NSURLConnectionDelegate>{ IBOutlet UIView *mapBottomView; IBOutlet
阅读全文
摘要:1:相机&从相册中获取图片.h记得导入<UIImagePickerControllerDelegate,UINavigationControllerDelegate,MFMailComposeViewControllerDelegate>.m://// ViewController.m// LessonHardWare//// Created by cyy on 13-1-29.// Copyright (c) 2013年 LanOuKeJi. All rights reserved.//#import "ViewController.h"@interf
阅读全文
摘要:set方法:-(void)setName:(NSString *)name{ if (_name != name) { [_name release]; [name retain]; _name = name; }}凡是.h里面的带星号变量或者属性的都要在dealloc中release一下 [_name release];这样释放 或者self.xxx = nil;这种更好get方法:-(UILabel *)titleLable{ if (_titleLable == nil) { _titleLable = [[UILabelalloc]init]; ...
阅读全文
摘要://// MyViewController.m// ReadWrite//// Created by lanou on 12-12-30.// Copyright (c) 2012年 lanou. All rights reserved.//#import "MyViewController.h"@interfaceMyViewController ()@end@implementation MyViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleO
阅读全文
摘要://// ScrollViewController.m// MyScrollView//// Created by lanou on 12-12-20.// Copyright (c) 2012年 lanou. All rights reserved.//#import "ScrollViewController.h"@interfaceScrollViewController ()@end@implementation ScrollViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NS
阅读全文
摘要://// ScrollViewController.m// MyScrollView//// Created by lanou on 12-12-20.// Copyright (c) 2012年 lanou. All rights reserved.//#import "ScrollViewController.h"@interfaceScrollViewController ()@end@implementation ScrollViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NS
阅读全文
摘要://// MyImageViewController.m// MyImageView//// Created by lanou on 12-12-19.// Copyright (c) 2012年 lanou. All rights reserved.//#import "MyImageViewController.h"@interfaceMyImageViewController ()@end@implementation MyImageViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:
阅读全文
摘要://// ImageViewController.m// TestImageView//// Created by lanou on 12-12-19.// Copyright (c) 2012年 lanou. All rights reserved.//#import "ImageViewController.h"@interfaceImageViewController ()@end@implementation ImageViewController-(void)dealloc{ [_imageViewrelease]; [super dealloc];}- (id)
阅读全文
摘要://// DoodleViewController.m// UI4practice//// Created by lanou on 12-12-17.// Copyright (c) 2012年 lanou. All rights reserved.//#import "DoodleViewController.h"#import "Doodleview.h"@interfaceDoodleViewController ()@end@implementation DoodleViewController- (id)initWithNibName:(NSS
阅读全文
摘要:atomic和nonatomic用来决定编译器生成的getter和setter是否为原子操作。atomic设置成员变量的@property属性时,默认为atomic,提供多线程安全。在多线程环境下,原子操作是必要的,否则有可能引起错误的结果。加了atomic,setter函数会变成下面这样:{lock}if (property != newValue) {[property release];property = [newValue retain];}{unlock}nonatomic禁止多线程,变量保护,提高性能。atomic是Objc使用的一种线程保护技术,基本上来讲,是防止在写未完成的时
阅读全文
摘要::NSTimer的使用方法[NSTimerscheduledTimerWithTimeInterval:0.2target:selfselector:@selector(changeColor)userInfo:nilrepeats:YES];//让NSTimer消失的方法[_timer invalidate];:AVAudioPlayer的简单使用 //创建音乐文件路径NSString* musicFilePath = [[NSBundlemainBundle]pathForResource:@"jnstyle"ofType:@"mp3"];//根据路
阅读全文
摘要://设置button文字阴影颜色在高亮状态显示 [buttonsetTitleShadowColor:[UIColorblueColor]forState:UIControlStateHighlighted];//为button文字设置阴影位置 [button.titleLabelsetShadowOffset:CGSizeMake(3, 3)];//为button文字设置字体大小 button.titleLabel.font= [UIFontsystemFontOfSize:23];
阅读全文
摘要:-(void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event{if(![self.txtField isExclusiveTouch]) { [self.txtField resignFirstResponder]; }}
阅读全文
摘要://创建imageViewself.imageView= [[UIImageViewalloc]initWithFrame:CGRectMake(0, 40, 320, 260)];//把图片添加到动态数组NSMutableArray* animateArray = [[NSMutableArrayalloc]initWithCapacity:20]; [animateArrayaddObject:[UIImageimageNamed:@"t1.png"]]; [animateArrayaddObject:[UIImageimageNamed:@"t2.png&q
阅读全文

浙公网安备 33010602011771号