Re: Where can I write in Undo/Redo action titles?

2017-03-27 Thread Quincey Morris
On Mar 27, 2017, at 16:25 , Daryle Walker  wrote:
> 
> The problem is that you’re traditionally supposed to put the names of actions 
> during the action so Undo/Redo can add them to their menu label.

That’s not quite true. By default, *all* of the undo actions registered during 
the current iteration of the run loop are grouped into a single group, which is 
effectively one giant action. The last action name you set while the group is 
“open” (i.e. during the current iteration of the run loop) is what appears on 
the Undo menu item.

That’s what happens when you set up the original action. For the automatic 
undo/redo, I would assume that Core Data would handle resetting the name stored 
with the action (group), but since this is Core Data who knows what it really 
does.

> I do have a pair of menu actions with app-custom code, but the other actions 
> are automatic so there’s no obvious spot to insert action strings.

What menu actions? “undo:” and “redo:”? If you implement those action methods 
yourself, you take on *all* responsibility for maintaining the menu items, 
including filling them out with action names, and internationalizing them. So 
implementing them yourself tends to be a bad idea, precisely because the action 
names will no longer appear unless you do it manually.

___

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: How to debug crash in NSOperation?

2017-03-27 Thread Quincey Morris
On Mar 26, 2017, at 22:04 , Gerriet M. Denkmann  wrote:
> 
> [ arrayOfStrings writeToFile: “directoryPath/SortedKeys.plist” atomically: 
> YES ]; ← pseudo code

A couple of points about this line of code, assuming that the method -[NSArray 
writeToFile:atomically:] is actually being used:

1. This method has a YES/NO result, which you really shouldn’t ignore, if you 
do.

2. This method is a file API with no outError parameter. All such methods 
should be regarded as ancient, undesirable to use, and superseded by a newer 
method that does have an outError parameter. The fact that there is no newer 
method with an outError parameter tells you that Apple has (essentially) 
abandoned this method, and that the replacement API requires a different 
approach. My guess is that the intended replacement is to convert the NSArray 
to a NSData object yourself (through serialization, archiving, or some similar 
technique), and then using one of the more modern NSData file writing methods 
to get it onto disk.

3. Really, don’t use path-based methods any more. Use the URL-based variant. 
(In this case, there is one, but it’s also lacking an outError parameter, so it 
also should be abandoned.)

However, none of the above can explain your crash. The symptoms of the crash 
indicate that the directory listed a file called “SortedKeys.plist”, but the 
file didn’t actually exist (or couldn’t be read), which is on the face of it 
pretty weird. That leads me to:

4. You might use “atomically: NO” instead of “atomically: YES”. It’s not clear 
whether you expect “SortedKeys.plist” to exist already in the directory, but 
I’m guessing not, or that you could delete it manually first. If the file 
doesn’t exist, and if you change your code to capture and handle file-write 
errors properly, then writing atomically doesn’t have any value, and it may in 
rare cases turn out to be actively harmful.

A successful non-atomic write is an open/write/close sequence. An atomic write 
does that to a temp location on the same HFS volume, then does a file system 
atomic “swap” operation to exchange the data of the real and temp files. On a 
non-local (e.g. network) or non-HFS volume, the file manager may not have 
access to an atomic file swap, so might have to simulate with renames, moves 
and/or copies.

So, an atomic file write involves a longer, possibly quite a lot longer, 
sequence of file system operations, and it’s not totally outside the bounds of 
possibility that there might be some reordering between this sequence and other 
sequences, perhaps even the subsequent directory scan that you do. It doesn’t 
seem outside the bounds of possibility that the directory scan might see the 
directory in a transitional state.

This is highly speculative, and other people may have reasons to argue that 
such a reordering cannot legally take place, but if you use a non-atomic write 
you eliminate any possible timing window on the directory scan, I think.

That doesn’t really touch the “how to debug?” question, to which I don’t know 
the answer, except to suggest you play around trying to make the problem more 
reproducible.

___

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: How to debug crash in NSOperation?

