iOS removeObjectAtIndex
你好 我有这段代码来删除NSMutableArray中特定的iOS removeObjectAtIndex,ios,objective-c,Ios,Objective C,你好 我有这段代码来删除NSMutableArray中特定的数据库 -(void)removeDatabaseName:(NSString*)databaseName { // remove database from array of databases for (int index = 0; index < [[self.openDatabases objectForKey:@"databaseName"] count]; index++) { if (
数据库
-(void)removeDatabaseName:(NSString*)databaseName {
// remove database from array of databases
for (int index = 0; index < [[self.openDatabases objectForKey:@"databaseName"] count]; index++) {
if ([[self.openDatabases objectForKey:@"databaseName"] objectAtIndex:index] == databaseName) {
//Match
[[self.openDatabases objectForKey:@"database"] removeObjectAtIndex:index];
[[self.openDatabases objectForKey:@"databaseName"] removeObjectAtIndex:index];
[[self.openDatabases objectForKey:@"location"] removeObjectAtIndex:index];
NSLog(@"removed database");
break;
}
}
}
-(void)removeDatabaseName:(NSString*)数据库名{
//从数据库阵列中删除数据库
对于(int index=0;index<[self.openDatabases objectForKey:@“databaseName”]count];index++){
if([[self.openDatabases objectForKey:@“databaseName”]objectAtIndex:index]==databaseName){
//匹配
[[self.openDatabases objectForKey:@“database”]removeObjectAtIndex:index];
[[self.openDatabases objectForKey:@“databaseName”]removeObjectAtIndex:index];
[[self.openDatabases objectForKey:@“location”]removeObjectAtIndex:index];
NSLog(@“删除的数据库”);
打破
}
}
}
因此,它显示NSLog(@“已删除的数据库”)但我不知道它是否在NSMUTABLEARRY中被完全删除,或者我是否错了,我至少可以删除特定的文件吗?您需要进一步解释您的情况。什么是self.openDatabases?您打算用它做什么?你不知道它是否被完全移除是什么意思?它怎么能被部分移除?为什么你不能检查一下里面的内容,看看它是否被正确删除了?self.openDatabase是一个NSmutableArray,请你再解释一下你的情况。-objectForKey不适用于可变数组。它似乎是一个字典,[self.openDatabases objectForKey:@“databaseName”]给出了数组作为回报。在此基础上,您可以使用objectAtIndex:查找“索引”。它提供了一个要比较的字符串。为什么不打印“self.openDatabases”并检查它是否真的被删除了呢。