你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS:以前筆記,未整理版。太多了,先放著吧。。。。。。。

iOS:以前筆記,未整理版。太多了,先放著吧。。。。。。。

編輯:IOS開發綜合

1、

-(void)timetick

{

    _d = 0;

    NSTimer *newtime =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(printfdate:) userInfo:@"byL" repeats:YES];

}

 

-(void)printfdate:(NSTimer*)time1

{

    NSLog(@"%d,%@",_d++,time1.userInfo);

}

 

[newtime invalidate];

 

[[NSRunLoop currentRunLoop]run];

 

 

 

 

//初始化察看

 [_phone addObserver:self forKeyPath:@"price" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];

//察看到變化控制

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context

{

    NSNumber *num = [change objectForKey:@"new"];

    NSLog(@"%@",num);

}

 

//發送信息

[[NSNotificationCenter defaultCenter]postNotificationName:@"pricechange" object:self userInfo:nil];

//承受信息初始化

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(salephone) name:@"pricechange" object:nil];

//承受到信息做控制

-(void)salephone

 

 

 

//數組

 NSArray *DATA_A =@[類,類,類,類,類];

//設置過濾條件

NSPredicate *newpre = [NSPredicate predicateWithFormat:@"age > 29"];

//過濾後保管的數組

NSArray *newarray = [DATA_A filteredArrayUsingPredicate:newpre];

 

@“name BEGINSWITH 'x' ”

@“name ENDSWITH 'x' ”

@“name CONTAINS 'x' ”

@“age > 29 || age < 20”

@“name like ‘?d*’ ”

 

 

2、

sql

====================================================================

創立:

 

翻開: 數據庫指針、保管地址

SQLite3_open([path UTF8String], &new_sql)

————————————————————————————————————————

創立: 數據庫指針、創立指令、錯誤指令

(

NSString *command = @"CREATE TABLE IF NOT EXISTS UserTable (username TEXT primary key,password TEXT,age TEXT)";

)

SQLite3_exec(new_sql, [command UTF8String], NULL, NULL, &new_error)

————————————————————————————————————————

封閉: 數據庫指針

SQLite3_close(new_sql);

 

 

====================================================================

拔出:

 

翻開:

————————————————————————————————————————

拔出指令:

(

    NSString *op = @"INSERT INTO UserTable(username,password,age) VALUES (?,?,?)";

)

預備: 數據庫指針、拔出指令、句柄

sqlite3_prepare(new_sql, [op UTF8String], -1, &new_stmt, NULL);

綁定: 句柄、地位、數據

sqlite3_bind_text(new_stmt, 1, [name UTF8String], -1, NULL);

下一步: 句柄

sqlite3_step(new_stmt);

完畢: 句柄

sqlite3_finalize(new_stmt);

————————————————————————————————————————

封閉:

 

====================================================================

刪除:

 

翻開:

————————————————————————————————————————

刪除指令:

(

    NSString *op = @"DELETE FROM userTable WHERE userName = ?";

)

預備: 數據庫指針、刪除指令、句柄

sqlite3_prepare(new_sql, [op UTF8String], -1, &new_stmt, NULL);

綁定: 句柄、地位、數據

sqlite3_bind_text(new_stmt, 1, [name UTF8String], -1, NULL);

下一步: 句柄

sqlite3_step(new_stmt);

完畢: 句柄

sqlite3_finalize(new_stmt);

————————————————————————————————————————

封閉:

 

====================================================================

選擇:

 

翻開:

————————————————————————————————————————

選擇指令:

(

    (1)NSString *op = @"SELECT username,password,age From UserTable where username = ?";

    (2)NSString *op = @"SELECT username,password,age From UserTable";

)

預備: 數據庫指針、選擇指令、句柄

sqlite3_prepare(new_sql, [op UTF8String], -1, &new_stmt, NULL);

綁定: 句柄、地位、數據

(1)sqlite3_bind_text(new_stmt, 1, [selet_name UTF8String], -1, NULL);

下一步: 句柄

sqlite3_step(new_stmt);

遍歷:

while (result == SQLITE_ROW)

