I think I screwed up Core Data multi-threading rules.

2017-02-22 Thread Daryle Walker
I naively thought this was OK, multi-threading wise. It worked before I added 
the “canAsynchronusly…” method to say TRUE for my main file type. When that 
method is added, the save hangs the program.

> override func data(ofType typeName: String) throws -> Data {
> guard typeName == Names.internationalEmailMessageUTI else { throw 
> NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil) }
> 
> // Save the current message data to the store so a background task 
> can see it.
> var messageID: NSManagedObjectID?
> var savingError: Error?
> let mainContext = self.container.viewContext
> mainContext.performAndWait {
> do {
> try mainContext.save()
> } catch {
> savingError = error
> }
> messageID = self.message?.objectID
> }
> 
> // Let the main interface continue.
> self.unblockUserInteraction()
> guard savingError == nil else { throw savingError! }
> guard messageID != nil else { throw NSError(domain: 
> NSCocoaErrorDomain, code: NSCoreDataError, userInfo: nil) }
> 
> // Write out the message data for externalization.
> var result: Data?
> let backgroundContext = self.container.newBackgroundContext()
> backgroundContext.performAndWait {
> let backgroundMessage = backgroundContext.object(with: 
> messageID!) as! RawMessage
> result = backgroundMessage.messageAsExternalData
> }
> return result!
> }

I use the original and the background copy of the message only within each of 
their respective contexts. Is the new persistent-container class not 
thread-safe even for returning (new) contexts? Am I calling 
“unblockUserInteraction” inappropriately? (I had that question in another 
post.) Is it the way I handle throwing?

— 
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

Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Quincey Morris
On Feb 22, 2017, at 17:45 , David Delmonte  wrote:
> 
> It's cell based!

In that case, you need to implement the delegate method 
"tableView(_:willDisplayCell:for:row:)”, which is called once for each cell 
that’s redrawn.

In your method, you need to verify that the cell is of the type you expect (a 
NSTextFieldCell, I’m guessing), cast it to the correct type, and then set its 
backgroundColor property. Note that NSCell does not itself have such a 
property, it’s only implemented by specific subclasses.

Alternatively, it is possible to prepare one cell per color at initialization, 
then supply the correctly colored cell at each row/column. This is slightly 
more efficient, because it doesn’t involve re-configuring the cell each time 
it’s used, but it’s a bit more code (also in the delegate).




___

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: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
I tried you solution but it doesn’t color the cell. Scratching my head some 
more.. I’ll probably ask on Stack Overflow.


> On Feb 22, 2017, at 8:37 PM, Saagar Jha  wrote:
> 
> Well, assuming you have a NSTableCellView, you can set its background color 
> using its layer. For example:
> 
> cell.layer.backgroundColor = NSColor.black.cgColor
> 
> Saagar Jha
> 
>> On Feb 22, 2017, at 16:14, David Delmonte > > wrote:
>> 
>> Hi all, I have a table that has records by date. I want to color those 
>> entries based on the decade.
>> 
>> I cannot seem to find a way to do this.
>> 
>> Any help would be appreciated.
>> 
>> David
>> ___
>> 
>> 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/saagar%40saagarjha.com 
>> 
>> 
>> This email sent to saa...@saagarjha.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: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
It's cell based!

> On Feb 22, 2017, at 20:38, Quincey Morris 
>  wrote:
> 
>> On Feb 22, 2017, at 16:14 , David Delmonte  wrote:
>> 
>> I have a table that has records by date. I want to color those entries based 
>> on the decade.
> 
> NSCell-based or NSView-based?
> 
___

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: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Quincey Morris
On Feb 22, 2017, at 16:14 , David Delmonte  wrote:
> 
> I have a table that has records by date. I want to color those entries based 
> on the decade.

NSCell-based or NSView-based?

___

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: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Saagar Jha
Well, assuming you have a NSTableCellView, you can set its background color 
using its layer. For example:

cell.layer.backgroundColor = NSColor.black.cgColor

Saagar Jha

> On Feb 22, 2017, at 16:14, David Delmonte  wrote:
> 
> Hi all, I have a table that has records by date. I want to color those 
> entries based on the decade.
> 
> I cannot seem to find a way to do this.
> 
> Any help would be appreciated.
> 
> David
> ___
> 
> 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/saagar%40saagarjha.com
> 
> This email sent to saa...@saagarjha.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


Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
Hi all, I have a table that has records by date. I want to color those entries 
based on the decade.

I cannot seem to find a way to do this.

Any help would be appreciated.

David
___

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


When to call unblockUserInteraction()

2017-02-22 Thread Daryle Walker
Although that method doesn't mention it, can I call it during data(ofType:), 
which is called by those other methods by default (I think)?

Sent from my iPad
___

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