Re: Bunch of CoreData based NSDocument questions.

2015-11-23 Thread Ernesto Giannotta
Have you tried this (in your Persistent document subclass)?

- (void)close
{

// we're about to close this document but we have to do some housekeeping
[self cleanup];
[super close];

}

> On 23-Nov-2015, at 07:41, Motti Shneor  wrote:
> 
> Problem is - the application quits immediately even when there are dirty 
> documents open!!! the @#$@#$ document "architecture" feels free to quit 
> because all has been "AutoSaved". not "Saved". I just want the old behavior - 
> you should not be able to quit with dirty documents. That's all.
> 
> I do have, of course, validation on saves (Hmmm CoreData has, and I added 
> my overrides). But happy-happy-document-architecture doesn't really care.
> 
> 

Cool Runnings,
Erne.
___

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: AppleEvents: Send port for process has no send right, port=( port:37207/0x9157 rcv:1,send:0,d:0 limit:5) (findOrCreate()/AEMachUtils.cp #526)

2015-11-23 Thread has

John MacMullin wrote:

> Anyone have an idea of what is causing this message in the log file?
>
> AppleEvents: Send port for process has no send right, port=( 
port:37207/0x9157 rcv:1,send:0,d:0 limit:5) 
(findOrCreate()/AEMachUtils.cp #526)


Nope, although you're obviously not the only one. Given what an 
ill-documented pig the Apple event stack is (and this error is way down 
where it bridges to Mach messages, where even more dragons lie 
), 
you might want to go straight for a TSI 
 and see if that does 
any good. No guarantees - I think there's very few folk at Apple these 
days who give a crap about this stuff, and even fewer who know what 
they're doing - but if they do give a useful response it will save no 
end of time and frustration.



> I am using scripting bridge for several Apple program interfaces.

Essential troubleshooting steps for any Apple event-based IPC problem:

1. If your apps are sandboxed, disable it and see if that makes any 
difference.


2. If you're using Scripting Bridge or JavaScript for Automation, 
rewrite the relevant code in AppleScript, which is the de facto 
standard, and try that:


* If it works in AppleScript then the problem is that SB/JXA are crappy 
broken junk which don't speak Apple events correctly/competently, in 
which case stick to using AppleScript. (It may be a rotten language, but 
it's the only _supported_ option that does Apple event IPC right.) FWIW, 
the AppleScript-ObjC bridge takes most (though not all) of the pain out 
of bridging between the two: Shane Stanley's the go-to guy for ASOC 
questions, and there's a brief how-to here: 
.


* If it doesn't work in AppleScript, then the problem is down in the OS, 
at which point all you can do is dig the web to see if anyone else has 
gotten a solution, or put in a TSI and hope it won't just be a waste of 
a perfectly good ticket.


3. If you've got some cases that are working and some that aren't, you 
could try running with `AEDebug` options enabled 
 and see if you can spot discrepancies in the logged messages that 
might give clues. At the least, it'll give you more data to include in 
your ticket in case they can't replicate it themselves.


HTH

has
___

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: dateFromString won't accept this string:

2015-11-23 Thread Sandor Szatmari
Alex,

Have you tried looking at NSDataDetector. http://nshipster.com/nsdatadetector/

Sandor

> On Nov 22, 2015, at 16:12, Alex Hall  wrote:
> 
> Hey list,
> I’m using NSDateFormatter.dateFromString() to make a date from the date 
> string in a tweet. However, it seems to be returning nil, and I’m not sure 
> why. Is there something else I have to do, like tell the formatter what order 
> to expect components to be in? The string is something like:
> 
> "Sun Nov 22 21:00:39 + 2015”
> 
> Thanks for any suggestions anyone has.
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.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: dateFromString won't accept this string:

2015-11-23 Thread Alex Hall

> On Nov 23, 2015, at 8:00 AM, Sandor Szatmari  
> wrote:
> 
> Alex,
> 
> Have you tried looking at NSDataDetector. 
> http://nshipster.com/nsdatadetector/ 
Thanks for the suggestion. I don't think that would apply here, though; I have 
some JSON data that includes a date as a string. I need to convert that to an 
NSDate object so I can then display it however the user wants, or compare it to 
now, and such. However, that's a really useful page (I love NSHipster) and I'll 
save it for another project I'm thinking about where data detectors will be 
useful.
> 
> Sandor
> 
> On Nov 22, 2015, at 16:12, Alex Hall  > wrote:
> 
>> Hey list,
>> I’m using NSDateFormatter.dateFromString() to make a date from the date 
>> string in a tweet. However, it seems to be returning nil, and I’m not sure 
>> why. Is there something else I have to do, like tell the formatter what 
>> order to expect components to be in? The string is something like:
>> 
>> "Sun Nov 22 21:00:39 + 2015”
>> 
>> Thanks for any suggestions anyone has.
>> ___
>> 
>> 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/admin.szatmari.net%40gmail.com
>>  
>> 
>> 
>> This email sent to admin.szatmari@gmail.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: dateFromString won't accept this string:

2015-11-23 Thread Alex Zavatone
Have you looked into The spec for date formatting?

It is seriously helpful. It's some ISO document.  

Specify the format at which the date is coming in and it should convert.

I will send you my crappy routines for this for iOS.

Sent from my iPhone

> On Nov 23, 2015, at 9:06 AM, Alex Hall  wrote:
> 
> 
>> On Nov 23, 2015, at 8:00 AM, Sandor Szatmari  
>> wrote:
>> 
>> Alex,
>> 
>> Have you tried looking at NSDataDetector. 
>> http://nshipster.com/nsdatadetector/ 
> Thanks for the suggestion. I don't think that would apply here, though; I 
> have some JSON data that includes a date as a string. I need to convert that 
> to an NSDate object so I can then display it however the user wants, or 
> compare it to now, and such. However, that's a really useful page (I love 
> NSHipster) and I'll save it for another project I'm thinking about where data 
> detectors will be useful.
>> 
>> Sandor
>> 
>>> On Nov 22, 2015, at 16:12, Alex Hall >> > wrote:
>>> 
>>> Hey list,
>>> I’m using NSDateFormatter.dateFromString() to make a date from the date 
>>> string in a tweet. However, it seems to be returning nil, and I’m not sure 
>>> why. Is there something else I have to do, like tell the formatter what 
>>> order to expect components to be in? The string is something like:
>>> 
>>> "Sun Nov 22 21:00:39 + 2015”
>>> 
>>> Thanks for any suggestions anyone has.
>>> ___
>>> 
>>> 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/admin.szatmari.net%40gmail.com
>>>  
>>> 
>>> 
>>> This email sent to admin.szatmari@gmail.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/zav%40mac.com
> 
> This email sent to z...@mac.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: Bunch of CoreData based NSDocument questions.

2015-11-23 Thread Motti Shneor

> On Nov 23, 2015, at 09:23, Quincey Morris 
>  wrote:
> 
> On Nov 22, 2015, at 22:41 , Motti Shneor  > wrote:
> 
>> I wish I knew enough to write my own MyPersistentDocument
> 
> The problem is that the way NSDocuments are used is semantically different 
> from the way databases are used, and you *cannot* reconcile the two across 
> all the functions on the NSDocument-based File menu. (This was an old 
> discussion.)

Any references to that old discussion? I’d like to read it. However, I think 
there should be a reasonable way to provide close-enough interpretation to 
NSDocument’s view of documents using CoreData's persistence. Database here is 
only means for partial saving of changes, without re-serializing the whole 
document. In the past there was a whole genre of applications who worked with 
very little Memory, by doing the same thing - reading small parts of their 
document into memory, and writing small changes to the document one at a time. 
Surely, the Document architecture acknowledges such applications.
> 
>> Problem is - the application quits immediately even when there are dirty 
>> documents open!!! the @#$@#$ document "architecture" feels free to quit 
>> because all has been "AutoSaved". not "Saved". I just want the old behavior 
>> - you should not be able to quit with dirty documents. That's all.
> 
> You are probably falling foul of Sudden Termination:
> 
>   
> https://developer.apple.com/library/prerelease/watchos/documentation/Cocoa/Reference/Foundation/Classes/NSProcessInfo_Class/#//apple_ref/doc/uid/2316-SW3
>  
> 

> You can try opting out of this completely, or opting out temporarily. Or 
> possibly the change count type I suggested doesn’t cause the opt-out behavior 
> in NSDocument, in which case you could try NSDocumentChangeDone instead. Or 
> possibly the change count has to be updated later.
> 

Just turned off sudden-termination for my App (setting 
NSSupportsSuddenTermination to “NO” in my info.plist)  to no avail. 

My issue seems different, and can also be easily reproduced in other apps (e.g. 
TextEdit). Quitting it with a dirty document will quit immediately, and on next 
launch the document will be open with all last-session’s changes, and the dirty 
flag on. The last autosaved state can be used to “Save” the changes from 
previous session.

I found this in NSDocument.h 

The default implementation of this method has two rather different behaviors. 
If [[self class] autosavesInPlace] returns YES and [self fileURL] returns 
non-nil then it simply invokes [self autosaveWithImplicitCancellability:NO 
completionHandler:aCompletionHandler] if [self hasUnautosavedChanges] returns 
YES after making sure that any editor registered using Cocoa Bindings' 
NSEditorRegistration informal protocol has committed its changes. Otherwise it 
presents a panel giving the user the choice of canceling, discarding changes, 
or saving. In that case the shouldClose value passed to the delegate will be 
YES if the document was not modified in the first place, or the user chose to 
discard modifications, or chose to save and the saving was successful. NO will 
be passed if the user chose to cancel the operation or saving was unsuccessful. 
Because -saveDocumentWithDelegate:didSaveSelector:contextInfo: is used, an 
alert panel will be presented before the delegate is messaged if saving is 
attempted but does not succeed.
*/
- (void)canCloseDocumentWithDelegate:(id)delegate 
shouldCloseSelector:(SEL)shouldCloseSelector contextInfo:(void *)contextInfo;


While BSManagedDocument open source class I’m using implements this method, It 
is never called in my app. I set up a breakpoints, and added NSLog lines - it’s 
never called, no matter what.

I may be plain stupid, but I can’t understand  the above description especially 
in my context. I can’t even make the break into the “two rather different 
behaviors”. Could anyone please shed light on this? 

Details of my application:  
1. autoSavesInPlace returns YES;
2. [self fileURL] will also return non-nil object.
3. [self hasUnautosavedChanges] will probably return NO
4. I have 2 (or more window controllers with their windows open), only one - 
main window - will return YES for closing the document when it is closed.




___

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: dateFromString won't accept this string:

2015-11-23 Thread Sandor Szatmari
Alex,

What spec are you referring to?  Link?  I was playing around with 
NSDataDetector for pulling dates out of strings in XML dumps of excel files for 
an internal tool I was writing.  NSDataDetectors seemed powerful, but failed 
when the dates weren't totally well formed (Tested on 10.8.5, SDK 10.8); the 
dates were still totally recognizable by humans, just missing some whitespace 
here or there.   It did handle differently formatted dates very well though.  I 
ended up using regular expressions to 'parse' the dates as there was just one 
format I was dealing with and the issue was just the missing whitespace.  Maybe 
I didn't know how to configure it to be more flexible or tolerant of the format 
deviations?

Sandor

On Nov 23, 2015, at 9:33 AM, Alex Zavatone  wrote:

> Have you looked into The spec for date formatting?
> 
> It is seriously helpful. It's some ISO document.  
> 
> Specify the format at which the date is coming in and it should convert.
> 
> I will send you my crappy routines for this for iOS.
> 
> Sent from my iPhone
> 
>> On Nov 23, 2015, at 9:06 AM, Alex Hall  wrote:
>> 
>> 
>>> On Nov 23, 2015, at 8:00 AM, Sandor Szatmari  
>>> wrote:
>>> 
>>> Alex,
>>> 
>>> Have you tried looking at NSDataDetector. 
>>> http://nshipster.com/nsdatadetector/ 
>> Thanks for the suggestion. I don't think that would apply here, though; I 
>> have some JSON data that includes a date as a string. I need to convert that 
>> to an NSDate object so I can then display it however the user wants, or 
>> compare it to now, and such. However, that's a really useful page (I love 
>> NSHipster) and I'll save it for another project I'm thinking about where 
>> data detectors will be useful.
>>> 
>>> Sandor
>>> 
 On Nov 22, 2015, at 16:12, Alex Hall >>> > wrote:
 
 Hey list,
 I’m using NSDateFormatter.dateFromString() to make a date from the date 
 string in a tweet. However, it seems to be returning nil, and I’m not sure 
 why. Is there something else I have to do, like tell the formatter what 
 order to expect components to be in? The string is something like:
 
 "Sun Nov 22 21:00:39 + 2015”
 
 Thanks for any suggestions anyone has.
 ___
 
 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/admin.szatmari.net%40gmail.com
  
 
 
 This email sent to admin.szatmari@gmail.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/zav%40mac.com
>> 
>> This email sent to z...@mac.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: dateFromString won't accept this string:

2015-11-23 Thread Alex Hall

> On Nov 23, 2015, at 4:32 PM, Sandor Szatmari  
> wrote:
> 
> Alex,
> 
> What spec are you referring to?  Link?  I was playing around with 
> NSDataDetector for pulling dates out of strings in XML dumps of excel files 
> for an internal tool I was writing.  NSDataDetectors seemed powerful, but 
> failed when the dates weren't totally well formed (Tested on 10.8.5, SDK 
> 10.8); the dates were still totally recognizable by humans, just missing some 
> whitespace here or there.   It did handle differently formatted dates very 
> well though.  I ended up using regular expressions to 'parse' the dates as 
> there was just one format I was dealing with and the issue was just the 
> missing whitespace.  Maybe I didn't know how to configure it to be more 
> flexible or tolerant of the format deviations?