{

char *c_name = (char *)sqlite3_column_text(new_stmt, 0);

char *c_password = (char *)sqlite3_column_text(new_stmt, 1);

char *c_age = (char *)sqlite3_column_text(new_stmt, 2);

        

        NSString *s_name = [NSString stringWithCString:c_name encoding:NSUTF8StringEncoding];

        NSString *s_password = [NSString stringWithCString:c_password encoding:NSUTF8StringEncoding];

        NSString *s_age = [NSString stringWithCString:c_age encoding:NSUTF8StringEncoding];

        

        NSLog(@"%@,%@,%@",s_name,s_password,s_age);

        result = sqlite3_step(new_stmt);

        //NSLog(@"%d",new_stmt);

}

完畢: 句柄

sqlite3_finalize(new_stmt);

————————————————————————————————————————

封閉:

 

====================================================================

拔出變體:

更新

@"UPDATE UserTable SET password = ? where username = ?"

 

選擇(2)變體:

排序

@“SELECT * FROM userTable ORDER BY age ASC(DESC)”

 

 

3、

@"[email protected]"

@"[email protected]"

@"[email protected]"

@"[email protected]"

 

4、

int gNumb=0;

全局變量通常用小寫g來提示。  

 

重寫,父類有聲明,不用再聲明

 

[p1 isKindOfClass:[Person class]];

[p1 isMemberOfClass:[Person class]];

[p1 respondsToSelector:@selector(test)];

 

 

可變數組 copy 賦值給不可變數組。

 

 

-(NSString *)description

{

    return [NSString stringWithFormat:@"%@,%lu",_name,_price];

}

 

 

==========================================================================

 

//編碼

NSData *new_data = [s_text dataUsingEncoding:NSUTF8StringEncoding];

 

//解碼

NSString *new_string = [[NSString alloc]initWithData:new_data encoding:NSUTF8StringEncoding];

 

==========================================================================

//沙盒途徑

NSHomeDirectory()

 

 //工程目錄

[NSBundle mainBundle]

==========================================================================

 

//弄個文件管理

NSFileManager *new_File = [NSFileManager defaultManager];

 

//創立文件夾   path要追加文件夾名,不要後綴

[new_File createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&new_error]

 

//創立文件   path在之前文件夾下追加“xxx.xxx”    data要編碼

[new_File createFileAtPath:new_path contents:new_data attributes:nil]

 

//讀取文件的信息 前往字典

[new_File attributesOfItemAtPath:new_path error:&new_error]

 

//讀取單個字典的關鍵詞

[new_dic objectForKey:@"NSFileSize"]

 

==========================================================================

 

//文件讀取

NSData *newData = [fileManager contentsAtPath:filePath];

[[NSString alloc]initWithData:newData encoding:NSUTF8StringEncoding];

or

[[NSString alloc]initWithContentsOfFile:new_path encoding:NSUTF8StringEncoding error:&new_error];

 

//文件挪動(剪切、重命名),要加上文件名和後綴”xxx.xx”

[new_File moveItemAtPath:new_path toPath:ob_add error:&new_error]

 

//文件復制   也要留意有文件名和後綴“xxx.xx”

[new_File copyItemAtPath:new_path toPath:ob_add_2 error:&new_error]

 

//文件刪除   也要留意有文件名和後綴“xxx.xx”

先判別有無文件

[new_File fileExistsAtPath:ob_add_2]

刪除

[new_File removeItemAtPath:ob_add_2 error:&new_error]

 

==========================================================================

 //寫入

 

/設置為寫入形式

NSFileHandle *new_handle = [NSFileHandle fileHandleForWritingAtPath:path];

 

/先轉碼

NSString *new_string = @"hello,hello,hello,世界";

NSData *new_data = [new_string dataUsingEncoding:NSUTF8StringEncoding];

/再寫入

[new_handle writeData:new_data];

 

//追加

/先找到最後的

[new_handle seekToEndOfFile];

/寫入轉碼後的數據

[new_handle writeData:new_data_2];

 

//掩蓋

/先找到偏移位

[new_handle seekToFileOffset:3];

/寫入轉碼後的數據

[new_handle writeData:new_data_3];

    

//封閉操作

[new_handle closeFile];

 

 

 

 

//讀取

/設置為讀取形式

new_handle = [NSFileHandle fileHandleForReadingAtPath:path];

/讀取一切data

