2.簡要介紹下記憶體管理機制?
Cocoa中提供了一個機制來實現上面提到的這個邏輯模型,它被稱為“引用計數”(referring counting)或“保留計數”(retain counting):
3.objc中的減號和加號的意思以及用法?
①減號表示一個函數、或者方法或者訊息的開始(在一個類的執行個體上被調用和實施)(可以認為是私人方法)
②加號表示其他的函數可以直接調用這個類中的方法,而不用建立這個類的執行個體(俗稱靜態方法)
4、項目整理
按鈕:
BtnWinWin = [UIButton buttonWithType: UIControlStateNormal];
BtnWinWin.frame = CGRectMake(768, 679, 256, 42);
[BtnWinWin setBackgroundImage:[UIImage imageNamed:@"btnwinwin.jpg"] forState:UIControlStateNormal];
[BtnWinWin addTarget:self action:@selector(WinWin) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:BtnWinWin];
播放器:
NSString *soundPath = [[NSBundle mainBundle]pathForResource:musicTop ofType:@"mp3"];
NSURL *soundURL = [[NSURL alloc]initFileURLWithPath:soundPath];
player = [[AVAudioPlayer alloc]initWithContentsOfURL:soundURL error:nil];
[player setDelegate:self];
[player play];
兩個控制器之間的動畫轉換:
mainFrame = [[Test_Book1_2_Classes_ViewControlleralloc] init];
haveMainFram =TRUE;
CATransition *transition = [CATransitionanimation];
transition.duration = 1.0f; /* 間隔時間*/
transition.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]; /* 動畫的開始與結束的快慢*/
transition.type = @"pageCurl";
transition.subtype = kCATransitionFromTop; /* 動畫方向*/
transition.delegate = self;
[self.navigationController.view.layeraddAnimation:transition forKey:nil];
[self.navigationControllerpushViewController:mainFrameanimated:YES];
sdk相關:
1、兩個.a靜態庫的合并,靜態庫有分適合模擬器的和真機的,如何合并請看:我的另一篇文章http://www.cnblogs.com/visen-0/archive/2011/08/02/2125067.html
2、建立root許可權應用:http://www.cnblogs.com/visen-0/archive/2011/08/22/2149014.html
3、擷取已經安裝的列表:http://www.cnblogs.com/visen-0/archive/2011/08/22/2148847.html
4、自製.ipa檔案下載安裝。
5、判斷是否越獄,去[NSFileManager defaultManager]找是否有對應的比如Cydia.app程式。
給伺服器提交資訊:
// 裝置資訊
UIDevice *device = [UIDevice currentDevice];
NSString *identifier = [[NSStringstringWithString:[device uniqueIdentifier]] lowercaseString];
NSLog(@"%@",identifier);
NSString *requestString = [NSStringstringWithFormat:@"http://www.yrwang.net/post.aspx?client=ios&deviceId=%@&reportMessage=%@",identifier,opinion.text];
NSString *requestStringUTF8 = [requestString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL * myURL = [[NSURL alloc] initWithString:requestStringUTF8];
NSMutableURLRequest *myRequest = [NSMutableURLRequestrequestWithURL: myURL
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval: 30];
[myURL release];
connection_ = [[NSURLConnectionalloc] initWithRequest: myRequest delegate: self];
解析xml:
NSXMLParser* xmlRead = [[NSXMLParser alloc] initWithData:data];//初始化NSXMLParser對象
[data release];
[xmlRead setDelegate:self];
[xmlRead parse];
監聽者模式:
[[NSNotificationCenterdefaultCenter] addObserver:self
selector:@selector(getUpdatedPoints:)
name:111
object:nil];
[[NSNotificationCenterdefaultCenter] postNotificationName:111 object:nil];
單例模式:
static AdPublisherConnect *sharedInstance_ = nil;
+ (AdPublisherConnect*)sharedAdPublisherConnect
{
if(!sharedInstance_)
{
sharedInstance_ = [[superalloc] init];
}
returnsharedInstance_;
}
檔案的讀取寫,建立:
這個是建立的例子:
//建立檔案管理工具
NSFileManager *fileManager = [NSFileManagerdefaultManager];
//擷取路徑
//參數NSDocumentDirectory要擷取那種路徑
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];//去處需要的路徑
//更改到待操作的目錄下
[fileManager changeCurrentDirectoryPath:[documentsDirectory stringByExpandingTildeInPath]];
//建立檔案fileName檔案名稱,contents檔案的內容,如果開始沒有內容可以設定為nil,attributes檔案的屬性,初始為nil
//擷取檔案路徑
NSString *path = [documentsDirectory stringByAppendingPathComponent:fileName];
//建立資料緩衝
NSMutableData *writer = [[NSMutableDataalloc] init];
//將字串添加到緩衝中
[writer appendData:[contents dataUsingEncoding:NSUTF8StringEncoding]];
//將其他資料添加到緩衝中
//將緩衝的資料寫入到檔案中
[writer writeToFile:path atomically:YES];
[writer release];
字串的擷取某個操作:NSRange
e = [tempString rangeOfString:@","];
key = [tempString substringToIndex:e.location];
e = [tempString rangeOfString:@"\r\n"];
tempString = [tempString substringFromIndex:e.location+1];
錄音:
AVAudioSession
分頁:
uitable分頁
尋找檔案目錄;
+ (NSMutableArray *)findFile{
NSFileManager *fileManager = [[NSFileManager defaultManager] init];
NSMutableArray *everyTitle = [[NSMutableArray alloc] init];
NSArray *filePaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *filePath = [filePaths objectAtIndex:0];
NSLog(@"%@",filePath);
NSDirectoryEnumerator *direnum = [fileManager enumeratorAtPath:filePath];
NSString *fileName;
while ((fileName = [direnum nextObject])) {
[everyTitle addObject:fileName];
}
return everyTitle;
}
表單:
UIActionSheet
長按按鈕:
UILongPressGestureRecognizer
滾動視圖:
UIScrollView
web網頁:
UIWebView
隱藏導覽列,應用全屏。