Fortunately, Twitter seems to do things consistently. I'll reg-exa it if I 
discover problems in testing, but it works for now. Using 
setDateFormat("[standard symbols]") did the job.
> 
> Sandor
> 
> On Nov 23, 2015, at 9:33 AM, Alex Zavatone  wrote:
> 
>> Have you looked into The spec for date formatting?
>> 
>> It is seriously helpful. It's some ISO document.  
>> 
>> Specify the format at which the date is coming in and it should convert.
>> 
>> I will send you my crappy routines for this for iOS.
>> 
>> Sent from my iPhone
>> 
>>> On Nov 23, 2015, at 9:06 AM, Alex Hall  wrote:
>>> 
>>> 
 On Nov 23, 2015, at 8:00 AM, Sandor Szatmari 
  wrote:
 
 Alex,
 
 Have you tried looking at NSDataDetector. 
 http://nshipster.com/nsdatadetector/ 
>>> Thanks for the suggestion. I don't think that would apply here, though; I 
>>> have some JSON data that includes a date as a string. I need to convert 
>>> that to an NSDate object so I can then display it however the user wants, 
>>> or compare it to now, and such. However, that's a really useful page (I 
>>> love NSHipster) and I'll save it for another project I'm thinking about 
>>> where data detectors will be useful.
 
 Sandor
 
