iOS 定制手机通讯录(1)
2015-06-03 20:19
363 查看
我要写第一个自己写的iOS APP啦,都闪开闪开!
仍照着Homepwner扒,建个NMTel,先解决Empty Application模版的问题
把 Main.storyboard 和 LaunchScreen.xib 删掉,
把 Info.plist 里边的 Launch screen interface file base name 和 Main storyboard file base name两项删掉,
最后在AppDelegate的第一个方法里面添加代码:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
建UITableViewController类的BNRItemsViewController,在BNRItemsViewController实现初始化方法
- (instancetype)init
{
self = [super initWithStyle:UITableViewStylePlain];
return self;
}
- (instancetype)initWithStyle:(UITableViewStyle)style
{
return [self init];
}
在AppDelegate.m里边导入
#import “BNRItemsViewController.h”
再在第一个方法里加入
BNRItemsViewController *itemsViewController = [[BNRItemsViewController alloc] init];
self.window.rootViewController = itemsViewController;
这时运行应用,BNRItemsViewController中的view方法会调用loadView方法,得到一个空的UITableView对象。
下面写生成数据的对象,建立BNRItem,有4个实例变量,分别保存姓名、手机号、分机号、邮箱,一个实例方法initWithItemName用来传消息生成数据。
实现initWithItemName,并覆盖description方法。
BNRItem.h
#import
@interface BNRItem : NSObject
{
NSString *_NMTelContactName;
NSString *_NMTelCellPhone;
NSString *_NMTelLandLine;
NSString *_NMTelContactEmail;
}
- (instancetype)initWithItemName:(NSString *)ContactName
NMTelCellPhone:(NSString *)CellPhone
NMTelLandLine:(NSString *)LandLine
NMTelContactEmail:(NSString *)ContactEmail;
@property (nonatomic, copy) NSString *NMTelContactName;
@property (nonatomic, copy) NSString *NMTelCellPhone;
@property (nonatomic, copy) NSString *NMTelLandLine;
@property (nonatomic, copy) NSString *NMTelContactEmail;
@end
BNRItem.m
#import “BNRItem.h”
@implementation BNRItem
- (NSString *)description
{
NSString *descriptionString =
[[NSString alloc] initWithFormat:@”%@ %@ %@ %@”,
self.NMTelContactName,
self.NMTelCellPhone,
self.NMTelLandLine,
self.NMTelContactEmail];
return descriptionString;
}
- (instancetype)initWithItemName:(NSString *)ContactName
NMTelCellPhone:(NSString *)CellPhone
NMTelLandLine:(NSString *)LandLine
NMTelContactEmail:(NSString *)ContactEmail
{
self = [super init];
if (self) {
_NMTelContactName = ContactName;
_NMTelCellPhone = CellPhone;
_NMTelLandLine = LandLine;
_NMTelContactEmail = ContactEmail;
}
return self;
}
@end
测试main.m,initWithItemName是有效的
#import
#import “BNRItem.h”
int main(int argc, const char * argv[]) {
@autoreleasepool {
BNRItem *item = [[BNRItem alloc] init];
item.NMTelContactName = @”郑华恩”;
item.NMTelCellPhone = @”18801767597″;
item.NMTelLandLine = @”873″;
item.NMTelContactEmail = @”huaen@niumag.com”;
NSLog(@”%@”, item);
item = nil;
BNRItem *itemWithName = [[BNRItem alloc] initWithItemName:@”郑华恩”
NMTelCellPhone:@”18801767597″
NMTelLandLine:@”873″
NMTelContactEmail:@”huaen@niumag.com”];
NSLog(@”%@”, itemWithName);
}
return 0;
}
把BNRItem.h和BNRItem.m文件加入到NMTel
仍照着Homepwner扒,建个NMTel,先解决Empty Application模版的问题
把 Main.storyboard 和 LaunchScreen.xib 删掉,
把 Info.plist 里边的 Launch screen interface file base name 和 Main storyboard file base name两项删掉,
最后在AppDelegate的第一个方法里面添加代码:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
建UITableViewController类的BNRItemsViewController,在BNRItemsViewController实现初始化方法
- (instancetype)init
{
self = [super initWithStyle:UITableViewStylePlain];
return self;
}
- (instancetype)initWithStyle:(UITableViewStyle)style
{
return [self init];
}
在AppDelegate.m里边导入
#import “BNRItemsViewController.h”
再在第一个方法里加入
BNRItemsViewController *itemsViewController = [[BNRItemsViewController alloc] init];
self.window.rootViewController = itemsViewController;
这时运行应用,BNRItemsViewController中的view方法会调用loadView方法,得到一个空的UITableView对象。
下面写生成数据的对象,建立BNRItem,有4个实例变量,分别保存姓名、手机号、分机号、邮箱,一个实例方法initWithItemName用来传消息生成数据。
实现initWithItemName,并覆盖description方法。
BNRItem.h
#import
@interface BNRItem : NSObject
{
NSString *_NMTelContactName;
NSString *_NMTelCellPhone;
NSString *_NMTelLandLine;
NSString *_NMTelContactEmail;
}
- (instancetype)initWithItemName:(NSString *)ContactName
NMTelCellPhone:(NSString *)CellPhone
NMTelLandLine:(NSString *)LandLine
NMTelContactEmail:(NSString *)ContactEmail;
@property (nonatomic, copy) NSString *NMTelContactName;
@property (nonatomic, copy) NSString *NMTelCellPhone;
@property (nonatomic, copy) NSString *NMTelLandLine;
@property (nonatomic, copy) NSString *NMTelContactEmail;
@end
BNRItem.m
#import “BNRItem.h”
@implementation BNRItem
- (NSString *)description
{
NSString *descriptionString =
[[NSString alloc] initWithFormat:@”%@ %@ %@ %@”,
self.NMTelContactName,
self.NMTelCellPhone,
self.NMTelLandLine,
self.NMTelContactEmail];
return descriptionString;
}
- (instancetype)initWithItemName:(NSString *)ContactName
NMTelCellPhone:(NSString *)CellPhone
NMTelLandLine:(NSString *)LandLine
NMTelContactEmail:(NSString *)ContactEmail
{
self = [super init];
if (self) {
_NMTelContactName = ContactName;
_NMTelCellPhone = CellPhone;
_NMTelLandLine = LandLine;
_NMTelContactEmail = ContactEmail;
}
return self;
}
@end
测试main.m,initWithItemName是有效的
#import
#import “BNRItem.h”
int main(int argc, const char * argv[]) {
@autoreleasepool {
BNRItem *item = [[BNRItem alloc] init];
item.NMTelContactName = @”郑华恩”;
item.NMTelCellPhone = @”18801767597″;
item.NMTelLandLine = @”873″;
item.NMTelContactEmail = @”huaen@niumag.com”;
NSLog(@”%@”, item);
item = nil;
BNRItem *itemWithName = [[BNRItem alloc] initWithItemName:@”郑华恩”
NMTelCellPhone:@”18801767597″
NMTelLandLine:@”873″
NMTelContactEmail:@”huaen@niumag.com”];
NSLog(@”%@”, itemWithName);
}
return 0;
}
把BNRItem.h和BNRItem.m文件加入到NMTel
相关文章推荐
- iOS开发:获取视频特定时段的截图
- iOS学习笔记--手势事件
- iOS开发:获取一个视频、音频文件的播放时长
- iOS 报错 Assert Catalog Complier Error Fail to write PNG data for the launach image......
- iOS8、Xcode6下 设置Launch Image 启动图片,为什么按命名规范还是不出来照片
- iOS8自适应布局视频教程
- IOS ARC跟block那点事
- iOS开发技巧点滴
- 用CocoaPods做iOS程序的依赖管理
- iOS模型以及使用
- iOS CoreLocation使用(iOS8 回调不行的问题解决)
- 适配 - 手机对应的尺寸
- 适配 - 手写 IOS自动布局
- 适配 - Xcode6中自动布局autolayout和sizeclass的使用
- 适配 - autolayout自动布局
- iOS中图片拉伸技巧
- iOS 截取图片,并且保持图片原有比例,同时填充imageView
- iOS开发中线程通信
- ios开发入门- plist 文件读写
- IOS初级:delegate的使用