2017-03-27 Thread Gerriet M. Denkmann


Sent from my iPhone

> On 28 Mar 2017, at 10:32, Jens Alfke  wrote:
> 
> 
>> On Mar 27, 2017, at 8:25 PM, Gerriet M. Denkmann  wrote:
>> 
>> 
>> 
>> Sent from my iPhone
>> 
>>> On 27 Mar 2017, at 23:37, Jens Alfke  wrote:
>>> 
>>> 
 On Mar 26, 2017, at 10:04 PM, Gerriet M. Denkmann  
 wrote:
 
 Yes, you are right. And I have to apologise for not spotting this:
 
 *** Terminating app due to uncaught exception 
 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot 
 be nil (key: SortedKeys.plist)'
>>> 
>>> I recommend always having an exception breakpoint set, to catch things like 
>>> this.
>> 
>> This same error occurred twice within 250 days. Running the code for about a 
>> year in Xcode is really not feasible. 
> 
> But when it did occur, it was hard to figure out what was going on, right?

No, not really. It was just my stupidity of reading the crash log right. 

It clearly showed that it crashed when I asked a Filewrapper (which contains 
about 6 sub wrappers which represent files) for serialised data. 

And one of these subwrappers (which were being put into an NSDictionary) turned 
out to be nil. 

Kind regards,

Gerriet 

___

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


New iTunes visual plugin SDK?

2017-03-27 Thread Greg Weston
So, apparently iTunes 12.6 doesn't support older plugins any more. Has anyone 
seen or heard news of a new SDK so those of us who have created plugins can 
update them?

Greg
___

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: How to debug crash in NSOperation?

2017-03-27 Thread Jens Alfke

> On Mar 27, 2017, at 8:25 PM, Gerriet M. Denkmann  wrote:
> 
> 
> 
> Sent from my iPhone
> 
> On 27 Mar 2017, at 23:37, Jens Alfke  > wrote:
> 
>> 
>>> On Mar 26, 2017, at 10:04 PM, Gerriet M. Denkmann >> > wrote:
>>> 
>>> Yes, you are right. And I have to apologise for not spotting this:
>>> 
>>> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
>>> reason: '*** setObjectForKey: object cannot be nil (key: SortedKeys.plist)'
>> 
>> I recommend always having an exception breakpoint set, to catch things like 
>> this.
> 
> This same error occurred twice within 250 days. Running the code for about a 
> year in Xcode is really not feasible. 

But when it did occur, it was hard to figure out what was going on, right? So 
if you have the breakpoint already there, then instead of crashing you stop at 
the breakpoint, which is much easier to debug.

> If no race condition (and I agree that there should be none) what else could 
> be causing this?

Dunno. It’s somewhere inside Foundation code. If you have the backtrace, 
looking at the method names can be a clue sometimes.

—Jens

___

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: How to debug crash in NSOperation?

2017-03-27 Thread Gerriet M. Denkmann


Sent from my iPhone

> On 27 Mar 2017, at 23:37, Jens Alfke  wrote:
> 
> 
>> On Mar 26, 2017, at 10:04 PM, Gerriet M. Denkmann  
>> wrote:
>> 
>> Yes, you are right. And I have to apologise for not spotting this:
>> 
>> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
>> reason: '*** setObjectForKey: object cannot be nil (key: SortedKeys.plist)'
> 
> I recommend always having an exception breakpoint set, to catch things like 
> this.

This same error occurred twice within 250 days. Running the code for about a 
year in Xcode is really not feasible. 
> 
>> I suspect that this might be a rare timing issue, i.e. SortedKeys.plist has 
>> not been fully written when serializedRepresentation is called.
> 
> Is the snippet you posted all code running in the same thread/queue? If so, 
> there couldn’t be a race condition between writing the plist and reading it.

Yes, all is running in the same thread. 

If no race condition (and I agree that there should be none) what else could be 
causing this?

Kind regards,

Gerriet 

___

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

Where can I write in Undo/Redo action titles?