> On Nov 22, 2015, at 16:12, Alex Hall  > wrote:
> 
> Hey list,
> I’m using NSDateFormatter.dateFromString() to make a date from the date 
> string in a tweet. However, it seems to be returning nil, and I’m not 
> sure why. Is there something else I have to do, like tell the formatter 
> what order to expect components to be in? The string is something like:
> 
> "Sun Nov 22 21:00:39 + 2015”
> 
> Thanks for any suggestions anyone has.
> ___
> 
> 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/admin.szatmari.net%40gmail.com
>  
> 
> 
> This email sent to admin.szatmari@gmail.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/zav%40mac.com
>>> 
>>> This email sent to z...@mac.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: Bunch of CoreData based NSDocument questions.

2015-11-23 Thread Quincey Morris
On Nov 23, 2015, at 12:50 , Motti Shneor  wrote:
> 
> Any references to that old discussion? I’d like to read it. However, I think 
> there should be a reasonable way to provide close-enough interpretation to 
> NSDocument’s view of documents using CoreData's persistence. Database here is 
> only means for partial saving of changes, without re-serializing the whole 
> document. In the past there was a whole genre of applications who worked with 
> very little Memory, by doing the same thing - reading small parts of their 
> document into memory, and writing small changes to the document one at a 
> time. Surely, the Document architecture acknowledges such applications.

