On 16 Dec 2012, at 10:45, Tamas Nagy <tamas.lov.n...@gmail.com> wrote:
> Hey, > > I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The panel > displays, but no files going to be displayed - the circle just spinning on > the bottom-left corner. Anyone have an idea what going wrong? > > Thanks, > > Tamas > > dispatch_async(dispatch_get_main_queue(), ^{ > > NSOpenPanel *oPanel = [NSOpenPanel openPanel]; > > NSMutableArray *filetype = [NSMutableArray arrayWithCapacity:0]; > > [filetype insertObject:@"txt" atIndex:0]; > > [oPanel setAllowedFileTypes:filetype]; > [oPanel setDirectoryURL:[NSURL URLWithString:NSHomeDirectory()]]; > > > NSInteger returnCode = [oPanel runModal]; > > if (returnCode == NSOKButton) { > > NSLog(@"OK!"); > > } else { > > NSLog(@"Cancel!"); > } > > }); I can't see off the top of my head what's going wrong here, but I just thought I'd comment that that looks like a pretty bizarre way of creating a constant array. 1) You know exactly how big the array's going to be – 1 object, so why hint that it's going to contain 0 objects? 2) Why use insertObject: atIndex:0 rather than addObject: 3) Why use a mutable array at all? You could just use a constant array – NSArray *filetype = [NSArray arrayWithObject:@"txt"]; 4) The above can then be further condensed with the new syntactic sugar for arrays: NSArray *filetype = @[ @"txt" ]; Thanks Tom Davie _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com