NSData *read_data = [new_handle readDataToEndOfFile];

/轉成字符串

NSString *read_string = [[NSString alloc]initWithData:read_data encoding:NSUTF8StringEncoding];

 

 

/設置為讀取形式,否則有問題

new_handle = [NSFileHandle fileHandleForReadingAtPath:path];

/讀取前幾個數據

read_data = [new_handle readDataOfLength:10];

/轉成字符串

ead_string = [[NSString alloc]initWithData:read_data encoding:NSUTF8StringEncoding];

 

//封閉操作

[new_handle closeFile];

 

5、

協議

@required

@optional

 

nonatomic

copy assign

 

==================================================

.h簽協議

<NSCopying>

 

.m設置要復制的值

- (id)copyWithZone:(nullable NSZone *)zone

{

    NSLog(@"復制對象調用了!");

    Person *person = [[self class] allocWithZone:zone];

    person.name = [_name mutableCopy];

    person.age = _age;

    person.bookArray = [_bookArray mutableCopy];

    return person;

}

 

調用

Person *person2 = [person1 copy]; 

 

==================================================

.h簽協議

<NSCoding>

 

.m設置要復制的值

- (void)encodeWithCoder:(NSCoder *)aCoder

{

    [aCoder encodeObject:_name forKey:NAME];

    [aCoder encodeInteger:_age forKey:AGE];

    [aCoder encodeObject:_hobby forKey:HOBBY];

    

}

 

- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder

{

    self = [super init];

    if (self)

    {

        self.name = [aDecoder decodeObjectForKey:NAME];

        self.age = [aDecoder decodeIntegerForKey:AGE];

        self.hobby = [aDecoder decodeObjectForKey:HOBBY];

    }

    return self;

}

 

調用

//地址

NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/di8zhangzuoue.txt"];

//歸檔

[NSKeyedArchiver archiveRootObject:atext toFile:path]

//讀取

[NSKeyedUnarchiver unarchiveObjectWithFile:path];

==================================================

單例 共享信息

.m

 

static .net *newone = nil;

 

+(instancetype)shalldata

{

    if (newone == nil)

    {

        newone = [[.net alloc]init];

        newone.data_zone = [NSMutableArray array];

    }

    return newone;

}

 

調用:

.net *one = [OneT shalldata];

OneT *two = [OneT shalldata];

==================================================

 

 

    NSArray *data = [NSArray arrayWithObjects:@"zhang3",@"li4", nil];

    

    NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"ceshi83.txt"];

    

    BOOL status = [NSKeyedArchiver archiveRootObject:data toFile:path];

    

    NSLog(@"%@",status?@"成功":@"失敗");

    

    NSArray *r_data = [NSKeyedUnarchiver unarchiveObjectWithFile:path];

    

    NSLog(@"%@",r_data);

 

 

 6、

instancetype:前往與初始化類相反的類型。

 

-(instancetype)initWith…

{

self=[super init];

if(self)

{

}

return self;

}

 

-(class_A *)initwithone:(int)a other:(int)b

{

self=[super init];

if(self)

{

[self seta:a b:b ] ;

}

return self;

}

 

 

 

+(instancetype)robotWithName:(NSString*)r_name andage:(int)r_age

{

#if 0

    return [[self alloc]initWithName:(NSString*)r_name andage:(int)r_age];

#else

    

    Robot *new_R = [[Robot alloc]initWithName:r_name andage:r_age];

    return new_R;

#endif

}

 

 

 

@private 公有:只要類定義外部可訪問

@protected 維護:只要類自身和子類的定義裡可訪問

@public 私有:順序的任何地位都可訪問

 

/** xxx */

#progame MARK xxx

 

[self performSelector:@selector(delaylog:) withObject:@"3秒" afterDelay:2];

[[NSRunLoop currentRunLoop]run];

 

7、

SET

 

//初始化

NSSet *set = [[NSSet alloc]initWithObjects:@“_1”,@“_2”,@“_3”,@“_4”,@“_3”, nil];

 

//可變初始化

NSMutableSet *mSet = [NSMutableSet set];

 

//可變添加對象

[mSet addObject:numobject];

 

//建個數組

NSArray *array = [NSArray arrayWithObjects:@“_3”,@“_4”,@“_5”, nil];