No, it was in the vague past.

In the NSDocument metaphor, you must keep changes to a file (since the last 
save) separate from the file (in its state at the last save). Without that, you 
cannot revert, and you cannot close the document without saving. If you’re 
saving by applying the changes to a copy, you can fulfill the 
reversion/don’t-save requirement, because the saved document doesn’t replace 
the original until the last moment, *and* the replacement is an atomic file 
system operation that can only fully succeed or fully fail.

When you use a database with NSDocument, you can update the original file in 
place safely (assuming the database has transactions that can roll back an 
incomplete write), so there’s no need to copy the database for that reason. 
However, you can’t autosave, because that implies the ability to revert. Your 
current autosave is getting the ability to revert by making a copy of the 
database. If you don’t want that, you can’t autosave, period, since Core Data 
has no user-restorable checkpoints (AFAIK).

If you turn off autosavesInPlace, then you’ll have the old behavior, but you’ll 
have to trust Core Data never to corrupt your database if the app (or the 
system) dies in the middle of a save.

> My issue seems different, and can also be easily reproduced in other apps 
> (e.g. TextEdit). Quitting it with a dirty document will quit immediately, and 
> on next launch the document will be open with all last-session’s changes, and 
> the dirty flag on. The last autosaved state can be used to “Save” the changes 
> from previous session.

I’m sorry, I always get this wrong. It’s behaving correctly according to the 
autosavesInPlace==YES paradigm.

In this case, quitting the app does *not* cause any documents to be saved (or 
the user to be prompted to save), ever. It simply quits the app (well, it does 
an autosave first, if the document state has changed since the most recent 
autosave), and when you start the app again, the document is restored to its 
previous UI state, with the same windows open and the same dirtiness.

The reasoning behind this is that (in modern apps) it doesn’t matter whether 
it’s actually running or not, so long as it can be restored to exactly the most 
recent UI state if it re-launches.

So the problem isn’t that it’s quitting, but that your document isn’t being 
restored properly when it reopens (if it isn’t — maybe it is??). That might be 
because NSPersistentDocument (or your custom clone of it) doesn’t support state 
restoration at all, or because you haven’t implemented the custom restoration 
you need to really get back to where you started.

It’s beginning to sound like autosavesInPlace==NO might be a good starting 
point for clearing your list of problems.

___

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: dateFromString won't accept this string:

2015-11-23 Thread Alex Zavatone
There is some ISO spec for date formatting that Apple’s docs mention IIRC.

Let me sniff around.

http://www.w3.org/TR/NOTE-datetime

Also, from Apple’s docs: 
“ The format string uses the format patterns from the Unicode Technical 
Standard #35”

Don’t go there.  It will hurt you.  I’ve added a great reference link later on.

From what I remember, it’s pretty important to pay attention to the  
character for certain types of time/date formatting and it isn’t easy to 
discover unless you dig pretty deep into the docs.

In any case, I tossed Alex Hall a bunch of samples.

What I had considered this morning was to come up with a few formatting 
approaches and just fail through the ones that return bogus values until you 
get a positive response.

Didn’t have time to dig into it though.

FYI, here are a few of the formatting strings that I’ve used that worked well 
for me.

// Notice the use of 3 or 4 Zs in the formatter.  It matters with respect to 
hours from GMT.
@"-MM-ddHH:mm:ssZZZ”
@"-MM-dd’T'HH:mm:ss” 

For Alex Hall’s date string, it looks like he’s got to add the date offset from 
GMT and a few space characters into the formatter.  That’s what the  stands 
for.

Should be pretty easy, once you see what each of the letters in the formatter 
represent.

Here’s a pretty good (really really good) reference:

http://waracle.net/iphone-nsdateformatter-date-formatting-table/

Cheers,
Alex Zavatone

On Nov 23, 2015, at 4:32 PM, Sandor Szatmari  
wrote:

