Can't get first try of NSURLProtocol subclass to work.
I entered a URL that triggers my handler, but I get this from the Xcode debug log: 2014-10-20 07:42:08.968 MyApp[94134:303] *** Assertion failure in -[NSWindow setTitle:], /SourceCache/AppKit/AppKit-1265.21/AppKit.subproj/NSWindow.m:2901 2014-10-20 07:42:08.972 MyApp[94134:303] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: NSInternalInconsistencyException Invalid parameter not satisfying: aString != nil Here’s my -startLoading method. I tried “about:”, which is the only URL I handle directly in the method. - (void)startLoading { NSAssert([self.class canInitWithRequest:self.request], @Inappropriate request.); NSAssert(!self.processing, @Receiving new protocol request while processing another.); // Handle the blank about: URL. NSString * const path = self.request.URL.path; NSString * const query = self.request.URL.query; if (!path || [path isEqualToString:@]) { if (query) goto error; NSStringEncoding const encoding = NSUTF8StringEncoding; NSData * const aboutData = [@htmlheadtitleabout/title/headbodyabout:/body/html dataUsingEncoding:encoding]; [self.client URLProtocol:self didReceiveResponse:[[NSURLResponse alloc] initWithURL:self.request.URL MIMEType:@text/html expectedContentLength:aboutData.length textEncodingName:nil/*(__bridge_transfer NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(encoding))*/] cacheStoragePolicy:NSURLCacheStorageNotAllowed]; [self.client URLProtocol:self didLoadData:aboutData]; [self.client URLProtocolDidFinishLoading:self]; } else { NSString * const handler = AboutKeyToSelectorMap()[path]; if (handler) { self.processing = [NSThread currentThread]; self.cancelled = NO; [self performSelector:NSSelectorFromString(handler) withObject:query afterDelay:0.0 inModes:@[[NSRunLoop currentRunLoop].currentMode, NSDefaultRunLoopMode]]; } else { goto error; } } return; error: // Bad response. [self.client URLProtocol:self didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorResourceUnavailable userInfo:nil]]; } I thought using “nil” instead of the big expression calculating the encoding string would make a difference. It didn’t. — Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com ___ 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
NSBezierPath with Transparent color stroke
I fill my bezierPath (a simple rect) with a red color. Then I stroke it with a 10 point border with a 50% transparent gray color. Since the border of the path gets drawn 50% inside the path and 50% outside the path, I end up with an external 5 points 50% gray border and an internal 5 points red-gray border. That's really bad. I really need to fill the rect with flat red and stroke it with a 10 points-width 50% transparent gray border. If I draw 2 paths, the one to be filled with red and the one to be stroked with gray, I end up with a small white gap between the 2 paths. How to fix this trouble? Regards -- Leonardo ___ 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
Re: NSBezierPath with Transparent color stroke
On Oct 20, 2014, at 8:50 AM, Leonardo mac.iphone@gmail.com wrote: I fill my bezierPath (a simple rect) with a red color. Then I stroke it with a 10 point border with a 50% transparent gray color. Since the border of the path gets drawn 50% inside the path and 50% outside the path, I end up with an external 5 points 50% gray border and an internal 5 points red-gray border. That's really bad. I really need to fill the rect with flat red and stroke it with a 10 points-width 50% transparent gray border. If I draw 2 paths, the one to be filled with red and the one to be stroked with gray, I end up with a small white gap between the 2 paths. Show what you tried for this last part, because that's probably the best approach. You would inset the rect by half of the stroke width. Fill that inset rect and stroke the original rect. Another approach would be to clip both drawing operations against the same path, except inverted in one case. To invert the clipping you would append a rectangle path much larger than the drawing so you have a rectangle in a rectangle. Set the winding rule to NSEvenOddWindingRule and that makes the interior of the inner rectangle excluded from the path. Don't forget to save and restore the graphics context state around changes to the clipping region as that's the only way to revert a clipping operation. Regards, Ken ___ 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
Custom NSTableRowView Question
I've created and I'm displaying a custom NSTableRowView but I'm having trouble settings its background color. I tried setting it in the init'r but it is getting overwritten. I can intercept the calls to [NSTableRowView setBackgroundColor:] and override the color but before doing that, I'd like to better understand why the color is being set by something else ... and then maybe work within that architecture. With a breakpoint in [NSTableRowView setBackgroundColor:], the stack trace shows me that if I programmatically invoke: [NSTableView setRowSizeStyle:], then [NSTableRowData _setBackgroundColorForRowView:] fires on my custom row view with a color I didn't control. Additonally, when I programmatically invoke [NSOutlineView expandItem:], then [NSTableRowData _setBackgroundColorForRowView:] again fires with a color I didn't set. The background color doesn't get set when I manually expand rows. I'm not sure what other methods secretly reset this background color -- but is there an appropriate way to have the private NSTableRowData invocations set the correct colors? As I mentioned, I can obviously implement setBackgroundColor on the custom table row - but I'm not sure I understand all the possible states I should account for. expanding? selected? etc ... it feels a little heavy handed. For what its worth, setting the color as part of the NSOutlineView delegate's didAddRowView: seems to stick - but since this is a custom row, I prefer to encapsulate the color management in the custom NSTableRowView class itself. Maybe I'm thinking wrong ... Is there an established convention around this? -Luther ___ 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
Re: NSBezierPath with Transparent color stroke
On Oct 20, 2014, at 06:50 , Leonardo mac.iphone@gmail.com wrote: I really need to fill the rect with flat red and stroke it with a 10 points-width 50% transparent gray border. What does that mean? Are you trying to fill the entire rect with red, and wrap a 10-point stroke around it (i.e. completely outside the rect)? In that case, stroke it *first* with a 20-point line width, then fill it. Or are you trying to put a 10-point stroke centered on the rect edge, and fill the interior with red without overlaying the stroke? In that case, inset the rect by 5 points, then do the above. ___ 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
Re: NSBezierPath with Transparent color stroke
Reminds me when I racked my brain trying to figure out how OmniGraffle drew parallel border lines on Beziers. I tried inset/outset, etc, then slapped my forehead when I realized that they just stroked it with a wide line, then again with a narrow line using the background color. Duh! On 10/20/14 11:26 AM, cocoa-dev-requ...@lists.apple.com cocoa-dev-requ...@lists.apple.com wrote: On Oct 20, 2014, at 06:50 , Leonardo mac.iphone@gmail.com wrote: I really need to fill the rect with flat red and stroke it with a 10 points-width 50% transparent gray border. What does that mean? Are you trying to fill the entire rect with red, and wrap a 10-point stroke around it (i.e. completely outside the rect)? In that case, stroke it *first* with a 20-point line width, then fill it. Or are you trying to put a 10-point stroke centered on the rect edge, and fill the interior with red without overlaying the stroke? In that case, inset the rect by 5 points, then do the above. ___ 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
Menubar not always redrawing in 10.10
We're seeing a weird problem in 10.10. Inserting or removing items from the main menubar will often not cause the menubar to redraw. Clicking in the menubar or typing a key equiv used in a menu item will cause it to redraw. I've done quite a bit of dinking around to try to figure out if it's something we're doing, but I'm just not finding anything. One that will fix the problem is to force some time delay before returning from the code that inserted or removed the item. Like I stuck in a 5-tick delay after removing an item, then it always seems to correctly redraw. Has anyone else seen anything weird with the menubar? Our current shipping app still has a few Carbon palettes in it, but I also tried it in our unreleased code base which has no Carbon windows, and it still happens there, but less frequently. I see no messages in the debug console or Console.app. Any ideas? -- Steve Mills office: 952-818-3871 home: 952-401-6255 ___ 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
Re: Custom NSTableRowView Question
On 20 Oct 2014, at 12:08, Luther Baker lutherba...@gmail.com wrote: I tried setting it in the init'r but it is getting overwritten. I can intercept the calls to [NSTableRowView setBackgroundColor:] and override the color but before doing that, I'd like to better understand why the color is being set by something else ... and then maybe work within that architecture. FWIW, I usually implement the didAddRowView:forRow: delegate method and set the color from there. That seems to work. Cheers, -- Uli Kusterer “The Witnesses of TeachText are everywhere...” http://zathras.de ___ 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
Trouble with imported enums in Swift
I'm having weird trouble using a C enumeration imported via bridging header from swift. I can define an instance variable and initialize it using the enum, but I can't compare the enum: Camera.swift:60:18: Cannot invoke '==' with an argument list of type '(@lvalue McpSweepState, McpSweepState)' The code is here: class MyClass { func getCameraState() - McpCameraState { if mSweepState == MCP_SWEEP_UNKNOWN // error here { return MCP_STATE_SWEEP_IN_PROGRESS; } else { return MCP_STATE_READY; } } var mSweepState: McpSweepState= MCP_SWEEP_UNKNOWN; // --- no error } Imported via bridging header: enum McpSweepState { MCP_SWEEP_UNKNOWN = 0, MCP_SWEEP_EMPTY= 1, MCP_SWEEP_ROTATING = 2, MCP_SWEEP_PROCESSING = 3, MCP_SWEEP_COMPLETE = 4, MCP_SWEEP_CANCELED = 5, MCP_SWEEP_ABORTED_PHYSICAL = 6, MCP_SWEEP_ABORTED_DATA = 7, MCP_SWEEP_ERROR= 8, }; typedef enum McpSweepState McpSweepState; enum McpCameraState { MCP_STATE_UNKNOWN = 0, MCP_STATE_READY = 1, MCP_STATE_SWEEP_IN_PROGRESS = 2, MCP_STATE_BLOCKED = 3, }; typedef enum McpCameraState McpCameraState; -- Rick Mann rm...@latencyzero.com ___ 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
Re: Trouble with imported enums in Swift
On 21 Oct 2014, at 10:03 am, Rick Mann rm...@latencyzero.com wrote: I'm having weird trouble using a C enumeration imported via bridging header from swift. I can define an instance variable and initialize it using the enum, but I can't compare the enum: Camera.swift:60:18: Cannot invoke '==' with an argument list of type '(@lvalue McpSweepState, McpSweepState)' The code is here: class MyClass { func getCameraState() - McpCameraState { if mSweepState == MCP_SWEEP_UNKNOWN// error here { return MCP_STATE_SWEEP_IN_PROGRESS; } else { return MCP_STATE_READY; } } var mSweepState: McpSweepState= MCP_SWEEP_UNKNOWN; // --- no error } — well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one. Have you tried 1) a switch 2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN 3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not ___ 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
Re: Trouble with imported enums in Swift
On Oct 20, 2014, at 19:17 , Roland King r...@rols.org wrote: well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one. Well, okay, but == sure is getting confused, but = sees the two types as compatible. Have you tried 1) a switch Type 'McpSweepState' does not conform to protocol 'IntervalType' (I've never been able to get switch to work) 2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN Could not find member 'MCP_SWEEP_UNKNOWN' 3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not Could not find an overload for '!' that accepts the supplied arguments -- Rick Mann rm...@latencyzero.com ___ 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
Re: Trouble with imported enums in Swift
On 21 Oct 2014, at 10:23 am, Rick Mann rm...@latencyzero.com wrote: On Oct 20, 2014, at 19:17 , Roland King r...@rols.org wrote: well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one. Well, okay, but == sure is getting confused, but = sees the two types as compatible well it would, = takes an lvalue of a type and a type, which is what the error message says you have. You’d have thunk == would be smart enough to do the same but clearly it’s not or else they aren’t really the same type, but two different types with the same name or they aren’t enums which have == automagically defined on them (as long as they don’t have associated types). Have you tried 1) a switch Type 'McpSweepState' does not conform to protocol 'IntervalType' (I've never been able to get switch to work) 2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN Could not find member 'MCP_SWEEP_UNKNOWN' 3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not Could not find an overload for '!' that accepts the supplied arguments oh dear you do have some major borkage there. I have no idea what’s going on. Kind of looks like the enum didn’t bridge over as an enum but some other type which doesn’t conform to ‘==‘. Perhaps the typedef of the name 'enum XXX' to ‘XXX' upsets it. Only other thought I have is to change the original version to typedef NS_ENUM( NSInteger, McpSweepState ) { // your enum values here } but I’m not entirely sure I hold out much hope for that either. -- Rick Mann rm...@latencyzero.com ___ 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
Re: Trouble with imported enums in Swift
Sigh, I figured it out. Not only do you have to use NS_ENUM, the enumeration members MUST begin with the name of the enumeration. On Oct 20, 2014, at 19:43 , Roland King r...@rols.org wrote: On 21 Oct 2014, at 10:23 am, Rick Mann rm...@latencyzero.com wrote: On Oct 20, 2014, at 19:17 , Roland King r...@rols.org wrote: well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one. Well, okay, but == sure is getting confused, but = sees the two types as compatible well it would, = takes an lvalue of a type and a type, which is what the error message says you have. You’d have thunk == would be smart enough to do the same but clearly it’s not or else they aren’t really the same type, but two different types with the same name or they aren’t enums which have == automagically defined on them (as long as they don’t have associated types). Have you tried 1) a switch Type 'McpSweepState' does not conform to protocol 'IntervalType' (I've never been able to get switch to work) 2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN Could not find member 'MCP_SWEEP_UNKNOWN' 3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not Could not find an overload for '!' that accepts the supplied arguments oh dear you do have some major borkage there. I have no idea what’s going on. Kind of looks like the enum didn’t bridge over as an enum but some other type which doesn’t conform to ‘==‘. Perhaps the typedef of the name 'enum XXX' to ‘XXX' upsets it. Only other thought I have is to change the original version to typedef NS_ENUM( NSInteger, McpSweepState ) { // your enum values here } but I’m not entirely sure I hold out much hope for that either. -- Rick Mann rm...@latencyzero.com ___ 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/rmann%40latencyzero.com This email sent to rm...@latencyzero.com -- Rick Mann rm...@latencyzero.com ___ 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