开发者

How to prevent all rows of an NSTableView being selected at startup

I am new to Objective-C. I am using NSArrayController to fill NSTableView. Initially, I am getting all rows selected in the table 开发者_JAVA百科view. I am unable to find the reason behind it.

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


NSArrayController has a property selectsInsertedObjects. If that is YES, inserted objects are marked selected, including the ones added by addObject:.

You can set that property to NO, or you can use the following to unset the selection after adding the items:

mMedia.mcMediaController.mcTableViewMyMedia.selectedObjects = @[];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