//取數組的對象初始化

NSSet *newSet = [NSSet setWithArray:array];

//又把set的對象給數組,自動消弭反復

NSArray *newArray = [newSet allObjects];

//打印

NSLog(@"%ld",[newSet count]);

 

//恣意取! 但不保證隨機!

NSLog(@"%@",[set anyObject]);

 

//能否等價

[set isEqualToSet:newSet]

 

//能否包括

[newSet isSubsetOfSet:set]

 

 

 

ENUM

 

//將set的值給枚舉

NSEnumerator *enumtor = [set objectEnumerator];

 

//將枚舉裡的對象逐個打印

for (NSObject* obj in enumtor)

 {

NSLog(@"-->%@",obj);

}

 

8、

日期時間

 

//美國的時間

NSDate *date = [[NSDate alloc]init];

 

//時區

NSTimeZone *myZone = [NSTimeZone systemTimeZone];

 

 //算時差 加上時差

NSInteger interValTimer = [myZone secondsFromGMTForDate:date];

NSDate *localDate = [date dateByAddingTimeInterval:interValTimer];

NSLog(@"%@",localDate);

 

 

//今天

NSDate *date2 = [NSDate dateWithTimeIntervalSinceNow:24*60*60];

 

//昨天

NSDate *date2 = [NSDate dateWithTimeIntervalSinceNow:-ADAY];

NSLog(@"date2 = %@",date2);

 

//1970年

NSDate *date2 = [NSDate dateWithTimeIntervalSince1970:0];

NSLog(@"%@",date2);

 

//參考日期2001年

NSDate *date3 = [NSDate dateWithTimeIntervalSinceReferenceDate:0];

NSLog(@"%@",date3);

 

 

 

//nsdate -> nsstring 類型轉換

NSDate *date1 = [NSDate date];

 

1.

NSString *date1str = date1.description; //美國的時間

 

2

NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc]init];

2.1

[dateFormat1 setDateFormat:@"yyyy年MM月dd日 EEEE HH mm ss zz"];

 

2.2

    [dateFormat1 setDateStyle:NSDateFormatterShortStyle];

   [dateFormat1 setTimeStyle:NSDateFormatterMediumStyle];

 

NSString *datestr2 = [dateFormat1 stringFromDate:date1];

NSLog(@"datestr2 = %@",datestr2);

 

 

 

//獲取一切時區的名字

NSArray *timeZoneNames =  [NSTimeZone knownTimeZoneNames];

//新建一個時區

NSTimeZone *newZone = [NSTimeZone timeZoneWithName:@"Pacific/Fiji"];

//新建一個時間格式

NSDateFormatter *dateFormat2 = [[NSDateFormatter alloc]init];

//設置該時區

[dateFormat2 setTimeZone:newZone];

//設置時間格式

[dateFormat2 setDateFormat:@"yyyy年MM月dd日 EEEE HH:mm:ss zz"];

//打印

NSString *dateString =  [dateFormat2 stringFromDate:[NSDate date]];

NSLog(@"dateString = %@",dateString);

 

//字符串轉date

NSString *dateStr4 = @"2016年07月27日 星期三 20:16:10 GMT+12";

NSDate *date4 = [dateFormat2 dateFromString:dateStr4];

NSLog(@"%@",date4);

 

 

 

 

 

 

 

NSRange newrange = NSMakeRange(1,5);

NSValue *newvalue = [NSValue valueWithRange:newrange];

NSLog(@"%@",newvalue);

NSArray *newarray = [NSArray arrayWithObjects:newvalue, nil];

NSLog(@"%@",newarray);

    

NSRange newrange2 = [newvalue rangeValue];

NSLog(@"%lu,%lu",newrange2.location,newrange2.length);

 

 

 

//封裝自定義的構造體

struct MyPoint 

{

int x;

        int y;

};

struct MyPoint mypoint;

mypoint.x = 10;

mypoint.y = 100;

    

NSValue *val2 = [NSValue value:&mypoint withObjCType:@encode(struct MyPoint)];

NSLog(@"%@",val2);

    

struct MyPoint mypoint2;

[val2 getValue:&mypoint2];

NSLog(@"mypoint2.x = %d,mypoint2.y = %d",mypoint2.x,mypoint2.y);

 

 9、