> Alex,
> 
> What spec are you referring to?  Link?  I was playing around with 
> NSDataDetector for pulling dates out of strings in XML dumps of excel files 
> for an internal tool I was writing.  NSDataDetectors seemed powerful, but 
> failed when the dates weren't totally well formed (Tested on 10.8.5, SDK 
> 10.8); the dates were still totally recognizable by humans, just missing some 
> whitespace here or there.   It did handle differently formatted dates very 
> well though.  I ended up using regular expressions to 'parse' the dates as 
> there was just one format I was dealing with and the issue was just the 
> missing whitespace.  Maybe I didn't know how to configure it to be more 
> flexible or tolerant of the format deviations?
> 
> Sandor
> 
> On Nov 23, 2015, at 9:33 AM, Alex Zavatone  wrote:
> 
>> Have you looked into The spec for date formatting?
>> 
>> It is seriously helpful. It's some ISO document.  
>> 
>> Specify the format at which the date is coming in and it should convert.
>> 
>> I will send you my crappy routines for this for iOS.
>> 
>> Sent from my iPhone
>> 
>>> On Nov 23, 2015, at 9:06 AM, Alex Hall  wrote:
>>> 
>>> 
 On Nov 23, 2015, at 8:00 AM, Sandor Szatmari 
  wrote:
 
 Alex,
 
 Have you tried looking at NSDataDetector. 
 http://nshipster.com/nsdatadetector/ 
>>> Thanks for the suggestion. I don't think that would apply here, though; I 
>>> have some JSON data that includes a date as a string. I need to convert 
>>> that to an NSDate object so I can then display it however the user wants, 
>>> or compare it to now, and such. However, that's a really useful page (I 
>>> love NSHipster) and I'll save it for another project I'm thinking about 
>>> where data detectors will be useful.
 
 Sandor
 
> On Nov 22, 2015, at 16:12, Alex Hall  > wrote:
> 
> Hey list,
> I’m using NSDateFormatter.dateFromString() to make a date from the date 
> string in a tweet. However, it seems to be returning nil, and I’m not 
> sure why. Is there something else I have to do, like tell the formatter 
> what order to expect components to be in? The string is something like:
> 
> "Sun Nov 22 21:00:39 + 2015”
> 
> Thanks for any suggestions anyone has.
> ___
> 
> 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/admin.szatmari.net%40gmail.com
>  
> 
> 
> This email sent to admin.szatmari@gmail.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/zav%40mac.com
>>> 
>>> This email sent to z...@mac.com
> 

___

Re: dateFromString won't accept this string:

2015-11-23 Thread Shane Stanley
On 24 Nov 2015, at 9:26 AM, Alex Zavatone  wrote:
> 
> Here’s a pretty good (really really good) reference:

Except it's out-of-date.



-- 
Shane Stanley 



___

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

Making custom table cells for view-based tables on mac?

2015-11-23 Thread Alex Hall
Hello list,
My Twitter app is working well with its Cocoa bindings and default table cells, 
but I want to do more with said table cells. Right now, I put *all* the text 
into the cell's label, which works fine. I'd like to put the sender, tweet 
text, and timestamp each in their own fields, though, on the assumption that 
this will look better. I'll also want to display thumbnail images for tweets 
that include them, again as part of a cell.

When I look at the cell I got by default, it has a lot of levels to it. I'm not 
sure where to add my own views, or how to assign a separate view controller to 
the cell (just for modularity's sake). What I see is this:

Tweet cell contains: table cell view, text cell..
Tweet Cell -> table cell view contains: table view cell
table view cell contains: table view cell (yes, a second one)

I believe I'd add my views to the top level, so they are on the same level as 
the text cell, but I'm not sure. The docs say I should have a label and an 
image for free, but I don't see either one here. Furthermore, I want my image 
on the right, not the left, unless there's a HIG reason not to do that? Even if 
the thumbnails end up being on the left, I want to understand how to change 
that if I ever wanted to.

Once I get my views in place, I'll have to hook them to the view controller, 
correct? Normally I'd not even ask this, but I had to hook up nothing, and my 
cell already has a label that's not an outlet, so I'm not sure if special rules 
apply to cells.

Can I have a separate view controller for my cell, just to keep things 
organized? I tried to have one for a scroll area inside my main scene, but 
Xcode wouldn't let me. It seems I can have one controller per scene?

According to one doc I was reading, VoiceOver automatically speaks the contents 
of a cell's text field. What if there are multiple ones, though? Or if I want 
VO to ignore the image cell but speak other cells in the row? Or speak 
something different--can I add an accessibility description to a whole cell to 
have VO speak that? If so, it'll be interesting to see if I have to interact 
with the table first, or if not interacting still reads the description instead 
of the text.

Am I confusing multiple fields per cell with multiple cells? I know I can have 
columns in a Mac table, unlike on iOS, but I don't really want that, I don't 
think. If I use multiple columns, once a VoiceOver user interacts with the 
table, up/down move by cell, not by row. Thinking about it, that might be good 
in some situations… Visually, is there value to having multiple columns versus 
multiple text labels in a single column? Would the answer change if I decided 
to add a button to each table row, to open a popover with additional details 
about the tweet? That is, would be button have to be its own cell, or could I 
still add it to a single cell and have it look okay?

Making something that speaks well using VoiceOver is turning out to be way 
easier than making something that looks good visually, which is ironic 
considering how often apps look good but aren't accessible. :D

I've read this:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/TableView/TableViewOverview/TableViewOverview.html

up through designing the cell. They don't say where exactly to add custom views 
to my custom cell, though. They also say to use a subclass of NSTableCellView 
for custom cells, but I'm not clear on what that would do. Have outlets for the 
views in the cell, to be sure, but it wouldn't be part of the table view 
delegate. Oh… Wait, I'd use that subclass to make functions that set the 
different views in the cell, then call those functions from the table's 
delegate, wouldn't I? Makes sense, but I couldn't do that with bindings…

Well, I think that's plenty to start with, and if there are other tutorials, 
I'll read them. I wasn't able to find much on this topic, though. As always, 
thanks for your patience and help. It's really interesting coming at visual 
design and layout from a non-visual perspective. Fun times. :)
___

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

