Fork me on GitHub
上一页 1 ··· 79 80 81 82 83 84 85 86 87 ··· 125 下一页

2012年3月1日

摘要: 使用NSFetchedResultsController和UITableView显示CoreData的数据时,如果用relationship作为分组的关键字。比如Contact和Group两个实例如下图:在显示的时候,创建NSFetchedResultsController/* Set up the fetched results controller. */ // Create the fetch request for the entity. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]... 阅读全文
posted @ 2012-03-01 09:16 pengyingh 阅读(3230) 评论(0) 推荐(0)
摘要: 1首先定义一个自定义类,如下@interfaceBookItem : NSObject{NSInteger booKDataID;NSString* bookName;NSString* bookDescription;NSString* bookFileName;NSInteger bookFileSize;NSString* recommendindex;NSDate* modifyTime;}@propertyNSInteger booKDataID;@property(nonatomic,retain) NSString* bookName;@property(nonatomic,re 阅读全文
posted @ 2012-03-01 08:29 pengyingh 阅读(5452) 评论(0) 推荐(0)
摘要: //// codeObj.h// encodeObject//// Created by 110 on 10-2-6.// Copyright 2010 __MyCompanyName__. All rights reserved.//#import <Cocoa/Cocoa.h>@interface codeObj : NSObject <NSCoding>{NSString *name;int magicNumber;float shoseSize;NSMutableArray *subThingies;}@property (copy) NSString *nam 阅读全文
posted @ 2012-03-01 07:06 pengyingh 阅读(758) 评论(0) 推荐(0)

2012年2月29日

摘要: (1)直接调用系统的方法排序intNSMutableArray*array = [[NSMutableArrayalloc]init];[arrayaddObject:[NSNumbernumberWithInt:20]];[arrayaddObject:[NSNumbernumberWithInt:1]];[arrayaddObject:[NSNumbernumberWithInt:4]];NSArray*sortedArray = [arraysortedArrayUsingSelector:@selector(compare:)];for(inti =0; i < [sortedA 阅读全文
posted @ 2012-02-29 19:18 pengyingh 阅读(898) 评论(0) 推荐(1)
摘要: 1 // 2 // Sort.h 3 // Algorithm 4 // 5 // Created by 张 汉国 on 11-9-30. 6 // Copyright 2011年 __MyCompanyName__. All rights reserved. 7 // 8 9 #import <Foundation/Foundation.h>10 11 @interface Sort : NSObject{12 13 }14 15 //选择排序16 -(void)selectSortWithArray:(NSArray *)aData;17 //插入排序18 -(void)ins 阅读全文
posted @ 2012-02-29 19:10 pengyingh 阅读(196) 评论(0) 推荐(0)
摘要: %c 一个单一的字符%d 一个十进制整数%i 一个整数 //原来i%是这个区别啊%e, %f, %g 一个浮点数%o 一个八进制数%s 一个字符串%x 一个十六进制数%p 一个指针 //也挺特别的%n 一个等于读取字符数量的整数 //特别的东东%u 一个无符号整数%[] 一个字符集 //没见过%% 一个精度符号//一、NSString/*—————-创建字符串的方法—————-*/1、创建常量字符串。NSString *astring = @”This is a String!”;2、创建空字符串,给予赋值。NSString *astring = [[NSString alloc] init] 阅读全文
posted @ 2012-02-29 17:47 pengyingh 阅读(243) 评论(0) 推荐(0)
摘要: 准备两个CLLocation的对象,比如要计算某个位置与使用者当前位置的距离,则其 中一个CLLocation是userLocation = [locationManager location],locationManager是CLLocationManager的实例,并已执行[locationManager startUpdatingLocation];然后计算这两个CLLocation的距离(已格式化成12.34 km)[NSString stringWithFormat:@"%0.2f km",[userLocationdistanceFromLocation:loc 阅读全文
posted @ 2012-02-29 13:05 pengyingh 阅读(10226) 评论(0) 推荐(0)
摘要: 自定义uitableviewcell怎样实现跳转一个自定义UITableViewCell,里面包含一个button, 点击button跳转到其它视图:UIButton *btn =[ retain];btn.tag = indexPath.row;[btn addTarget:self action:@selector(响应函数:) forControlEvents:UIControlEventTouchUpInside];在tableview的编辑状态下:[self.tableview setEditing:YES animated:NO],令cell响应点击事件不会变颜色,但能响应事件,方 阅读全文
posted @ 2012-02-29 09:19 pengyingh 阅读(4883) 评论(0) 推荐(0)

2012年2月28日

摘要: 一般是在你需要添加自定义navigationbar的地方:self.navigationController.navigationBar.hidden = YES;UINavigationBar *customNavigationBar = [[[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)] autorelease];UIImageView *navigationBarBackgroundImageView = [[UIImageView alloc] initWithImage:backgroundImage] 阅读全文
posted @ 2012-02-28 19:44 pengyingh 阅读(7286) 评论(0) 推荐(0)
摘要: 我们在C/C++开发中常会用到结构体来帮助我们简单封装基本数据类型,在Objective-C中我们也可以使用结构体来完成数据类型的封装。同时,Cocoa Touch还提供了一个NSValue来帮助我们更好地在开发中使用结构体。 我们可以使用NSValue来辅助我们实现一些简单数据结构的封装。比如我们定义了一个简单的结构体类型typedef struct { int id, float height, unsigned char flag}MyTestStruct; 此时,我们就可以使用MyTestStruct这个结构体来很容易地封装数据。如 MyTestStruct myTestStruct; 阅读全文
posted @ 2012-02-28 13:44 pengyingh 阅读(10107) 评论(0) 推荐(2)
上一页 1 ··· 79 80 81 82 83 84 85 86 87 ··· 125 下一页

导航