@interface class_A:NSObject

@end

 

@implementation class_A

@end

 

@property int x;

@synthesize x;

 

[MyA setNumb:5]; 即便實例變量是小寫,這個set後也要大寫

n=[MyA numb]; 

 

[A B]  等價 A.B

 

[self 該.m文件的辦法],找不到再去父類找

 

 

與文件.h.m同名

@interface class_A:NSObject

@end

 

@interface class_B:class_A

@ens

 

承繼裡,class_B裡的辦法的可以用

[self A的辦法]

[self A的變量]

 

需求某文件的某些辦法,可以用

@class xxx.h

 

假如xxx.h的某些辦法訪問不了,如init,還是要

#import xxx.h

 

反復包括的,其中一個.h可以用@class xxx(不必寫.h),對應.m要#import xxx.h

 

 

同名辦法優先運用class_B的辦法

 

同名的辦法,會自動判別[A set_value:(int)x]的類,如判別出A

 

id x;

x=恣意變量、class類

 

@try

{

}

@catch

{

}

@finally

{

}

 

還有的@throw

 

10、

字符串:

字符串的創立

 

對象辦法:

[[NSString alloc]init];

[[NSString alloc]initWithString:string];

[[NSString alloc]initWithFormat:@"%@",string1];

 

類辦法:

[NSString stringWithString:string];

[NSString stringWithFormat:@"%@",string2];

 

字符串格式化拼接

 

[NSString stringWithFormat:@"%@%@",string3,string4];

 

字符串比擬

 

[string3 isEqualToString:string4];

[string3 caseInsensitiveCompare:string4];

[string3 compare:string4]

 

字符串長度

 

[string length];

string.length;

 

字符串大小寫變化

 

[string uppercaseString];

[string lowercaseString];

[string capitalizedString];

 

字符串追加

 

[string4 stringByAppendingString:string3];

 

字符串查找

 

[string rangeOfString:@"world"];

NSNotFound

 

[string hasprefix:@“www”];

[string hasSuffix:@“com”];

 

字符串截取

 

[string substringFromIndex:2];

[string substringToIndex:5];

[string substringWithRange:range];

 

字符串跟根本數據類型轉換

 

[NSString stringWithFormat:@"%d",a];

[NSString stringWithFormat:@"%f",b];

[NSString stringWithFormat:@"%c",c];

 

[strnum1 intValue];

[strnum2 floatValue];

const char *cc = [strchar UTF8String];

 

字符串取個元素

 

[newstring characterAtIndex:3]

 

字符串能否包括

 

[mString containsString:@"hello"];

 

 

 

可變字符串的創立

 

[[NSMutableString alloc]initWithString:string];

[[NSMutableString alloc]initWithFormat:@"%@",string];

 

[NSMutableString stringWithString:string];

[NSMutableString stringWithFormat:@"%@",string];

 

 

可變字符串的交換

 

  [mString replaceCharactersInRange:NSMakeRange(2,2) withString:@"xxx"];

 

可變字符串的拔出

 

[mString insertString:@"aaa" atIndex:1];

 

可變字符串的刪除

 

[mString deleteCharactersInRange:NSMakeRange(1, 3)];

 

可變字符串的追加

 

[S_1 appendString:@"QAZ"];

[S_1 appendFormat:@"%@",S_1];

 

 

11、

字典的創立

NSDictionary *dic = [[NSDictionary alloc]init];

 

//dic = @{key:value,...};

    dic = @{

            @"name":@"xiaoming",

            @"age":@"18",

            @"sex":@"男",

            @"name1":@"xiaoming"

            };

 

對象辦法:

//dic2 = @{value:key,...};

NSDictionary *dic2 = [[NSDictionary alloc]initWithObjectsAndKeys:@"xiaohong",@"name",@"20",@"age",@"男",@"sex",@"12",@"20",@"aaa",@"bbb", nil];

NSDictionary *dic3 = [[NSDictionary alloc]initWithDictionary:dic2];

 

 

類辦法:

NSDictionary *dic4 = [NSDictionary dictionaryWithDictionary:dic3];

 

字典的長度

 

字典依據key獲取value

[dic objectForKey:@"age"]

