我需要一次将myInteger传递给一个参数,而不是传递另一个myInteger,直到调用完syncDocFinish函数。所以基本上这个代码将被调用一次[self syncDocs:myInteger];
,然后在syncDocs
函数完成之前不会再次调用它。
- (void) syncDocs
{
int i;
for (i = 0; i < [mFormList count]; i++) {
myInteger = i;
[self syncDocs:myInteger];
}
}
-(void)syncDocs : (NSInteger) myInt{
[docHandler getDocs:myInt limit:InitLoad_Count];
// the doc handler will call syncDocFinish automatically
}
- (void) syncDocFinish : (id) result
{
/// do functions{
}
/// sync doc is finished insert code to call [self syncDocs:myInteger]; again
}
答案 0 :(得分:0)
int myInteger = 0; // initialise as class level local variable
-(void)syncDocs {
[docHandler getDocs:myInteger limit:InitLoad_Count];
// the doc handler will call syncDocFinish automatically
}
- (void) syncDocFinish : (id) result {
// do functions{
//}
/// sync doc is finished insert code to call [self syncDocs:myInteger];
if(myInteger < [mFormList count]){
myInteger ++;
[self syncDocs];
}
}
This should be work...
答案 1 :(得分:-1)
你可以简单地使用BOOL值。
BOOL isSyncDocFinish;
- (void) syncDocs
{
int i;
for (i = 0; i < [mFormList count]; i++) {
myInteger = i;
if(isSyncDocFinish)
{
isSyncDocFinish = NO;
[self syncDocs:myInteger];
}
}
}
-(void)syncDocs : (NSInteger) myInt
{
[docHandler getDocs:myInt limit:InitLoad_Count];
// the doc handler will call syncDocFinish automatically
}
- (void) syncDocFinish : (id) result
{
isSyncDocFinish = YES;
/// do functions{
}
/// sync doc is finished insert code to call [self syncDocs:myInteger]; again
}
答案 2 :(得分:-1)
为此任务提供了几种解决方案:
我不会详细描述这些内容,因为互联网上有很多关于它的信息。 我建议搜索&#34;如何使用NSOperation依赖&#34;或阅读此NSOperation howto