Question about getBytes:length:

2015-11-23 Thread Eric E. Dolecki
I have a bit of old code someone else wrote. I get warnings since getBytes
is deprecated since iOS 8. I don't know enough about this but would like to
use the *getBytes:length:* to turn them off. How would I get a length from
something like this? This is part of code I've bridged into a Swift project.

Thanks,
Eric

-(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
{
char b1[16];
 *   [UUID1.data getBytes:b1]; //<---*
UInt16 b2 = [self swap:UUID2];
if (memcmp(b1, (char *)&b2, 2) == 0)
return 1;
else
return 0;
}
___

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: Question about getBytes:length:

2015-11-23 Thread Lee Ann Rucker
 [UUID1.data getBytes:b1 length:16]
since that's the size of your buffer. Doc says "The number of bytes copied is 
the smaller of the length parameter and the length of the data encapsulated in 
the object."

From: cocoa-dev-bounces+lrucker=vmware@lists.apple.com 
[cocoa-dev-bounces+lrucker=vmware@lists.apple.com] on behalf of Eric E. 
Dolecki [edole...@gmail.com]
Sent: Monday, November 23, 2015 7:55 PM
To: cocoa-dev
Subject: Question about getBytes:length:

I have a bit of old code someone else wrote. I get warnings since getBytes
is deprecated since iOS 8. I don't know enough about this but would like to
use the *getBytes:length:* to turn them off. How would I get a length from
something like this? This is part of code I've bridged into a Swift project.

Thanks,
Eric

-(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
{
char b1[16];
 *   [UUID1.data getBytes:b1]; //<---*
UInt16 b2 = [self swap:UUID2];
if (memcmp(b1, (char *)&b2, 2) == 0)
return 1;
else
return 0;
}
___

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/lrucker%40vmware.com

This email sent to lruc...@vmware.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: Question about getBytes:length:

2015-11-23 Thread Eric E. Dolecki
Thank you very much!

On Mon, Nov 23, 2015 at 11:00 PM Lee Ann Rucker  wrote:

>  [UUID1.data getBytes:b1 length:16]
> since that's the size of your buffer. Doc says "The number of bytes copied
> is the smaller of the length parameter and the length of the data
> encapsulated in the object."
> 
> From: cocoa-dev-bounces+lrucker=vmware@lists.apple.com
> [cocoa-dev-bounces+lrucker=vmware@lists.apple.com] on behalf of Eric
> E. Dolecki [edole...@gmail.com]
> Sent: Monday, November 23, 2015 7:55 PM
> To: cocoa-dev
> Subject: Question about getBytes:length:
>
> I have a bit of old code someone else wrote. I get warnings since getBytes
> is deprecated since iOS 8. I don't know enough about this but would like to
> use the *getBytes:length:* to turn them off. How would I get a length from
> something like this? This is part of code I've bridged into a Swift
> project.
>
> Thanks,
> Eric
>
> -(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
> {
> char b1[16];
>  *   [UUID1.data getBytes:b1]; //<---*
> UInt16 b2 = [self swap:UUID2];
> if (memcmp(b1, (char *)&b2, 2) == 0)
> return 1;
> else
> return 0;
> }
> ___
>
> 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/lrucker%40vmware.com
>
> This email sent to lruc...@vmware.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: Question about getBytes:length:

2015-11-23 Thread Charles Srstka
> On Nov 23, 2015, at 9:55 PM, Eric E. Dolecki  wrote:
> 
> -(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
> {
>char b1[16];
> *   [UUID1.data getBytes:b1]; //<---*
>UInt16 b2 = [self swap:UUID2];
>if (memcmp(b1, (char *)&b2, 2) == 0)
>return 1;
>else
>return 0;
> }

Is there a possible typo here? It looks like you’re reading in 16 *bytes* of 
data, and then comparing it against an integer that is 16 *bits* in size. Is 
that what you meant to do?

At any rate, you’re only comparing the first two bytes here; the other fourteen 
will never be used, unless the code above is a simplification.

Charles

___

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: Question about getBytes:length:

2015-11-23 Thread Eric E. Dolecki
That method is not my code so I can't speak to it. It's from a github
example from a company supplying BT shields for Arduino.

On Mon, Nov 23, 2015 at 11:57 PM Charles Srstka 
wrote:

> On Nov 23, 2015, at 9:55 PM, Eric E. Dolecki  wrote:
>
> -(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
> {
>char b1[16];
>
> *   [UUID1.data getBytes:b1]; //<---*
>
>UInt16 b2 = [self swap:UUID2];
>if (memcmp(b1, (char *)&b2, 2) == 0)
>return 1;
>else
>return 0;
> }
>
>
> Is there a possible typo here? It looks like you’re reading in 16 *bytes*
> of data, and then comparing it against an integer that is 16 *bits* in
> size. Is that what you meant to do?
>
> At any rate, you’re only comparing the first two bytes here; the other
> fourteen will never be used, unless the code above is a simplification.
>
> Charles
>
>
___

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: Question about getBytes:length:

2015-11-23 Thread Charles Srstka
> On Nov 23, 2015, at 11:04 PM, Eric E. Dolecki  wrote:
> 
> That method is not my code so I can't speak to it. It's from a github example 
> from a company supplying BT shields for Arduino.
> 
> On Mon, Nov 23, 2015 at 11:57 PM Charles Srstka  > wrote:
>> On Nov 23, 2015, at 9:55 PM, Eric E. Dolecki > > wrote:
> 
>> -(int) compareCBUUIDToInt:(CBUUID *)UUID1 UUID2:(UInt16)UUID2
>> {
>>char b1[16];
> 
>> *   [UUID1.data getBytes:b1]; //<---*
> 
>>UInt16 b2 = [self swap:UUID2];
>>if (memcmp(b1, (char *)&b2, 2) == 0)
>>return 1;
>>else
>>return 0;
>> }
> 
> 
> Is there a possible typo here? It looks like you’re reading in 16 *bytes* of 
> data, and then comparing it against an integer that is 16 *bits* in size. Is 
> that what you meant to do?
> 
> At any rate, you’re only comparing the first two bytes here; the other 
> fourteen will never be used, unless the code above is a simplification.

Can you look at one of the data objects to see if it actually has 16 bytes of 
data in it?

Charles

___

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: Making custom table cells for view-based tables on mac?

2015-11-23 Thread Quincey Morris
On Nov 23, 2015, at 16:06 , Alex Hall  wrote:
> 
> When I look at the cell I got by default, it has a lot of levels to it. I'm 
> not sure where to add my own views, or how to assign a separate view 
> controller to the cell (just for modularity's sake). What I see is this:
> 
> Tweet cell contains: table cell view, text cell..
> Tweet Cell -> table cell view contains: table view cell
> table view cell contains: table view cell (yes, a second one)
> 
> I believe I'd add my views to the top level, so they are on the same level as 
> the text cell, but I'm not sure.

You’ve described three levels here, but there are actually four. 

The first (top) level is actually the table column. Inside it is a table cell 
view and a NSCell that you should ignore.

The second level is the table cell view. It contains a text field.

The third level is the text field.  Inside it is a NSCell that you should 
ignore.

So you’ll add views into the second level, that is as siblings of the text 
field at level 3, but you’ll have to do some preparation first.

> The docs say I should have a label and an image for free, but I don't see 
> either one here.

In OS X, you drag in “Image & Text Table Cell View” from the object library, as 
a sibling of the table cell view at level 2. Then delete the original table 
cell view. (I think this is different for UITableView.)

> Furthermore, I want my image on the right, not the left, unless there's a HIG 
> reason not to do that? Even if the thumbnails end up being on the left, I 
> want to understand how to change that if I ever wanted to.

The image is going to appear on the left (or perhaps on the right for 
right-to-left locales). I’m not sure if you can fiddle with this in IB — the 
eventual placement might be the result of layout decisions in the 
NSTableCellView class.

If IB won’t let you put the image where you want it, you can always go back to 
the text only cell, and add your own custom image subview.

> Once I get my views in place, I'll have to hook them to the view controller, 
> correct? Normally I'd not even ask this, but I had to hook up nothing, and my 
> cell already has a label that's not an outlet, so I'm not sure if special 
> rules apply to cells.

Nope. If you have custom subviews, you need to subclass NSTableCellView to 
provide outlets to your new subviews, and potentially other behavior. (The 
standard NSTableCellView may have some programmatic auto-layout behavior 
involving the two standard subviews.)

If your custom subviews have bindings, you might not need the outlets, but I 
don’t see any harm in having the outlets anyway. Once you change the cell view 
subclass from NSTableCellView to your custom subclass, you can drag your other 
subviews into (i.e. inside) the 2nd level of Tweet cell, hook up the outlets in 
IB, and add bindings and autolayout constraints.

The last thing you need to do, if you aren’t using bindings, is update your 
tableView:viewForTableColumn:row: delegate method to set custom subview values 
when configuring the cell view for a particular row/column.

Fun stuff. Subclassing NSTextCellView isn’t something I do very often, so be 
aware I’ve probably got a few details wrong.

> Can I have a separate view controller for my cell, just to keep things 
> organized? I tried to have one for a scroll area inside my main scene, but 
> Xcode wouldn't let me. It seems I can have one controller per scene?

Nope. Cell views aren’t managed by controllers. The 
tableView:viewForTableColumn:row: delegate method is basically the controller.

> According to one doc I was reading, VoiceOver automatically speaks the 
> contents of a cell's text field. What if there are multiple ones, though? Or 
> if I want VO to ignore the image cell but speak other cells in the row? Or 
> speak something different--can I add an accessibility description to a whole 
> cell to have VO speak that? If so, it'll be interesting to see if I have to 
> interact with the table first, or if not interacting still reads the 
> description instead of the text.

Any subviews you add are just views, so they can have the necessary 
accessibility information to describe them individually. I’d assume you can 
just do it at the table cell view level, if you want, but you might have to 
remove standard accessibility annotations on the standard text and image 
subviews.

> Am I confusing multiple fields per cell with multiple cells? I know I can 
> have columns in a Mac table, unlike on iOS, but I don't really want that, I 
> don't think. If I use multiple columns, once a VoiceOver user interacts with 
> the table, up/down move by cell, not by row. Thinking about it, that might be 
> good in some situations… Visually, is there value to having multiple columns 
> versus multiple text labels in a single column? Would the answer change if I 
> decided to add a button to each table row, to open a popover with additional 
> details about the tweet? That is, would be button have to be its own ce

Re: Bunch of CoreData based NSDocument questions.

2015-11-23 Thread Motti Shneor

> On Nov 24, 2015, at 00:14, Quincey Morris 
>  wrote:
> 
> On Nov 23, 2015, at 12:50 , Motti Shneor  > wrote:
>> 
>> Any references to that old discussion? I’d like to read it. However, I think 
>> there should be a reasonable way to provide close-enough interpretation to 
>> NSDocument’s view of documents using CoreData's persistence. Database here 
>> is only means for partial saving of changes, without re-serializing the 
>> whole document. In the past there was a whole genre of applications who 
>> worked with very little Memory, by doing the same thing - reading small 
>> parts of their document into memory, and writing small changes to the 
>> document one at a time. Surely, the Document architecture acknowledges such 
>> applications.
> 
> No, it was in the vague past.
> 
> In the NSDocument metaphor, you must keep changes to a file (since the last 
> save) separate from the file (in its state at the last save). Without that, 
> you cannot revert, and you cannot close the document without saving. If 
> you’re saving by applying the changes to a copy, you can fulfill the 
> reversion/don’t-save requirement, because the saved document doesn’t replace 
> the original until the last moment, *and* the replacement is an atomic file 
> system operation that can only fully succeed or fully fail.
> 
All that only makes sense for in-memory documents. Reverting was well known, 
supported and implemented before this architecture, by throwing away unsaved 
changed. That of course doesn’t cover “Autosave” in its current meaning.

> When you use a database with NSDocument, you can update the original file in 
> place safely (assuming the database has transactions that can roll back an 
> incomplete write), so there’s no need to copy the database for that reason.

Right

> However, you can’t autosave, because that implies the ability to revert.

But Cocoa undo-manager lives well beyond the “Save” and can easily provide 
Reverting of “autosaved” (meaning, core-data-saved but not “NSDocuent saved” 
data).

> Your current autosave is getting the ability to revert by making a copy of 
> the database. If you don’t want that, you can’t autosave, period, since Core 
> Data has no user-restorable checkpoints (AFAIK).

User restorable checkpoints can easily be found in the undo manager. If you 
only clear your undo stack when NSDocument-Saving, you’re done.

> 
> If you turn off autosavesInPlace, then you’ll have the old behavior, but 
> you’ll have to trust Core Data never to corrupt your database if the app (or 
> the system) dies in the middle of a save.

Tried that too - a zillion other niceties and standard UI of modern NSDocument 
disappear with that. You can’t use the document window’s title for moving, 
renaming, copying etc. You lose the “save as…” for some reason, and many other 
weirdnesses. 

> 
>> My issue seems different, and can also be easily reproduced in other apps 
>> (e.g. TextEdit). Quitting it with a dirty document will quit immediately, 
>> and on next launch the document will be open with all last-session’s 
>> changes, and the dirty flag on. The last autosaved state can be used to 
>> “Save” the changes from previous session.
> 
> I’m sorry, I always get this wrong. It’s behaving correctly according to the 
> autosavesInPlace==YES paradigm.

Yes.

> 
> In this case, quitting the app does *not* cause any documents to be saved (or 
> the user to be prompted to save), ever. It simply quits the app (well, it 
> does an autosave first, if the document state has changed since the most 
> recent autosave), and when you start the app again, the document is restored 
> to its previous UI state, with the same windows open and the same dirtiness.
> 

But it kills my application state that is not persisted. I’ll explain. I have 
my document (call it database if you want). I have an open “satellite” window 
open, related to that document, showing live microscope data, and the user 
(researches) performs complicated measurement of microscopic object, by drawing 
polygons and bezier curves over identified objects, then adjusts them, then 
completes his measurement to add data to the database. This window is NOT 
tagged as one who “closes the document” because it should not. If the user 
closes this microscope-view window - he’s being asked what to do with the 
incomplete measurement onscreen. But if the user presses Cmd-Q — everything 
just disappears immediately, losing the measurement, the track of where he was 
measuring, and lots of stuff that is not persistent. This is plain ugly - and I 
want to prevent this, but going the same route on quit, as the route of closing 
the window. 


> The reasoning behind this is that (in modern apps) it doesn’t matter whether 
> it’s actually running or not, so long as it can be restored to exactly the 
> most recent UI state if it re-launches.

As you see — it can’t. Maybe I should go the extra mile and learn how to 
preserve my full state? It i