dic[@"age"]

 

字典取出一切的key

NSArray *keyArray = [dic allKeys];

 

字典取出一切的value

   NSArray *valueArray = [dic allValues];

 

 

 

 

可變字典的創立

NSMutableDictionary *mDic1 = [NSMutableDictionary dictionary];

 

類辦法:

NSMutableDictionary *mDic = [[NSMutableDictionary alloc]initWithObjectsAndKeys:@"xiaoming",@"name",@"19",@"age",@"男",@"sex", nil];

 

可變字典添加元素

[mDic setObject:@"80kg" forKey:@"weight"];

 

可變字典刪除元素

    [mDic removeObjectForKey:@"age"];

[mDic removeObjectsForKeys:array];

 

可變字典刪除一切元素

[mDic removeAllObjects];

 

可變字典遍歷

for (NSString *key in mDic) 

{

NSLog(@"%@",mDic[key]);

    }

 

 

存儲

NSString *path = @"/Users/etcxm/test.plist";

    [dic writeToFile:path atomically:YES];

 

NSArray  *A_data_R = [NSArray array];

A_data_R = [NSArray arrayWithContentsOfFile:S_add];

 

 

12、

數組的創立

NSArray *array1 = [[NSArray alloc]init];

    array1 = @[@"here",@"is",@"etcxm"];

 

對象辦法:

    NSArray *array6 = [[NSArray alloc]initWithObjects:array1,array5, nil];

NSArray *array2 = [[NSArray alloc]initWithObjects:@"here",@"is",@"china", nil];

NSArray *array3 = [[NSArray alloc]initWithArray:array1];

 

 

類辦法:

NSArray *array4 = [NSArray arrayWithObject:@"hello"];

NSArray *array5 = [NSArray arrayWithObjects:@"here",@"is",@"china", nil];

NSArray *array6 = [NSArray arrayWithArray:array1];

 

數組取下標元素

array5[2];

[array5 objectAtIndex:2];

 

數組的長度

array5.count

[array5 count]

 

數組能否包括某個元素

[array10 containsObject:@"hello”];

 

數組經過元素獲取下標

[array10 indexOfObject:@"1123”];

NSNotFound

 

數組銜接成字符串,字符串聯系成數組

NSString *string = [array1 componentsJoinedByString:@" "];

NSArray *array2 = [string componentsSeparatedByString:@"i"];

 

數組訪問最後一個元素

[array1 lastObject];

[array1 firstObject];

 

數組遍歷

for (NSString *str in array1) 

{

        NSLog(@"->%@",str);

    }

 

數組追加元素

NSArray *array3 = [array1 arrayByAddingObject:@"hello"];

NSArray *array4 = [array1 arrayByAddingObject:array3];

NSArray *array5 = [array1 arrayByAddingObjectsFromArray:array3];

 

 

 

 

可變數組的創立

NSMutableArray *mArray = [[NSMutableArray alloc]initWithObjects:@"hello",@"world",@"china", nil];

 

 

 

可變數組添加元素

[mArray addObject:@"American"];

 

NSArray *array = [[NSArray alloc]initWithObjects:@"hi",@"hei", nil];

[mArray addObjectsFromArray:array];

 

可變數組刪除元素

    [mArray removeAllObjects];

    [mArray3 removeObject:@"here"];

[mArray3 removeObjectAtIndex:3];

    [mArray3 removeLastObject];

    [mArray3 removeObjectsInArray:arraytest];

    [mArray3 removeObjectsAtIndexes:set1];

    [mArray3 removeObject:@"here" inRange:NSMakeRange(0, 3)];

    [mArray3 removeObjectsInRange:NSMakeRange(1, 4)];

 

可變數組交流地位

[mArray3 exchangeObjectAtIndex:0 withObjectAtIndex:3];

 

可變數組交換

[mArray3 replaceObjectAtIndex:0 withObject:@"objxxx"];

 

可變數組拔出

[mArray3 insertObject:@"iiiii" atIndex:1];

 

可變數組遍歷

int i=0;

    for (NSString *str in mArray)

{

        NSLog(@"%@",str);

        NSLog(@"%d",i++);

    }

 

【iOS:以前筆記,未整理版。太多了,先放著吧。。。。。。。】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved