省市县用对象实现
来源:互联网 发布:seo按天付费 编辑:程序博客网 时间:2024/04/28 00:13
//
// main.m
// 练习省市区用对象实现
//
// Created by dllo on 15/11/3.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "Operation.h"
#import "City.h"
#import "provice.h"
int main(int argc,const char * argv[]) {
@autoreleasepool {
Operation *oper = [[Operationalloc] init];
[oper operation];
[oper info];
}
return 0;
}
//
// Operation.h
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "City.h"
@class provice;
@class City;
@interface Operation : City
@property (nonatomic,retain)NSMutableArray *proArr;
@property (nonatomic,retain)NSArray *arr;
- (id)init;
- (void)operation;
- (void)info;
@end
//
// Operation.m
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "Operation.h"
@class provice;
@class City;
@implementation Operation
- (id)init
{
NSString *filePath =@"/Users/dllo/Desktop/省市区/area.txt";
NSString *str = [NSStringstringWithContentsOfFile:filePath encoding:NSUTF8StringEncodingerror:nil];
// NSMutableArray *arr = [NSMutableArray array];
NSArray *arr = [strcomponentsSeparatedByString:@"\n"];
NSMutableArray *proArr = [NSMutableArrayarray];
self = [superinit];
if (self) {
[self setProArr:proArr];
[self setArr:arr];
}
return self;
}
- (void)operation
{
for (NSString *tempin self.arr) {
if (![temp hasPrefix:@" "]) {
provice *pro = [[provicealloc]init];
[pro setProName:temp];
[self.proArraddObject:pro];
} else if([temphasPrefix:@" "] && ![temphasPrefix:@" "]) {
City *city = [[Cityalloc]init];
[[[self.proArrlastObject] cityArr]addObject:city];
[[[[self.proArrlastObject] cityArr]lastObject]setCityName:temp];
} else {
[[[[[self.proArrlastObject] cityArr ]lastObject]quArr]addObject:temp];
}
}
}
- (void)info
{
for (provice *proin self.proArr) {
NSLog(@"%@", [proproName]);
for (City *cityin pro.cityArr) {
NSLog(@"%@", [citycityName]);
for (NSString *tempin city.quArr) {
NSLog(@"%@", temp);
}
}
}
}
@end
//
// City.h
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "provice.h"
@interface City : provice
@property (nonatomic,retain)NSMutableArray *quArr;
@property (nonatomic,copy)NSString *cityName;
- (id)init;
@end
//
// City.m
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "City.h"
@implementation City
- (id)init
{
NSMutableArray *quArr = [NSMutableArrayarray];
NSString *cityName = [[NSStringalloc]init];
self = [superinit];
if (self) {
[self setQuArr:quArr];
[self setCityName:cityName];
}
return self;
}
@end
//
// provice.h
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface provice : NSObject
@property (nonatomic,retain)NSMutableArray *cityArr;
@property (nonatomic,copy)NSString *proName;
- (id)init;
@end
//
// provice.m
// 练习省市区用对象实现
//
// Created by dllo on 15/11/4.
// Copyright (c) 2015年 dllo. All rights reserved.
//
#import "provice.h"
@implementation provice
- (id)init
{
NSMutableArray *cityArr = [NSMutableArrayarray];
NSString *proName = [[NSStringalloc]init];
self = [superinit];
if (self) {
[self setProName:proName];
[self setCityArr:cityArr];
}
return self;
}
@end
- 省市县用对象实现
- 实现省市县三级联动
- 省市县联动的实现。
- 用ajax实现省市联动
- 省市县三级联动菜单实现
- js 实现 省市县三级级联
- Ajax实现省市县三级联动
- jQuery实现省市县三级联动菜单
- JavaScript实现省市县三级联动效果~~~
- Jscript实现省市县三级联动
- JavaScript实现省市县三级联动效果~~~
- ASP.NET实现省市县三级联动
- Ext省市县三级联动实现
- Easyui实现省市县三级联动
- 省市县三级级联的实现
- Easyui实现省市县三级联动
- 省市县三级联动实现代码
- Jquery实现省市县三级联动
- 省市区用字典实现
- CoreData
- CSS学习笔记之<层叠>
- ERROR 1036 (HY000): Table 'teacher' is read only
- 服务器的产品类型之塔式|机架式|刀片式
- 省市县用对象实现
- 顺序表应用1:多余元素删除之移位算法
- hibernate的type类型对照表
- matlab ---PSNR
- 移动App开发(包含iOS和Android转型)
- java基础杂记(一)——public,protected,缺省(default),private
- 顺序表应用2:多余元素删除之建表算法
- Linux 学习(4) -- printk与printf的区别
- 蓝鸥0c考试 绝密