2013-03-18 17 views
-1

我正在編寫一個解析xml文件的程序我需要不斷地讀取這個文件,這意味着如果在運行時xml文件發生任何變化,它也必須在模擬器中顯示 我試圖如何在ios中不斷調用使用NSThread的函數

NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:@selector(doParsing) object:nil]; 
    [myThread start]; 

並調用XML文件,但它沒有顯示我。如何能做到這一點

+0

沒有ü保存更改? – lakesh 2013-03-18 06:13:10

+0

是的,我沒有保存變化 – Optimus 2013-03-18 06:13:30

+0

' while(1){function(); ''也許? – 2013-03-18 06:16:29

回答

2

可能類似的變化:

NSThread *myThread =[[NSThread alloc]initWithTarget:self selector:@selector(callTimer) object:nil]; 
[myThread start]; 

- (void)callTimer 
{ 
    [NSTimer scheduledTimerWithTimeInterval:10.0 
    target:self 
    selector:@selector(doParsing) 
    userInfo:nil 
    repeats:YES]; 
} 

- (void)doParsing 
{ 
    //Do the stuff here 
} 
+0

我試過你的方法,但它沒有調用doParsing – Optimus 2013-03-18 07:05:27

+0

@AlenJoy:在我的方法中,它會在每十秒鐘後調用doParsing。改變這個時間並在doParsing上添加日誌 – 2013-03-18 08:19:51