I've got a fairly simply application, with IKImageBrowserView embedded in 
NSScrollView, as is the most common case. When running on macOS 10.13 High 
Sierra GM and whenever the IKImageBrowserView is presented and there are enough 
items in it to make it scrollable, it throws and exception with the following 
stack trace:


NSInvalidArgumentException

*** -[NSProxy doesNotRecognizeSelector:lastIndex] called!

0x7fff59b71b27  0x7fff7e452c76  0x7fff57c65bfd  0x7fff57b4a510  0x7fff57b49ed8  
0x7fff62254b98  0x7fff62288543  0x7fff6226b819  0x7fff59bc66d8  0x7fff7f2cb6c1  
0x7fff7f2cb56d  0x7fff7f2cac5d

NSExceptionHandlerExceptionRaiser (in ExceptionHandling) + 160
objc_exception_throw (in libobjc.A.dylib) + 48
+[NSException raise:format:] (in CoreFoundation) + 205
___forwarding___ (in CoreFoundation) + 1456
_CF_forwarding_prep_0 (in CoreFoundation) + 120
IKLimitIndexSetToCount (in ImageKit) + 51
-[IKImageBrowserView(ImageBrowserImport) startScrollPrefetchTask] (in ImageKit) 
+ 157
-[IKTaskManager taskLoop] (in ImageKit) + 2389
__NSThread__start__ (in Foundation) + 1197
_pthread_body (in libsystem_pthread.dylib) + 340
_pthread_body (in libsystem_pthread.dylib) + 0
thread_start (in libsystem_pthread.dylib) + 13


There's really nothing special in the implementation. IKImageBrowserDataSource 
mrotocol methods looks something like:


- (NSUInteger)numberOfItemsInImageBrowser:(IKImageBrowserView *)aBrowser
{
    return [myItems count];
}

- (id)imageBrowser:(IKImageBrowserView *)aBrowser 
itemAtIndex:(NSUInteger)anIndex
{
    return myItems[anIndex];
}


and items implement IKImageBrowserItem also in a very simple way:


- (NSString *)imageUID
{
    return [self bundleIdentifier];
}

- (NSString *)imageRepresentationType
{
    return IKImageBrowserNSImageRepresentationType;
}

- (id)imageRepresentation
{
    return [self image];
}

- (NSString *)imageTitle
{
    return [self displayName];
}

- (BOOL)isSelectable
{
    return YES;
}

- (NSImage *)image
{
    if (!_image)
    {
        NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(128.0, 
128.0)];
        [image lockFocus];
        NSRect imageRect = NSMakeRect(.0, .0, 128.0, 128.0);
        [[NSColor redColor] set];
        [NSBezierPath fillRect:imageRect];
        [[NSColor blackColor] set];
        [NSBezierPath strokeRect:imageRect];
        [image unlockFocus];
        
        [self setImage:image];
    }
    
    return _image;
}


The UI is implemented using xib file, not a storyboard. Even Apple's official 
sample code available at 
https://developer.apple.com/library/content/samplecode/ImageBrowserViewAppearance/Introduction/Intro.html
 suffers from the same issue.

Have anyone find a workaround for this issue. It looks like a bug in the SDK.

Thanks,
-- Dragan

_______________________________________________

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

Reply via email to