2017-03-27 Thread Daryle Walker
[I thought I wrote something about this, but I didn’t see it in my Sent e-mail 
list.]

I “drunk the Kool-Aid” and have a Core Data-based model and using Cocoa 
Bindings. This combination gives me Undo support. The problem is that you’re 
traditionally supposed to put the names of actions during the action so 
Undo/Redo can add them to their menu label. I do have a pair of menu actions 
with app-custom code, but the other actions are automatic so there’s no obvious 
spot to insert action strings.

Any ideas of where I can interrupt the Undo/Redo process to insert titles? Or 
do I have to live with plain “Undo” and “Redo” for my actions?

— 
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: Can't access by data via KVC during KVO

2017-03-27 Thread Quincey Morris
On Mar 27, 2017, at 14:48 , Daryle Walker  wrote:
> 
> The message observation points to the object controller’s “selection”, then a 
> specific property of my model (of type “String?”).

>> Could not cast value of type '_NSStateMarker' (0x7fffa3003cf8) to 'NSString' 
>> (0x7fffa397df38).
>> 2017-03-27 16:36:33.978709 XNW[39160:4830169] Could not cast value of type 
>> '_NSStateMarker' (0x7fffa3003cf8) to 'NSString' (0x7fffa397df38).
> 
> What is this “NSStateMarker” class? And why does it prevent me from accessing 
> the data?

In short, you shouldn’t be using the “selection” property as if it means 
something for an object controller. Yes, you *can* select an object in the 
object controller’s content as *the* selection, but it doesn’t help you with 
anything — it doesn’t represent anything in the UI.**

By definition, the “selection” is a proxy for an object (NSObjectController) or 
an array of objects (NSArrayController, which is a *subclass* of 
NSObjectController), but it can also represent a marker value, indicating no 
selection or multiple selection or (IIRC) some other possibilities. I assume 
your crash occurred because at the time you referenced “selection” it was set 
to one of these markers, and hence not castable to a String.

Programming (in the sense of writing actual code) against NS…Controller objects 
is a horrible and dangerous experience, because they’re black boxes and you’ll 
never know what they’re really doing internally. I strongly, strongly recommend 
that you program against the data model directly. There’s no value (that I know 
of) in referencing a NSObjectController as you have. NSArrayController is a bit 
less clear, because if you’re using it to fetch, sort and filter Core Data 
records, then you sort of think you need to use its arrangedObjects property. 
Still, you don’t have to go through a NSArrayController — there’s nothing wrong 
with fetching, sorting and filtering Core Data records yourself.


** I’ve never really understood for sure, but I think the point of having a 
selection is that (by default in IB) NSObjectController models a 
NSMutableDictionary, and it can distinguish between multiple keys “within” the 
“dictionary” that are in most cases just different properties of the content 
object. By binding to “selection” and switching the selection, you can switch 
which key supplies a value to a single UI field (like a primitive master-detail 
arrangement).

In fact, what normally happens is that the keys just represent independent 
objects accessible via the content object, and each of them is bound directly 
to its own UI element. In this case, the selection basically has no meaning.
___

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

Can't access by data via KVC during KVO

2017-03-27 Thread Daryle Walker
This is from my window controller class, which has a (optional) reference to my 
document subclass’s model data. Through Interface Builder, that data is 
connected to a NSObjectController, and a property of that data is connected to 
a NSArrayController. The window controller has outlets to both data 
controllers. The model data is Core Data-based, BTW.

I have to watch the data as part of my scheme to create a character map to use 
for NSTextFinder. Instead of KVO-ing the model data, I do the two data 
controllers instead since those are the “truth” I need to track (in case they 
cache any editing changes).

> headerController.addObserver(self, forKeyPath: 
> MessageWindowController.headerKeyPath, options: .initial, context: 
> )
> messageController.addObserver(self, forKeyPath: 
> MessageWindowController.bodyKeyPath, options: .initial, context: 
> )

The header observation points to the array controller’s “arrangedObjects”. The 
message observation points to the object controller’s “selection”, then a 
specific property of my model (of type “String?”). I try to test an incomplete 
version of the KVO function:

