我是Objective-C的新手。我正在使用NSArrayController来填充NSTableView。最初,我在表视图中选择了所有行。我无法找到背后的原因。
for(int i=0;i<nCount;i++)
{
NSString *fileName_File = [[[filenames objectAtIndex:i] lastPathComponent] stringByDeletingPathExtension];
NSString *pathExtension = [[filenames objectAtIndex:i] pathExtension];
NSString *yourPath = [filenames objectAtIndex:i];
NSFileManager *fmgr = [[NSFileManager alloc] init];
NSDictionary *attrs = [fmgr attributesOfItemAtPath: yourPath error: nil];
[attrs retain];
UInt32 result = [attrs fileSize];
/*NSString * zStr1 = [[NSString alloc]initWithFormat:@"%d",i+1];
NSString * zStr2 = [[NSString alloc]initWithFormat:@"%@",fileName_File];
NSString * zStr3 = [[NSString alloc]initWithFormat:@"%@",pathExtension];
NSString * zStr4 = [[NSString alloc]initWithFormat:@"%d",result];
NSString * zStr5 = [[NSString alloc]initWithFormat:@"%@",[filenames objectAtIndex:i]];*/
CMyMediaData * MyMediaObj = [[CMyMediaData alloc]initWithString1:[[NSString alloc]initWithFormat:@"%@",@""]
andString2:[[NSString alloc]initWithFormat:@"%@",fileName_File]
andString3:[[[NSString alloc]initWithFormat:@"%@",pathExtension]uppercaseString]
andString4:[[NSString alloc]initWithFormat:@"%d",result]
andString5:[[NSString alloc]initWithFormat:@"%@",[filenames objectAtIndex:i]]
];
[attrs release];
[mMedia.mcMediaController.mcTableViewMyMedia addObject:MyMediaObj];
//[mMedia.nsMutaryOfDataObject addObject:MyMediaObj];
} this is the code to add data to nsarraycontroller object.mcMediaController is object of NSArrayController
答案 0 :(得分:0)
NSArrayController有一个属性selectsInsertedObjects
。如果为YES,则选择插入的对象,包括addObject:
添加的对象。
您可以将该属性设置为NO,或者您可以在添加项目后使用以下内容取消设置选择:
mMedia.mcMediaController.mcTableViewMyMedia.selectedObjects = @[];