> override func observeValue(forKeyPath keyPath: String?, of object: Any?, 
> change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
> guard let keyPath2 = keyPath, let object2 = object, let change2 = 
> change, let context2 = context else {
> return super.observeValue(forKeyPath: keyPath, of: object, 
> change: change, context: context)
> }
> 
> let changeKind = NSKeyValueChange(rawValue: change2[.kindKey] as! 
> UInt)!
> switch context2 {
> case :
> precondition(keyPath2 == MessageWindowController.headerKeyPath)
> precondition(object2 as AnyObject === headerController)
> break
> case :
> precondition(keyPath2 == MessageWindowController.bodyKeyPath)
> precondition(object2 as AnyObject === messageController)
> assert(changeKind == .setting)
> 
> let newString = (messageController.selection as! 
> NSObject).value(forKey: #keyPath(RawMessage.body)) as! String? 
> //messageController.value(forKeyPath: keyPath2) as! String?
> let bodyTextRangeIndex = textRanges.index(before: 
> textRanges.endIndex)
> let oldBodyTextRange = textRanges[bodyTextRangeIndex]
> let newLength = (newString as NSString?)?.length ?? 0
> if oldBodyTextRange.length != newLength {
> textRanges[bodyTextRangeIndex] = 
> NSMakeRange(oldBodyTextRange.location, newLength)
> }
> break
> default:
> super.observeValue(forKeyPath: keyPath2, of: object2, change: 
> change2, context: context2)
> }
> }

And there’s a crash at the “newString” definition. (The current and 
commented-out versions get the same error. The current version was copied from 
my menu-item validation function, where it actually works.):

> Could not cast value of type '_NSStateMarker' (0x7fffa3003cf8) to 'NSString' 
> (0x7fffa397df38).
> 2017-03-27 16:36:33.978709 XNW[39160:4830169] Could not cast value of type 
> '_NSStateMarker' (0x7fffa3003cf8) to 'NSString' (0x7fffa397df38).

What is this “NSStateMarker” class? And why does it prevent me from accessing 
the data?

Do NSObjectController and/or NSArrayController do any caching of its editing 
data? If not, and we can’t directly solve this problem, I could read the data 
directly from the document’s model objects.

Pre-Send Update:

I took out the “.initial” from the observing setup call, and it works! Why is 
that? Now I have to hope that my concept of the initial text-range array is 
accurate, since I can’t confirm it with an initial pass (for now).

Note that when the window controller goes through “windowDidLoad”, the 
reference to the model data is NIL. (The object and array controllers are still 
bound to it by then, though.) It doesn’t get set to an actual data tree until 
the document’s “makeWindowControllers” call.

Pre-Send Update 2:

I completed a first try for the other property:

> let changeKind = NSKeyValueChange(rawValue: change2[.kindKey] as! 
> UInt)!
> let bodyTextRangeIndex = textRanges.index(before: textRanges.endIndex)
> switch context2 {
> case :
> precondition(keyPath2 == MessageWindowController.headerKeyPath)
> precondition(object2 as AnyObject === headerController)
> 
> let newArray = headerController.mutableArrayValue(forKeyPath: 
> keyPath2) as NSArray
> switch changeKind {
> case .insertion, .removal, .replacement:
> fallthrough
> case .setting:
> var newFieldRanges = RangeArray()
> for newField in newArray {
> let field = newField as! RawHeaderField
> newFieldRanges.append(contentsOf: [field.name, 
> 

Re: Is there a way to access other controller square's other icons programmatically?

2017-03-27 Thread Quincey Morris
On Mar 27, 2017, at 12:50 , Daryle Walker  wrote:
> 
> So, there is no API to getting at runtime the top-bar items that you add?! 
> (If you don’t mind a subclass, you can drag items from the storyboard to the 
> corresponding subclass definition file.)

AFAIK, there is no API for this, starting from the view controller object. If 
you instantiate the NIB yourself (the view controller from the storyboard is 
compiled into some NIB or other), you can get an array of the top level objects 
when the NIB loads, but I don’t see how that helps when you’re using 
storyboards.

> I was trying to avoid using subclasses.

On iOS, business logic typically goes in the view controller, so it’s common to 
subclass. (Exceptions would be when you use a specific kind of view controller, 
such as a table view controller.) That goes hand in hand with the storyboard 
metaphor, when the scenes (object graphs with a view controller at their root) 
don’t have data cross-connections made in IB.

So, I think you have to buy into a fairly similar pattern for storyboards on 
macOS. NSViewController was enhanced to support this, and (minimally) 
subclassing is *how* you get access to custom NIB objects.

If you don’t want to follow this pattern, then I think a better solution is to 
use XIBs rather than storyboards, which is still perfectly feasible. In a 
sense, by choosing a storyboard, you are choosing to partition your UI into 
unconnectable pieces.
___

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: How do I set a NSTextView's font in Interface Builder?

2017-03-27 Thread Daryle Walker

> On Mar 24, 2017, at 2:28 PM, Keary Suska  wrote:
> 
>> On Mar 24, 2017, at 10:33 AM, Jens Alfke  wrote:
>> 
>>> On Mar 23, 2017, at 6:35 PM, Daryle Walker  wrote:
>>> 
>>> I have the NSTextView selected in its storyboard scene. And I have the 
>>> Attributes Inspector active. The entry for the font is empty. Clicking the 
>>> squared-T gives a pop-up with a “Custom” font and changing it to one of the 
>>> fixed selections (User, fixed) doesn’t do any actual change. 
>> 
>> This is a longstanding bug, or maybe it’s an API issue. The problem is that 
>> the view’s text is empty, and an empty NSAttributedString can’t have any 
>> attributes because the attributes are associated with characters.
>> 
>> IIRC you can fix this by adding some placeholder text, even a single space, 
>> in the view, then replacing it at runtime.
> 
> I don’t believe that is actually true. Attributes *can* apply to an empty 
> range. Alternatively, or additionally, I believe if you call 
> setTypingAttributes: on an empty text view that any new types text will use 
> the specified attributes.

I solved this by starting to play with UserDefaults. I added my font as a 
default, then referenced it in the text view with Cocoa Bindings.

— 
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 there a way to access other controller square's other icons programmatically?

2017-03-27 Thread Daryle Walker

> On Mar 24, 2017, at 3:49 PM, Quincey Morris 
>  wrote:
> 
> On Mar 24, 2017, at 11:11 , Daryle Walker  > wrote:
>> 
>> I have a re-explaination, including a picture, at …
> 
> I think I’m beginning to understand what you’re asking. Part of the problem 
> is that Apple has never properly documented the use of storyboards on macOS, 
> and there seems to be no standard pattern for doing many of the things that 
> we used to do when using XIBs instead.

So, there is no API to getting at runtime the top-bar items that you add?! (If 
you don’t mind a subclass, you can drag items from the storyboard to the 
corresponding subclass definition file.)

> If I understand correctly, you have a window with an associated custom 
> subclass of NSWindowController. The root view controller is a 
> NSSplitViewController, with a NSViewController on the left, and a 
> NSTabViewController on the right. Each of the tabs has a NSViewController, 
> with a table view in one tab and a text view in another tab (based on what 
> you said in earlier posts). My structure may not be exactly the same as 
> yours, but it’s something like that, right?

It’s a top/bottom split view. And the table view is on top, while the text view 
is one of the tabs in the bottom half.

> Now, in some of the NSViewController views, you need to use a 
> NSArrayController or NSObjectController, which is added directly to the 
> storyboard. The question then becomes: how to connect the array or object 
> controller to its content (which lies outside the storyboard) and/or 
> establish an outlet to the array or object controller that gives you a 
> programmatic reference to the object in the nib. (In a XIB-based design, this 
> is straightforwardly done via the File’s Owner pseudo-object.)
> 
> I think the short answer is that you should create a subclass for each 
> NSViewController in your tree of controllers. You *could* subclass the split 
> and tab view controllers too, but there’s no real need. The subclass would 
> contain whatever outlets and properties providing access to model data it 
> needs for its particular view. Each VC would have its own set of object 
> and/or array controllers, and each object/array controller would bind or 
> connect to its own VC.

I was trying to avoid using subclasses.

> The only remaining problem is how to establish programmatic references 
> between the WC and the VC subclasses, in particular how to make model data 
> available to the VCs.
> 
> — If this is a non-document app, I would recommend you create a class 
> property in your WC subclass that holds a reference to your singleton WC of 
> that subclass. This reference would be set in an override of the WC init 
> method.
> 
> — If this is a document-based app, I would suggest that your VC subclasses 
> use KVO to observe themselves along key paths of the form 
> “view.window.windowController.document.model…”. You could, for example, 
> create a derived “model” property that returns 
> “view.window.windowController.document.model”, along with a class 
> “keyPathsOfValuesAffectingModel” method to make the derived property KVO 
> compliant. You can then bind UI elements through the model property.
> 
> The only thing to be careful of is that the derived “model” property will be 
> nil initially, so your UI has to do something sensible until the model 
> reference is available (in particular, not crash).
> 
> — Alternatively, you can have the WC walk the tree of VCs, injecting a 
> reference to itself in each VC of known custom subclasses.
> 

I first kept my object and array controllers in my window controller class. I 
walked the controller tree, keeping references to the table and text views, and 
adding the appropriate controller as the view controller’s represented-object. 
(I’m not subclassing, so they have no other use.) I used the represented-object 
as the controller key while building Cocoa Bindings.

> Does any of that help?

— 
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: How to debug crash in NSOperation?

2017-03-27 Thread Jens Alfke

> On Mar 26, 2017, at 10:04 PM, Gerriet M. Denkmann  wrote:
> 
> Yes, you are right. And I have to apologise for not spotting this:
> 
> *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
> reason: '*** setObjectForKey: object cannot be nil (key: SortedKeys.plist)'

I recommend always having an exception breakpoint set, to catch things like 
this.

> I suspect that this might be a rare timing issue, i.e. SortedKeys.plist has 
> not been fully written when serializedRepresentation is called.

Is the snippet you posted all code running in the same thread/queue? If so, 
there couldn’t be a race condition between writing the plist and reading it. If 
not, you need some synchronization between the two operations (the specifics 
would depend on the details of your program.)

—Jens
___

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: How to convert NSData → Property List Object

2017-03-27 Thread Gerriet M. Denkmann

> On 27 Mar 2017, at 15:49, Felix Franz  wrote:
> 
> On 27 Mar 2017, at 10:42, Gerriet M. Denkmann  wrote:
>> 
>> propertyListFromData:mutabilityOption:format:errorDescription: (which 
>> converts an NSData into some property list object) is deprecated.
>> 
>> The documentation says: This method is deprecated. Use 
>> dataWithPropertyList:format:options:error: instead.
>> 
>> But this seems to be the exact opposite: converting a property list object 
>> into NSData.
>> 
>> So: what to use to convert NSData into property list object?
> 
> 
> + propertyListWithData:options:format:error: in NSPropertyListSerialization ,

Thanks a lot! Exactly what I needed.

> looks like a documentation error (I used 10.11-documentation, maybe this is 
> already fixed). 

I use Xcode Version 8.2.1 (8C1002) with macOS 12.3 and it is not yet fixed.

Kind regards,

Gerriet.


___

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


How to convert NSData → Property List Object

2017-03-27 Thread Gerriet M. Denkmann
propertyListFromData:mutabilityOption:format:errorDescription: (which converts 
an NSData into some property list object) is deprecated.

The documentation says: This method is deprecated. Use 
dataWithPropertyList:format:options:error: instead.

But this seems to be the exact opposite: converting a property list object into 
NSData.

So: what to use to convert NSData into property list object?

Gerriet.


___

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