Re: Creating NSTableView programmatically

2017-12-12 Thread Jonathan Mitchell

> On 12 Dec 2017, at 19:56, Richard Charles  wrote:
> 
> I always assumed the reason bindings never came over to iOS was they consumed 
> too much cpu power and were too difficult to understand. It seems evident 
> that 10 or 20 years from now Apple anticipates the bulk of it programmers 
> coming out of school will use iPads with the new style documentation. Cocoa 
> bindings do not fit very well into this picture.
I am not sure if stringent power concerns were the overriding factor for 
excluding bindings from iOS. 
Bindings are driven by observations, which do exist on iOS. 
I think that some developers use reactive frameworks such as ReactiveCocoa to 
achieve UI binding on IOS - but I am not sure that would count as a 
simplification.

Cocoa bindings are okay though they lack flexibility and features when compared 
to the likes of WPF bindings.
WPF bindings are just about as tricky to get right - though the use of a GC 
makes life generally easier in a managed world.

Bindings are actually a fairly essential technology for medium to large scale 
data driven macOS applications.
Trying to manually glue hundreds of controls and data paths together quickly 
becomes a major development obstacle.

J

___

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: Creating NSTableView programmatically

2017-12-11 Thread Jonathan Mitchell
For NSTableCellView see
https://developer.apple.com/documentation/appkit/nstablecellview

objectValue is a property on NSTableCellView not on NStableView.

The NSTableViewDelegate method 
- (NSView *)tableView:(NSTableView *)tableView 
viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
provides the required NSTableView instances on demand.

You also need to bind the NSTableView's content object to the 
NSArrayController’s arrangedObjects.

The nib makes all this easier  though its still fiddly.
I would get it working in a nib first and then work backwards from there.


> On 11 Dec 2017, at 10:59, Eric Matecki  wrote:
> 
> 
> Hello,
> 
> I'm trying to implement in Objective-C on macOS *programmatically* the "Real 
> World Example" at the bottom of this page :
> https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/WhatAreBindings.html
> 
> I want to do it programmatically instead of using IB to really understand 
> what happens.
> 
> Just creating the "Attacker" NSTableView causes me already a lot of trouble.
> My code is at the bottom of this message.
> 
> I can't just bind "value" of the attacker tableview to the array controller's 
> "arrangedObjects.name",
> I get a "this class is not key value coding-compliant for the key value" 
> exception.
> 
> So I create a column (I think this is mandatory anyway...).
> In my delegates tableView:viewForTableColumn:row: I create a text field 
> (NSTextView).
> (I create a textfield for now, will probably be a NSButton in the final 
> version).
> 
> I now see a table with four rows (the number of entries in my array), each 
> with a text field I can edit.
> But they start empty and don't change my array of combattants.
> 
> How do I bind this text field to the right "thing" ?
> 
> According to the last paragraph of this page:
> https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/TableView/PopulatingViewTablesWithBindings/PopulatingView-TablesWithBindings.html
> I have to :
> """
> When you make the connection to the table view’s Content binding, the 
> objectValue property of the NSTableViewCell used as the cell for the table 
> column is configured such that for each item in the model array, the table 
> updates the objectValue property to the current row’s Person object.
> """
> But NSTableViewCell doesn't seem to exists (a search on Apple's dev doc gives 
> 27 results... all about *UI*TableViewCell)
> 
> So I need to bind "value" from the text field to "objectValue.name" from... 
> something...
> Whatever I try I get either an exception for not KV compliance, or it doesn't 
> seem to do anything.
> 
> Please shed some light on this...
> Thanks.
> 
> CODE:
> 
> #include "Cocoa/Cocoa.h"
> 
> //===
>  cCombattant
> 
> @interface  cCombattant : NSObject
> 
> @property (copy) NSString*  weapon1;
> @property (copy) NSString*  weapon2;
> @property (copy) NSString*  weapon3;
> @property (copy,readwrite) NSString*  name;
> @propertyNSString**  selectedWeapon;
> 
> - (cCombattant*)initWithName: (NSString*)  iName;
> 
> //DEBUG
> - (void)addObserver: (NSObject *)observer
> forKeyPath: (NSString *)keyPath
>options: (NSKeyValueObservingOptions)options
>context: (void *)context;
> 
> //DEBUG
> - (void)removeObserver: (NSObject *)observer
>forKeyPath: (NSString *)keyPath;
> @end
> 
> 
> @implementation  cCombattant
> 
> - (cCombattant*)initWithName: (NSString*)  iName
> {
>self = [super  init];
> 
>[self  setWeapon1: @"Dagger"];
>[self  setWeapon2: @"Sword"];
>[self  setWeapon3: @"Pike"];
>[self  setSelectedWeapon: &_weapon1];
>[self  setName: iName];
> 
>return  self;
> }
> 
> //DEBUG
> - (void)addObserver: (NSObject *)observer
> forKeyPath: (NSString *)keyPath
>options: (NSKeyValueObservingOptions)options
>context: (void *)context
> {
>printf( "[%p addObserver: %p forKeyPath: %s options: XXX context: %p]\n", 
> self, observer, [keyPath UTF8String], /*options,*/ context );
>int bkpt=bkpt;
>[super  addObserver: observer  forKeyPath: keyPath  options: options  
> context: context];
> }
> 
> //DEBUG
> - (void)removeObserver: (NSObject *)observer
>forKeyPath: (NSString *)keyPath
> {
>printf( "[%p removeObserver: %p forKeyPath: %s]\n", self, observer, 
> [keyPath UTF8String] );
>int bkpt=bkpt;
>[super  removeObserver: observer  forKeyPath: keyPath];
> }
> 
> @end
> 
> //===
>  cDelegate
> 
> @interface  cDelegate : NSObject < NSTableViewDelegate >
> 
> - (cDelegate*)init;
> 
> @end
> 
> 
> @implementation  cDelegate
> 
> 
> - (cDelegate*)init
> {
>self = [super  init];
>return  self;
> }
> 
> - (NSView *)tableView:(NSTableView *)tableV

Re: NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2017-08-30 Thread Jonathan Mitchell

> On 30 Aug 2017, at 18:30, Quincey Morris 
>  wrote:
> 
> On Aug 30, 2017, at 06:18 , Jonathan Mitchell  <mailto:li...@mugginsoft.com>> wrote:
>> 
>> My documents have a lot of variable user cancellable activity that must run 
>> prior to document closure regardless of whether the document is dirty or not.
> 
>> My solution is to run a termination preflight that processes my clean 
>> documents prior to allowing actual termination,
> 
> 
> Instead, the “applicationWillTerminate:” override of your app delegate seems 
> like the right place, especially because it explicitly permits you to delay 
> terminate while you do stuff, without having to run the run loop manually.  
> That’s the *point* of the “applicationWillTerminate:” mechanism.

Thanks for the thoughts.

Using the applicationWillTerminate is probably a less hacky approach like you 
say but it would mean refactoring to accommodate this one troublesome situation 
- I would likely still need to retain the code that handles normal document 
closing as well.

I am not sure that the NSApp -terminate: override is such an issue as the 
problem only occurs when -terminate: is called. If another termination method 
appears on the scene it will likely have its own foibles.

The doc close logic is quite tricky with copies of the NSDocument instance 
being sent to both local and remote URLs. Getting it all to hang together at 
termination in a way that integrates with the NSDocument architecture is 
challenging.
As you say running the loop manually mimics what applicationWillTerminate tries 
to achieve in the first place.

I will keep an eye on how the preflight code works out in the knowledge that I 
can fall back to an “applicationWillTerminate” style approach.
___

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


NSDocument -canCloseDocumentWithDelegate::: not called when terminating

2017-08-30 Thread Jonathan Mitchell
This is one from the archives:

https://lists.apple.com/archives/cocoa-dev/2012/Jul/msg00740.html

In short NSDocument -canCloseDocumentWithDelegate::: gets called on documents 
when closing the document window but only for dirty documents when closing the 
app via NSApp -terminate: (i.e.: the application Quit menu item).
My documents have a lot of variable user cancellable activity that must run 
prior to document closure regardless of whether the document is dirty or not.
Trying to fudge the document dirty flag as and when required just sounds like a 
maintenance headache.

My solution is to run a termination preflight that processes my clean documents 
prior to allowing actual termination,
My experience is that intervening in the NSDocument machinery at critical 
points can be a recipe for disaster if things are not quite right.

If anyone has attempted this in the past comments would be appreciated.

NSApplication subclass
==

- (void)terminate:(id)sender
{
   // The logic here is quite complex
   // 
https://developer.apple.com/documentation/appkit/nsapplication/1428417-terminate?language=objc
   // The receiver calls NSDocumentController to check if documents can be 
closed.
   // If those methods don't handle their callbacks accurately then then this 
method never returns (even in termination does not occur)
   // and I think we end up in an inner run loop.
   //
   // If the termination process succeeds then this method does not return.
   // If the termination process is cancelled then this method does return;

   self.isTerminating = YES;

   // preflight
   // see https://lists.apple.com/archives/cocoa-dev/2012/Jul/msg00740.html
   // when we call terminate: non edited document instances do not get 
processed like diirty docs hence the preflight
   BOOL preflight = [[BPDocumentController sharedDocumentController] 
preflightCloseAllDocumentsOnApplicationTerminate];
   if (preflight) {
   [super terminate:sender];
   }

   self.isTerminating = NO;
}


NSDocumentController subclass
=

- (BOOL)preflightCloseAllDocumentsOnApplicationTerminate
{
   // see https://lists.apple.com/archives/cocoa-dev/2012/Jul/msg00740.html
   // when we call NSApp -terminate: non edited document instances do not get 
processed like dirty docs hence this preflight
   BOOL success = YES;

   // this method is only available if within NSApp -terminate:
   BOOL appTerminating = [(BPApplication *)NSApp isTerminating];
   if (!appTerminating) {
   return NO;
   }

   // we need to preflight non edited documents
   NSArray *cleanDocuments = [self.documents linq_where:^BOOL(BPDocument * doc) 
{
   return !doc.isDocumentEdited;
   }];

   for (NSDocument *doc in cleanDocuments) {
   self.cleanDocumentTerminateInfo = nil;

   // this method is called by default on dirty docs but in order to retain 
our sanity and ensure that the doc close logic
   // is called in all situations we call it here too
   [doc canCloseDocumentWithDelegate:self 
shouldCloseSelector:@selector(onTerminateCleanDocument:shouldClose:contextInfo:)
 contextInfo:NULL];

   // process events until our close selector gets called
   while (!self.cleanDocumentTerminateInfo) {
   NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny 
untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
   [NSApp sendEvent:event];
   }

   success = [self.cleanDocumentTerminateInfo[@"shouldClose"] boolValue];
   if (!success) {
   break;
   }
   }

   self.cleanDocumentTerminateInfo = nil;

   return success;
}

- (void)onTerminateCleanDocument:(NSDocument *)doc 
shouldClose:(BOOL)shouldClose contextInfo:(void  *)contextInfo
{
   self.cleanDocumentTerminateInfo = @{@"document" : doc, @"shouldClose" : 
@(shouldClose)};
}

___

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: NSMutableParagraphStyle -paragraphSpacingBefore

2017-08-22 Thread Jonathan Mitchell

> On 22 Aug 2017, at 18:17, Quincey Morris 
>  wrote:
> 
> On Aug 22, 2017, at 10:02 , Jonathan Mitchell  wrote:
>> 
>> I don’t seem to be having much luck getting NSMutableParagraphStyle 
>> -paragraphSpacingBefore to render.
> 
> To render where? I have never found a way of getting it to be honored at the 
> *top* of a text container, only after a non-empty, non-trivial paragraph of 
> text.
Yes. That might well be the behaviour.

In this case I was trying to adjust the before spacing of the second paragraph.
I hadn’t defined an explicit paragraph style for the first paragraph (which I 
presumed would use the default para style).
Once I set the 1st para to explicitly use [NSParagraphStyle 
defaultParagraphStyle] it rendered ok.

Thanks

J
___

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


NSMutableParagraphStyle -paragraphSpacingBefore

2017-08-22 Thread Jonathan Mitchell
macOS 10.12
I don’t seem to be having much luck getting NSMutableParagraphStyle 
-paragraphSpacingBefore to render.
 NSMutableParagraphStyle -paragraphSpacing seems fine.

Any thoughts?

I know I can work around it if needs be.

J
___

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: Release mode bindings crash and release pools

2017-06-17 Thread Jonathan Mitchell

> On 17 Jun 2017, at 16:36, Charles Srstka  wrote:
> 
>> On Jun 17, 2017, at 8:36 AM, Jonathan Mitchell > <mailto:li...@mugginsoft.com>> wrote:
> 
> 
> Just tested it on 10.9; it works :-)
> 
> import Foundation
> 
> class C: NSObject {
> @objc dynamic var foo = "Foo"
> }
> 
> let c = C()
> 
> let observer = c.observe(\.foo) { obj, _ in
> print("Foo changed: now it's \(obj.foo)")
> }
> 
> c.foo = "Bar"
> 
> Running it on my Mavs VirtualBox VM, this outputs:
> 
> $ ./kvotest
> Foo changed: now it's Bar
> 
> Charles

Thanks for taking the time to test that.
I haven’t had time this week to take look at the new 10.13 APIs.

Will the above translate to Obj-C?

J
___

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: Release mode bindings crash and release pools

2017-06-17 Thread Jonathan Mitchell

> On 17 Jun 2017, at 14:21, Charles Srstka  wrote:
> 
>> On Jun 17, 2017, at 5:32 AM, Jonathan Mitchell > <mailto:li...@mugginsoft.com>> wrote:
>> 
>>> On 16 Jun 2017, at 23:18, Quincey Morris 
>>> >> <mailto:quinceymor...@rivergatesoftware.com>> wrote:
>>> 
>>> On Jun 16, 2017, at 14:41 , Jonathan Mitchell >> <mailto:li...@mugginsoft.com>> wrote:
>>>> 
>>>> I sometimes use the default NSObject bind: to set up a simple one way 
>>>> operation as you describe as opposed to a discrete observation.
>>> 
>>> With macOS 10.13, the new block/closure-based KVO “addObserver” method is 
>>> probably an easier way, although you do have to remove it manually.
>>> 
>> The block/closure improvements are long overdue IMHO.
>> 
>> I use a home brewed approach using BPBlockValueTransformer : 
>> NSValueTransformer with bindings that gives a lot more flexibility.
>> A trivial example involving a closure would be:
>> 
>>BPBlockValueTransformer *blockValueTransformer = [BPBlockValueTransformer 
>> valueTransformerWithBlock:^id(NSNumber *value) {
>>   strongify(self);
>>   return ([value boolValue] || self.isFree)? @“Freedom for all" : 
>> @“Freedom for no-one";
>>}];
>>[self.titleTextField bind:NSValueBinding toObject:self.repObjCon 
>> withKeyPath:@"selection.isHidden" options:@{NSValueTransformerBindingOption 
>> : blockValueTransformer}];
>> 
>> The downside is that you cannot establish the binding in the NIB.
> 
> It’s definitely overdue; I’ve been using a blocks-based wrapper around KVO 
> for years. 
Is that a publicly available wrapper?

> 
> A couple of notes, though, re-reading the message this replied to. The new 
> blocks-based API, ‘observe()’, is actually part of the Swift overlay, which 
> means it works on older macOS versions, not just 10.13. Also, you don’t have 
> to remove it manually, and that’s in fact one of its major features—it 
> automatically deregisters itself whenever the observer falls out of scope. So 
> as long as you make sure you don’t set up a retain cycle with captured 
> values, you can just stash the observer in an ivar, and when your object gets 
> deallocated, your observer will be unregistered. Much easier than what we had 
> to do before.
It would be good if I could get this to work all the way back to 10.9 (that’s 
my deployment target).

Accurately managing observation and object lifetimes is such a big time sink 
that any improvement is always welcome.

J
___

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: Release mode bindings crash and release pools

2017-06-17 Thread Jonathan Mitchell

> On 17 Jun 2017, at 01:54, Charles Srstka  wrote:
> 
>>  it’s preferred that bindings go either through an NSObjectController, an 
>> NSViewController, or something else that implements NSEditorRegistration.

I think that is a crucial aspect in all this.
I while back I configured bindings in contravention of the above and found 
myself literally re-inventing NSEditorRegistration (just to get everything to 
hang together) until the penny dropped.

In my case I route my object bindings through an NSObjectController hosted in 
my NSViewController subclass - I find the that the extra level of indirection 
gives flexibility.

The NSAutoUnbinder support is also crucial.
The public classes that implement it are:

NSViewController.
NSTableCellView
NSWindowController

J
___

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: Release mode bindings crash and release pools

2017-06-17 Thread Jonathan Mitchell

> On 16 Jun 2017, at 23:18, Quincey Morris 
>  wrote:
> 
> On Jun 16, 2017, at 14:41 , Jonathan Mitchell  wrote:
>> 
>> I sometimes use the default NSObject bind: to set up a simple one way 
>> operation as you describe as opposed to a discrete observation.
> 
> With macOS 10.13, the new block/closure-based KVO “addObserver” method is 
> probably an easier way, although you do have to remove it manually.
> 
The block/closure improvements are long overdue IMHO.

I use a home brewed approach using BPBlockValueTransformer : NSValueTransformer 
with bindings that gives a lot more flexibility.
A trivial example involving a closure would be:

BPBlockValueTransformer *blockValueTransformer = [BPBlockValueTransformer 
valueTransformerWithBlock:^id(NSNumber *value) {
   strongify(self);
   return ([value boolValue] || self.isFree)? @“Freedom for all" : 
@“Freedom for no-one";
}];
[self.titleTextField bind:NSValueBinding toObject:self.repObjCon 
withKeyPath:@"selection.isHidden" options:@{NSValueTransformerBindingOption : 
blockValueTransformer}];

The downside is that you cannot establish the binding in the NIB.
___

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: Release mode bindings crash and release pools

2017-06-16 Thread Jonathan Mitchell

> On 16 Jun 2017, at 22:32, Quincey Morris 
>  wrote:
> 
> On Jun 16, 2017, at 13:48 , Charles Srstka  wrote:
>> 
>> This is incorrect.
> 
> It’s incorrect as a 2-way binding, but it works as a pair of so-called 1-way 
> bindings, with the proviso that they may need to be unbound manually, to 
> prevent reference cycles, which it sounds like is what Jerry is doing.
> 
> The thing that I always said that no one believed is that there’s really no 
> such thing as 1-way binding, and NSObject’s default implementation of the 
> “bind:…” method does *not* establish a binding. It’s *part* of the 
> implementation of a proper 2-way binding (as explained in the documentation 
> you referenced), and for a given receiver class the method only establishes a 
> 2-way binding if it’s an override that provides the rest of the functionality.
> 
I sometimes use the default NSObject bind: to set up a simple one way operation 
as you describe as opposed to a discrete observation.
It works fine.

I haven’t quite figured out yet how NSAutoUnbinder breaks the view <-> 
controller retain cycle when the binding object is the controller.


___

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: Release mode bindings crash and release pools

2017-06-15 Thread Jonathan Mitchell

> On 15 Jun 2017, at 20:03, Quincey Morris 
>  wrote:
> 
> On Jun 15, 2017, at 04:46 , Jonathan Mitchell  wrote:
>> 
>> The crash occurs when the pool gets drained.
> 
>> Wrapping my -bind: calls in a release pool solves the issue too.
> 
> The information you’ve provided doesn’t make a lot of sense by itself. If 
> draining an autorelease pool is leading to a crash, then putting the affected 
> objects in a different autorelease pool and draining *that* should also crash.
Thanks for the reply.

Sorry that wasn’t clear.
The crash occurs when the default application created  thread pool gets drained.
It doesn’t crash if I supply a local thread pool that just wraps the -bind:.

Its the timing of when the relevant pool gets drained that seems to be 
important.
I don’t know what effect the release optimisation is having to cause this issue 
to appear.

> 
> Have you tried turning on Zombies to find out which incorrect reference is 
> being followed?
> 
Yes.
The NSViewController is calling its internal implementation that removes itself 
from the responder chain - _removeFromResponderChain
This method calls [NSWindow nextResponder] and the crash occurs there as the 
NSWindow is a zombie.

The nextResponder property uses assign memory semantics so it is prone to this 
sort of thing.
In my NSViewController subclass I already set self.nextResponder to nil in 
dealloc.
But I don’t set self.view.nextResponder to nil in dealloc and this causes the 
crash in loc_307c88: as view.nextResponder == deallocated NSWindow instance.
But setting self.view.nextResponder to nil in dealloc would affect responder 
chain patching for all view controllers and may have unwanted results.
So I will need to think about that.

void -[NSViewController _removeFromResponderChain](void * self, void * _cmd) {
r14 = self;
if ([self _viewControllerSupports10_10Features] == 0x0) goto .l1;

loc_307c3c:
r12 = r14->view;
rax = [r12 nextResponder];
if (rax == 0x0) goto .l1;

loc_307c63:
rbx = rax;
if (rbx == r14) goto loc_307c88;

loc_307c6b:
rax = [rbx nextResponder];
r12 = rbx;
if (rax != 0x0) goto loc_307c63;

.l1:
return;

loc_307c88:
[r12 setNextResponder:[r14 nextResponder]];
return;
}

J
___

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


Release mode bindings crash and release pools

2017-06-15 Thread Jonathan Mitchell
My macOS 10.12 ARC app has a gazillion bindings.

Many are made in the NIBS but a lot are dynamically applied in code.

In release mode I see the odd crash that can be traced back to NSAutoUnbinder 
getting dealloc'd in a release pool.
With build optimisations set to 0 there is no issue.
With build optimisations set to s there is an issue (a views window has been 
deallocated but the controller dealloc queries the responder chain - which uses 
assign semantics - and boom).

The issue occurs when I inadvertently create a binding when my view controller 
is about to be torn down.
An NSAutoUnbinder gets created during a bind call and added to the thread 
release pool.
The crash occurs when the pool gets drained.

My bindings are such that a dynamic binding can in theory get called when the 
view controller is getting torn down so I would like a general solution that 
mitigates the possible issue.

Two questions:

1. Does anyone have any insight into why the release pool draining seems to be 
an issue in release mode - and I know that trying to second guess the macro 
effect of optimisations is pretty thankless. Does the optimisation affect the 
ARC calls?

2. Wrapping my -bind: calls in a release pool solves the issue too. I can 
easily add a category method that wraps each -bind: call in a release pool. But 
what is the over head for this like?

I can of course crank the release optimisation level down to 0 but I have no 
guarantee that the issue will still not occur in some situations.

Thanks

J

___

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: Drawing a 5 Sided Star Shape

2017-06-02 Thread Jonathan Mitchell

> On 2 Jun 2017, at 12:56, Dave  wrote:
> 
> Hi,
> 
> I want to draw a 5 sided Star Shape using UIBezierPath. I’ve search for a 
> general purpose algorithm, but I can’t find anything that I can get to work 
> with Cocoa/Objective-C. 
> 
You could take a peek at https://www.paintcodeapp.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: KVO - deallocation with observers attached

2017-06-02 Thread Jonathan Mitchell

> On 1 Jun 2017, at 00:51, Ken Thomases  wrote:
> 
> On May 31, 2017, at 5:02 PM, Jonathan Mitchell  wrote:
>> 
>> It is common for deallocating objects to abort if they have observers still 
>> registered.
>> 
>> The Data_Test object is deallocated with non nil -observationInfo and yet it 
>> does not abort.
>> Why does this occur?
> 
> It's not clear to me that the KVO machinery is obligated to set 
> observationInfo to nil when an object is no longer being observed.  Note that 
> observationInfo is *not* an object pointer.  It's a pointer to void.  Among 
> other things, that means that there's no memory management involved in the 
> setter.  That is, it's not a strong reference or even a weak one.  So, for 
> example, it's not necessary for KVO to nil it out to free memory.

Thanks for the input.
I wasn’t able to get to the bottom of this despite poking around with Hopper 
through the foundation framework.
There is an NSKVODeallocate foundation function that can get called when an 
observed object gets deallocated.
It raises the familiar KVO exception if -observationInfo is not nil.

- observationInfo does return a void* but it dereferences to an 
NSKeyValueObservationInfo :  NSObject instance.
Its obviously private API though.

I was able to track the comings and goings of NSKeyValueObservationInfo using 
the memory graph debugger and malloc stack logging but enlightenment did not 
strike.

I was able to make my test project behave as I anticipated but my real world 
app doesn’t seem so compliant.

I am just trying to eradicate the possibility of crashes that occur when the 
observing object deallocs and the observed object keeps pumping notifications 
to the old observers address.

Thanks

J

___

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: switching text field between editable and non-editable

2017-05-31 Thread Jonathan Mitchell

> On 31 May 2017, at 21:13, Ken Thomases  wrote:
> 
> On May 31, 2017, at 1:51 PM, J.E. Schotsman  wrote:
>> 
>> I have a hard time achieving what the message title says.
>> Depending on user settings I want a text field to be either editable or 
>> non-editable.

The following works for me.

@implementation NSTextField (CocoaDev)

- (void)bp_styleAsEditableTextField
{
[self setSelectable:YES];
[self setEditable:YES];
[self setDrawsBackground:YES];
[self setBezeled:YES];
[self.cell setScrollable:YES]; // required so that text scrolls 
horizontally when editing
[self.cell setWraps:NO];
[self.cell setLineBreakMode:NSLineBreakByWordWrapping]; // setting to 
truncate here kills the horiz scrolling during edit

[self setContentCompressionResistancePriority:1 
forOrientation:NSLayoutConstraintOrientationHorizontal];
}

- (void)bp_styleAsEditableWrappingTextField
{
[self setSelectable:YES];
[self setEditable:YES];
[self setDrawsBackground:YES];
[self setBezeled:YES];

[self.cell setLineBreakMode:NSLineBreakByWordWrapping];
}

- (void)bp_styleAsLabel
{
[self setSelectable:NO];
[self setEditable:NO];
[self setDrawsBackground:NO];
[self setBezeled:NO];

[self.cell setLineBreakMode:NSLineBreakByTruncatingTail]; // truncate the 
tail
[self setContentCompressionResistancePriority:1 
forOrientation:NSLayoutConstraintOrientationHorizontal];
}

- (void)bp_styleAsWrappingLabel
{
[self setSelectable:NO];
[self setEditable:NO];
[self setDrawsBackground:NO];
[self setBezeled:NO];

[self.cell setLineBreakMode:NSLineBreakByWordWrapping];
}

@end
___

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


KVO - deallocation with observers attached

2017-05-31 Thread Jonathan Mitchell
It is common for deallocating objects to abort if they have observers still 
registered.

However in some cases it seems that an object can get deallocated with 
observers attached and not abort.

I have instrumented my test case thoroughly and overridden -setObservationInfo: 
to log the observation changes as below.

The Data_Test object is deallocated with non nil -observationInfo and yet it 
does not abort.
Why does this occur?

I am sorting through some observer related crash reports just trying to figure 
out possible causes.

The Data_Test object is heavily observed throughout its lifetime both by 
bindings and explicit observations.

macOS 10.12

2017-05-31 22:49:01.616632+0100 MyApp Data_Test (0x11336d100) SetObservationInfo
2017-05-31 22:49:01.616656+0100 MyApp oldObservationInfo : 
 (
 Context: 0x10075a4b8, Property: 
0x6144abc0>
 
Context: 0x0, Property: 0x608000a51280>
)
2017-05-31 22:49:01.616692+0100 MyApp newObservationInfo : 
 (
 Context: 0x10075a4b8, Property: 
0x6144abc0>
)
2017-05-31 22:49:04.188226+0100 MyApp Data_Test (0x11336d100) dealloc

Thanks

Jonathan
___

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: inactive menu item

2017-05-24 Thread Jonathan Mitchell

> On 24 May 2017, at 10:07, J.E. Schotsman  wrote:
> 
> Hello,
> 
> I have a popup button with a menu item that I have set disabled in the xib.
> Every time the popup is enabled the item is enabled too!
> Why isn’t the latent state of the item preserved?
> I can solve the problem by binding the enabled state of the item to a value 
> that is always false but this shouldn’t be necessary IMHO.
> 
> Jan E.

I imagine this is because in the nib auto enables state is on for the popup 
button menu.
See the attributes inspector.

J


___

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: Context leak detected, msgtracer returned -1 ?

2017-05-22 Thread Jonathan Mitchell

> On 22 May 2017, at 22:24, Greg Parker  wrote:
> 
> 
>> On May 22, 2017, at 8:52 AM, Jonathan Mitchell > <mailto:li...@mugginsoft.com>> wrote:
>> 
>> Context leak detected, msgtracer returned -1
>> 
> 
> The context is an IOAccelContext, which itself is deep in the graphics 
> machinery. The log complains once for every 512 objects allocated. Try 
> setting a breakpoint on IOAccelLogContextLeak or fprintf. 
> 
> You should also file a bug report that this log is too vague.
> 
> 
> -- 
> Greg Parker gpar...@apple.com <mailto:gpar...@apple.com> Runtime 
> Wrangler
> 
Thanks for that.

I can now see that an observation is triggering a button redraw.
I am processing a collection at this stage so the button redraw code is 
probably getting hammered.
This is in a tight loop and [NSView displayIfNeeded] is called repeatedly.
Removing this display update request silences the warning.

#0  0x7fff8967b5c4 in IOAccelLogContextLeak ()
#1  0x7fff8967c75d in IOAccelCommandQueueCreateWithQoS ()
#2  0x7fff7e1de805 in -[MTLIOAccelCommandQueue 
initWithDevice:descriptor:] ()
#3  0x7fff7b4f4d45 in CIMetalCommandQueueCreate ()
#4  0x7fff7b4e621c in CI::MetalContext::init(void const*) ()
#5  0x7fff7b3e332f in +[CIContext(Internal) 
internalContextWithMTLDevice:options:] ()
#6  0x7fff7b3ddcd8 in -[CIContext initWithOptions:] ()
#7  0x7fff7b3dd9f2 in +[CIContext contextWithOptions:] ()
#8  0x7fff788b96e9 in -[NSCIImageRep 
CGImageForProposedRect:context:hints:] ()
#9  0x7fff785879ff in -[NSImage 
_newSnapshotRepForRep:rect:context:processedHints:] ()
#10 0x7fff785542c2 in -[NSImage 
_snapshotRepForRep:rect:context:processedHints:] ()
#11 0x7fff78a0fcdb in __71-[NSImage 
drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke.1352 
()
#12 0x7fff78553543 in -[NSImage 
_usingBestRepresentationForRect:context:hints:body:] ()
#13 0x7fff785907e8 in -[NSImage 
drawInRect:fromRect:operation:fraction:respectFlipped:hints:] ()
#14 0x7fff78587480 in -[NSImage 
_drawMappingAlignmentRectToRect:withState:backgroundStyle:operation:fraction:flip:hints:]
 ()
#15 0x7fff78586d93 in -[NSButtonCell drawImage:withFrame:inView:] ()
#16 0x0001004efc7f in -[BPTimelineButtonCell 
drawImage:withFrame:inView:] at BPTimelineButtonCell.m:77
#17 0x7fff78586650 in -[NSButtonCell 
_configureAndDrawImageWithRect:cellFrame:controlView:] ()
#18 0x7fff78586285 in -[NSButtonCell drawInteriorWithFrame:inView:] ()
#19 0x0001004ef525 in -[BPTimelineButtonCell 
drawInteriorWithFrame:inView:] at BPTimelineButtonCell.m:28
#20 0x7fff7858531a in -[NSButtonCell drawWithFrame:inView:] ()
#21 0x0001004ef42c in -[BPTimelineButtonCell drawWithFrame:inView:] at 
BPTimelineButtonCell.m:19
#22 0x7fff785850d1 in -[NSControl drawRect:] ()
#23 0x7fff7857cf99 in -[NSView _drawRect:clip:] ()
#24 0x7fff785ccf2f in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#25 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#26 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#27 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#28 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#29 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#30 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#31 0x7fff785cd39a in -[NSView 
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#32 0x7fff7857aad2 in -[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
 ()
#33 0x7fff785786d8 in -[NSView 
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()
#34 0x7fff78573fca in -[NSView displayIfNeeded] ()
#35 0x0001001eb5be in -[BPTimelineButton setButtonHighlight:] at 
BPTimelineButton.m:211
#36 0x0001001eb227 in -[BPTimelineButton highlightForOffState] at 
BPTimelineButton.m:134
#37 0x0001001eb197 in -[BPTimelineButton stateDidChange] at 
BPTimelineButton.m:123
#38 0x0001001eb29e in -[BPTimelineButton setEnabled:] at 
BPTimelineButton.m:147
#39 0x00010005011d in -[BPPayslipTimelineButton setButtonStatus:] at 
BPPayslipTimelineButton.m:145
#40 0x000100051104 in -[BPPayslipTimelineButton 
observeValueForKeyPath:ofObject:change:context:] at 
BPPayslipTimelineButton.m:277

___

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/Upd

Context leak detected, msgtracer returned -1 ?

2017-05-22 Thread Jonathan Mitchell
Hi

On occasion I see the following in the Xcode console when running my Obj-C app:

Context leak detected, msgtracer returned -1

I have tried setting symbolic breakpoints on NSLog etc but to no avail.

Is the context in question a CGContext?

Thanks

J
___

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: Times in other cities

2017-05-15 Thread Jonathan Mitchell
You might want to err on the side of caution and ensure that the Calendar 
object is explicitly set to Gregorian rather than using the current system 
setting.

Jonathan

> On 15 May 2017, at 13:50, Eric E. Dolecki  wrote:
> 
> Thanks for your reply. Does this look safe to use?
> 
> // London
> let locale = TimeZone.init(abbreviation: "BST")
> let cal = Calendar.current
> let date = Date()
> let comp = cal.dateComponents(in:locale!, from: date)
> 
> // Local (right now for me it's Boston)
> let hour = Calendar.current.component(.hour, from: date)
> 
> print("HOUR OFFSET: \(comp.hour! - hour)") //HOUR OFFSET: 5
> 
> It's okay if the modifier is negative (Los Angeles from Boston, etc.)
> 
> 
> 
> 
> 
> 
> On Sun, May 14, 2017 at 9:29 PM Jens Alfke  wrote:
> 
>> 
>>> On May 14, 2017, at 5:47 PM, Eric Dolecki  wrote:
>>> 
>>> I have a clock. If like to present the times in a few major cities.  Say
>> London, England. Based on the user's current time zone, present the correct
>> hour, min, and second for London. If I can see how to do it for one city, I
>> should be good for others.
>> 
>> Get an NSTimeZone instance based on a GMT offset or a name
>> Create an NSDateFormatter and set its timeZone property.
>> Use the formatter to convert [NSDate date] to a string.
>> 
>> If you want to display the time in some other way, like an analog clock,
>> use NSDateComponents instead of NSDateFormatter; then you can get the
>> hours, minutes and seconds.
>> 
>> —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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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: disable group of controls

2017-04-05 Thread Jonathan Mitchell

> On 5 Apr 2017, at 12:05, J.E. Schotsman  wrote:
> 
> 
>> On 05 Apr 2017, at 11:48, Jack Carbaugh  wrote:
>> 
>> Get a list of the controls then loop through it, setting each enabled 
>> property to false. The container holding them will hold a reference to them
> 
> That way you lose the latent enabled state.
> When the embedder is set to disabled some of the sub controls may already be 
> disabled.
You could create a simple queue for each control (an associated object might be 
handy here) and then push and pop the sub control state.

J
___

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: disable group of controls

2017-04-05 Thread Jonathan Mitchell

> On 5 Apr 2017, at 10:45, J.E. Schotsman  wrote:
> 
> 
>> On 03 Apr 2017, at 21:00, J.E. Schotsman wrote:
>> 
>> What is the Cocoa way of enabling/disabling a group of controls?
>> In Carbon I used to use a user pane for that.
>> I thought I would try an NSBox but then I realized it is not a control.
> 
> Nobody?
> I thought this would be a simple and solved problem.
> I tried subclassing MyEmbedder:NSControl and embedding in a custom view of 
> class MyEmbedder.
> Alas, setting the isEnabled property of the custom view has no effect on the 
> embedded controls.
> What am I missing?

I don’t think you are missing anything.
There is no built in support for this AFAIK.

For disabling groups of controls I generally just bind the relevant controls 
enabled property to a bool flag.

J
___

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: Printing questions

2017-03-13 Thread Jonathan Mitchell

> On 12 Mar 2017, at 21:23, Daryle Walker  wrote:
> 
> 
> 
> Sent from my iPhone
> 
>> On Mar 12, 2017, at 5:18 AM, Daryle Walker  wrote:
>> 
>> I hope it’s a nice first try, but I have some concerns.
>> 
>> 1. I also added an “Export as PDF…” menu item, which uses the save-as-PDF 
>> default action. I guess it calls my code, but the docs for 
>> “NSDocument.pdfPrintOperation” say I should use a separate print-information 
>> objects for PDF mode. Does the default code take care of that already? Or do 
>> I have to figure out somehow if I’m in print-to-PDF mode or regular print 
>> mode and change the initialization of “info” above to be 
>> “self.pdfPrintOperation” as needed?
> 
> And this is why you shouldn't post half-tired. It's "pdfPrintOperation," not 
> "pdfPrintInfo," so my override wouldn't be called by definition. I guess I 
> would override "pdfPrintOperation" to attach a custom print-info, but what 
> should be in it? Is there some Apple sample code on this property? I didn't 
> find it at all on GitHub. 
For NSDocument pdfPrintOperation  The docs say :

Important
This property does not copy the document’s printInfo to the PDF printing 
operation object. Your app should maintain a separate NSPrintInfo instance 
specifically for creating PDFs and assign it to the printInfo property of the 
operation object.

So just just set the printInfo on the operation.

As to how you configure the printInfo it depends on what output you require - 
in general its just a bunch of print settings for page size, margins etc.
However there are a few save related settings.

// flag as a PDF save job
[printInfo setJobDisposition:NSPrintSaveJob];

// Set the target destination for the file
[printInfoDictionary setObject:pdfInfo.URL forKey:NSPrintJobSavingURL];

Jonathan
___

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

struts and springs layout

2017-03-10 Thread Jonathan Mitchell
In Xcode 8 we can use struts and springs style layout until we add an explicit 
constraint.

The idea seems to be that the strut + spring definition get turned into 
constraints.

However, querying NSView -constraints returns nothing in this case, nor does 
the debug view hierarchy.

Is it just that the constraints are private in this case?

And what relevance does NSView -translatesAutoresizingMaskIntoConstraints add 
to the mix now now that we seem to have an auto detection of when we add 
constraints? 
Is it just a legacy behaviour now?

I don’t use the strut and spring method, normally adding whatever constraints I 
need.
But sometimes I think I am missing trick by not using the simpler s + s route 
in some cases.

However a lot of my UI features wrapping text and this is just a pain to 
implement pre 10.11.

Even on 10.12 s + s and text wrapping and textfields don’t seem to get on well.

Thanks

J



___

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: ncurses type wrapper for NStextview

2017-03-06 Thread Jonathan Mitchell

> On 6 Mar 2017, at 21:43, Julie Porter  wrote:
> 
>  I am looking for something much simpler along the lines of
> 
> textmoveto(3,4)
> displaytext(Hello World)
> 

This is probably not what you were thinking of but it does provide for 
positional layout to a pdf view though not an NSTextView..
It is normally driven by an XML mapping file but you can call the required 
methods directly.
You can define all the font characteristics etc in the mapping file.

https://github.com/ThesaurusSoftware/PDFPageBuilder

Search for the following:

[self addTextItem:attrString rect:elementRect];

Jonathan


___

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: Binding NSTextField to an array

2017-03-06 Thread Jonathan Mitchell
Sounds like NSValueTransformer is in fact what you need.
It can take in your NSArray ref and spit out a single NSString that the 
NSTextField binding can live with.

Defining NSValueTransformer subclass for every binding can be a pain.
So I use a block approach. This has the big advantage that you can capture 
other variables if required - like calling a weak self method:

BPBlockValueTransformer * fooTransformer = [BPBlockValueTransformer 
valueTransformerWithBlock:^id(NSArray *a)  {
return [welf soSomethingWith:a];
}];
[self.fooView bind:NSValueBinding toObject:self withKeyPath:@“foo” 
options:@{NSValueTransformerBindingOption: fooTransformer}];


// subclass
@interface BPBlockValueTransformer : NSValueTransformer

+ (instancetype)valueTransformerWithBlock:(id(^)(id value))block;
@property (nonatomic,strong) id (^transform)(id value);

@end

@implementation BPBlockValueTransformer

+ (instancetype)valueTransformerWithBlock:(id(^)(id value))block
{
BPBlockValueTransformer *transformer = [[self alloc] init];
transformer.transform = block;

return transformer;
}

+ (Class)transformedValueClass
{
return [NSObject class];
}

- (id)transformedValue:(id)value
{
return self.transform(value);
}

@end


> On 6 Mar 2017, at 13:32, Jeremy Hughes  wrote:
> 
>> From what I understand of your example, you’re not “binding” anything in a 
>> Cocoa sense.
> 
> In the case of the single value, the text field is set up via the Bindings 
> pane of Interface Builder so that “Value" says “Bind to File’s Owner” with a 
> model key path of self.value. (And “value" is declared as dynamic so that 
> Swift will take care of KVO.) This works fine. Is this not a Cocoa binding?
> 
> What I don’t understand is why this works for a single value but doesn’t work 
> for an array of values, where I change the model key path to self.values.
> 
>> What you is an NSArrayController. Bind your text field to the array 
>> controller. Supply the array controller with content, and have it derive the 
>> selected value, be it single or multiple.
> 
> OK. I now have an array controller that is bound to File’s Owner with a model 
> key path of self.values, and I then bind the text field to the array 
> controller with a Controller Key value of “selection” (although I’m not sure 
> that’s right, because the array is not actually displayed anywhere for users 
> to select items).
> 
> Now I get the following error:
> 
> Cannot create number from object <_NSControllerObjectProxy: 0x600070b0> 
> of class _NSControllerObjectProxy
> 
> Jeremy
> 
> 
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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: Attributed strings - and bounding rects

2017-03-04 Thread Jonathan Mitchell
> I’m still not out of the wood yet though.


Sorry. I should have provided more details.

What I do to support table cell view wrapping is this. However, I have to 
support back to 10.9 so it may be possible to use some of the newer auto 
NSTextField line wrapping stuff.

1. Create a nib containing a wrapping cell view and associate it with a column 
that we want to wrap the content of. View based tableviews use Auto Layout for 
interior layout but in IB it doesn’t generally add and constrains to the 
default table cell views. So make a BPWrappingTableCellView nib that contains 
an NSTextField configured to wrap and constrained to the width and height of 
the cell.

columnCellNib = [[NSNib alloc] initWithNibNamed:@"BPWrappingTableCellView" 
bundle:nil];
[self.tableView registerNib:columnCellNib forIdentifier:@"action”];

2. Now the height of a row in the tableview must equal the height of the 
tallest cell in the row. There is a NSTableViewDelegate call for this. IN this 
example I have only one column that I need to wrap. If you have more you will 
need to find out which column has the tallest content.

- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
// calculate height of row based on height of cell view in variable height 
column
id obj = self.arrayController.arrangedObjects[row];
CGFloat height = [tableView bp_heightOfRowForString:obj.description 
variableHeightColumnIdentifier:@"action"];
return height;
}

3. Calculate height of cell using a worker cell. This is an NSTableView 
category method.

#pragma mark -
#pragma mark Row height support

- (CGFloat)bp_heightOfRowForString:(NSString *)text 
variableHeightColumnIdentifier:(NSString *)identifier
{
/*
 
 Calculate height of row to accomodate wrapping text field in the 
description column.
 On 10.11 it might be possible to just use the fields Automatic setting.
 
 
http://stackoverflow.com/questions/7504546/view-based-nstableview-with-rows-that-have-dynamic-heights
 
 */
// we use a layout worker cell for height calcs.
if (!self.layoutCellView) {
self.layoutCellView = [self makeViewWithIdentifier:identifier 
owner:nil];
}

// reset size
CGFloat width = [self tableColumnWithIdentifier:identifier].width;
[self.layoutCellView setFrameSize:NSMakeSize(width, 10)];

// set the cell text
self.layoutCellView.textField.stringValue = text;

// layout to calculate size
self.layoutCellView.textField.preferredMaxLayoutWidth = width - 
self.layoutCellView.textField.frame.origin.x - 10;
[self.layoutCellView layoutSubtreeIfNeeded];
CGFloat height = self.layoutCellView.frame.size.height;

if (height < 30) height = 30;
if (height > 150) height = 150;

return height;
}

4. Deal with column resizing:

- (void)tableViewColumnDidResize:(NSNotification *)aNotification
{
// notify table view of row height change if variable height column width 
changes
NSTableColumn *tableColumn = aNotification.userInfo[@"NSTableColumn"];
NSTableView *tableView = tableColumn.tableView;
[tableView bp_columnDidResize:tableColumn 
variableHeightColumnIdentifiers:@[@"action"]];
}

Another NSTableView category method.
- (void)bp_columnDidResize:(NSTableColumn *)tableColumn 
variableHeightColumnIdentifiers:(NSArray *)columnIds
{
/*
 
 Trigger row height recalculation when change table column width
 
 */
if (self.numberOfRows > 0 && [columnIds 
containsObject:tableColumn.identifier]) {
 NSIndexSet *rowIndexSet = [NSIndexSet 
indexSetWithIndexesInRange:NSMakeRange(0, self.numberOfRows)];
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0];
[self noteHeightOfRowsWithIndexesChanged:rowIndexSet];
[NSAnimationContext endGrouping];
}
}

HTH

J


___

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: Attributed strings - and bounding rects

2017-03-03 Thread Jonathan Mitchell
Hi

I needed to do this for my pdf builder  implementation:

Using the NSLayoutManager directly gives the best level of control.
 
https://github.com/ThesaurusSoftware/PDFPageBuilder/blob/master/PDFPageBuilder/TSPageTextItem.m#L95

NSRect boundingRect = self.containerRect;

// if no rect height defined then use default
BOOL containerHasExplicitHeight = YES;
if (boundingRect.size.height == 0) {
boundingRect.size.height = self.pageHeight - 
self.containerRect.origin.y ;
containerHasExplicitHeight = NO;
}

// allocate text container and layout manager
NSTextContainer *textContainer = [[NSTextContainer alloc] 
initWithContainerSize:boundingRect.size];
textContainer.lineFragmentPadding = 0;  // defaults to non zero

NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
[layoutManager addTextContainer:textContainer];
layoutManager.usesFontLeading = YES;

// allocate text storage and assign layout manager
self.textStorage = [[NSTextStorage alloc] 
initWithAttributedString:self.attributedString];
[self.textStorage addLayoutManager:layoutManager];

// do glyph layout
// NOTE: cannot quite get glyphRangeForBoundingRect configured correctly 
here
//self.glyphRange = [layoutManager glyphRangeForBoundingRect:boundingRect 
inTextContainer:textContainer];
self.glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];

// get rect used for actual glyph layout
self.usedTextRect = [layoutManager usedRectForTextContainer:textContainer];

Jonathan

> On 3 Mar 2017, at 13:28, Igor Ranieri  wrote:
> 
> Hi Peter.
> 
> 
> Have you tried also passing `usesLineFragmentOrigin` as one of the options? 
> It works here.
> 
> Here’s some code I’m currently using to achieve a similar effect:
> 
> let sizeLimit = CGSize(width: 80.0, height: CGFloat.greatestFiniteMagnitude)
> let size = attrString.boundingRect(with: sizeLimit, options: 
> [.usesLineFragmentOrigin, .usesFontLeading], context: nil).integral.size
> 
> And it returns the expected size.
> 
> 
> best,
> elland
> 
> 
>> On 3. Mar 2017, at 14:18, Peter Hudson  wrote:
>> 
>> Hi All
>> 
>> I have done the following to try to determine the rect required to draw an 
>> attributed string( and thus the height of a row in a table view  - on MacOS 
>> ) 
>> 
>> I am trying to constrain my column width to 60 - and let the possible height 
>> of the row be a max of 1000.
>> 
>> 
>> let aString = anAttributedString
>> let constrainedSize = NSMakeSize(60.0, 1000.0)
>> let optns = NSStringDrawingOptions.usesFontLeading
>> let cntxt = NSStringDrawingContext()
>> cntxt.minimumScaleFactor = 1.0
>> 
>> let aRect = aString?.boundingRect(with: constrainedSize, options: optns, 
>> context: cntxt)
>> 
>> 
>> 
>> After the call to boundingRect,  aRect has its width set to 60 and its 
>> height set to 18.  
>> 
>> This is not however correct for the contents of the attributed string - I 
>> would expect the height to be at least 200 or so with the width constrained 
>> to 60.
>> 
>> Any help gratefully received.
>> 
>> Peter
>> 
>> 
>> 
>> ___
>> 
>> 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/igor%40elland.me
>> 
>> This email sent to i...@elland.me
> 
> 
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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: Xcode Framework wrapper for Library ( Exposing library headers)

2017-02-06 Thread Jonathan Mitchell
Its been a while since I wrapped my little noggin around this issue but perhaps 
this will help:

https://github.com/mugginsoft/Single-Object-Prelink-Framework-Demo 


There is a thread too, but the Apple list server seems to be on the beer again:
https://lists.apple.com/archives/xcode-users/2014/Apr/msg00079.html 


Jonathan

> On 6 Feb 2017, at 22:04, Mr steve davis  
> wrote:
> 
> 
> I would be so grateful if someone could help me, I have been banging my head 
> a against a brick wall for days on this now.
> Here’s a sample project if it helps… 
> http://www.thingsidoatwork.co.uk/MyProject.zip 
> 
> 
> I'm creating a Framework wrapper round a static library. The header 
> (MyLibrary.h) needs to be accessable from the ViewController.m file in 
> MyProject
> 
> MyProject
>   MyFramework
>   MyLibrary.h
>   libMyLibrary.a
> 
> 
> 
> #import "ViewController.h"
> @import MyFramework;
> 
> @implementation ViewController
> 
> - (void)viewDidLoad {
>[super viewDidLoad];
> 
>[[[MyLibrary alloc]init]test];
> }
> 
> 
> I have set MyLibrary.h to public
> MyFramework.h contains the line #import 
> 'Embedded Binaries' is set to MyFramework
> When I run the above code I get...
> 
> 
> Undefined symbols for architecture x86_64:
>  "_OBJC_CLASS_$_MyLibrary", referenced from:
>  objc-class-ref in ViewController.o
> ld: symbol(s) not found for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> 
> 
> The only way I have found to solve this problem is to create a private Class 
> in MyFramework (called TestClass) and allocate MyLibrary. I assume this 
> forces MyLibrary to be linked at runtime and accessable from ViewController.
> But this is ugly as hell, what am I missing? 
> 
> #import "TestClass.h"
> #import "MyLibrary.h"
> 
> @implementation TestClass
> - (id)init {
>if (self = [super init]) {
> 
>[MyLibrary alloc]; //solves the problem of MyLibrary being accessable 
> from  ViewController
>}
>return self;
> }
> @end
> 
> 
> Is there a compiler flag I’m missing that would help? I have tried all-load 
> -ObjC etc but no luck.
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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: Merging scrolling/clipping with NSStackView

2017-01-20 Thread Jonathan Mitchell

> On 20 Jan 2017, at 21:36, Quincey Morris 
>  wrote:
> 
> On Jan 20, 2017, at 02:47 , Jonathan Mitchell  <mailto:li...@mugginsoft.com>> wrote:
>> 
>> NSTableView might go something like this:
>> 
>> @implementation TSTableView
>> 
>> - (NSSize)intrinsicContentSize
>> {
>>  NSSize  size   = [super intrinsicContentSize];
>>  NSInteger   nr  = [self numberOfRows];
>>  CGFloat rh  = [self rowHeight];
>>  CGFloat ih  = [self intercellSpacing].height;
>>  size.height = rh * nr + ih * MAX(nr, 1);
>>  return size;
>> }
> 
> My concern about this approach is timing. It needs to be supported by other 
> code that triggers autolayout whenever the number of rows changes. Further, 
> if the row height is not fixed (either because the height varies from row to 
> row, or because the row height is a logical height influenced by the 
> system-wide font size settings), it gets even more complicated.
Absolutely. Getting from raw concept to actual implementation for a particular 
use case can be a painful process.
And sometimes it is just not worth the candle.
I wince at the thought of the number of hours I have spent wrangling with auto 
layout.

___

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: Merging scrolling/clipping with NSStackView

2017-01-20 Thread Jonathan Mitchell

> On 19 Jan 2017, at 18:25, Quincey Morris 
>  wrote:
> 
> On Jan 19, 2017, at 06:39 , Daryle Walker  wrote:
>> 
>> The inner views should be as tall as they need to be.
> 
> I don’t understand this part. How tall is that?
> 
> I assume you mean that you want the text and table views to be tall enough to 
> show all of their contents, then stacked together and wrapped in a single 
> scroller. Conceptually that makes sense, but:
> 
> 1. The stack view is going to size itself, in the absence of explicit 
> constraints, based on the *intrinsic* sizes of the stacked views, and neither 
> text nor table view is going to report its full height as its intrinsic 
> height. Re-working them to provide that information is going to be very, very 
> painful.
> 
Everything Quincey says is right.
No surprise there then.

However, subclassing NSTableView and NSTextView to provide intrinsicContentSize 
does not have to be awful for a simple scenario (though these sort of things 
can descend into awfulness sometimes…)

Obviously you need to obtain raw NSTableView and NSTextView instances sans 
NSScollView containers.

NSTableView might go something like this:

@implementation TSTableView
 
- (NSSize)intrinsicContentSize
{
NSSize  size   = [super intrinsicContentSize];
NSInteger   nr  = [self numberOfRows];
CGFloat rh  = [self rowHeight];
CGFloat ih  = [self intercellSpacing].height;
size.height = rh * nr + ih * MAX(nr, 1);
return size;
}

For textviews I do something like:

@interface TSTextView : NSTextView

// primitives
@property (assign, nonatomic) CGFloat borderOffsetX;
@property (assign, nonatomic) CGFloat borderOffsetY;
@end


@implementation TSTextView

#pragma mark -
#pragma mark Life cycle

- (instancetype)initWithFrame:(NSRect)frameRect textContainer:(nullable 
NSTextContainer *)container
{
self = [super initWithFrame:frameRect textContainer:container];
if (self) {
[self commonInit];
}
return self;
}

- (nullable instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self commonInit];
}
return self;
}

- (void)commonInit
{
_borderOffsetX = 1;
_borderOffsetY = 3;
self.usesFontPanel = NO;
self.usesFindPanel = NO;

}
#pragma mark -
#pragma mark Auto layout

- (NSSize)intrinsicContentSize
{
NSTextContainer* textContainer = [self textContainer];
NSLayoutManager* layoutManager = [self layoutManager];
[layoutManager ensureLayoutForTextContainer: textContainer];
NSSize size = [layoutManager usedRectForTextContainer: textContainer].size;

return NSMakeSize(NSViewNoInstrinsicMetric, size.height);
}

#pragma mark -
#pragma mark Accessors

- (void)setString:(NSString *)string
{
[super setString:string];
[self invalidateIntrinsicContentSize];
}

#pragma mark -
#pragma mark Text change notifications

- (void)didChangeText
{
[super didChangeText];
[self invalidateIntrinsicContentSize];
}

#pragma mark -
#pragma mark Focus ring

- (void)drawFocusRingMask
{
if (self.editable) {
NSRectFill(self.focusRingMaskBounds);
}
}

- (NSRect)focusRingMaskBounds {
NSRect r = [self bounds];
return NSMakeRect(r.origin.x - self.borderOffsetX, r.origin.y - 
self.borderOffsetY, r.size.width + self.borderOffsetX * 2, r.size.height + 
self.borderOffsetY * 2);
}


___

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: Merging scrolling/clipping with NSStackView

2017-01-19 Thread Jonathan Mitchell

> On 19 Jan 2017, at 14:39, Daryle Walker  wrote:
> 
> Right now, my window has a table view sitting on top of a text view. Those 
> templates from Interface Builder have those NSViews surrounded by a clip view 
> surrounded by a scroll view. But I want to flip that around; put the table 
> and text views together in a stack view, and surround that with clip and 
> scroll views as necessary. 
> 
> The stack view should be as wide as the window. The table and text views 
> should be as wide as their stack view. The inner views should be as tall as 
> they need to be. (The text view should be one line high if there's no text.) 
> I'm thinking of putting a horizontal line between the inner views
> 
> Any ideas how to do this?
> 
Adding the subviews to the NSStackView should be standard fare.
However, I always find getting the constraints correctly configured painful.

The trick with stack views and multiple subviews, IMHO, is to ensure that the 
subviews correctly constrain their height.
You may also need to constrain the bottom of the last subview to the bottom of 
the stackview, depending on how you want things to lay out.

For scrolling I use an NSStackView subclass 
(https://github.com/mugginsoft/TSStackView) that includes the following to 
embed it in a scroll view.
Looks like I had to use a flipped NSClipView to get things to work out.

The subclass is getting on a bit so parts of it may be redundant if you are 
targeting the more recent versions of MacOS.

#pragma mark -
#pragma mark Embedding
- (NSScrollView *)scrollViewContainer
{
NSScrollView *scrollView = nil;

if (self.scrollViewAllocated) {
scrollView = [self enclosingScrollView];
}
else {
self.scrollViewAllocated = YES;

// allocate scroll view
scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 
100)];
scrollView.translatesAutoresizingMaskIntoConstraints = NO;

// allocate flipped clip view
TSClipView *clipView = [[TSClipView alloc] 
initWithFrame:scrollView.contentView.frame];
scrollView.contentView = clipView;
NSAssert(scrollView.contentView.isFlipped, @"ScrollView contenView must 
be flipped? Use TSClipView");

// configure the scrollview
scrollView.borderType = NSNoBorder;
scrollView.hasHorizontalScroller = YES;
scrollView.hasVerticalScroller = YES;
scrollView.autohidesScrollers = YES;

// stackview is the document
scrollView.documentView = self;

// constrain stackview to match dimension of scrollview
NSDictionary *viewsDict = NSDictionaryOfVariableBindings(self);
NSString *vfl = nil;
if (self.orientation == NSUserInterfaceLayoutOrientationVertical) {
vfl = @"H:|-0-[self]-0-|";
} else {
vfl = @"V:|-0-[self]-0-|";
}
self.stackViewConstraints = [NSLayoutConstraint 
constraintsWithVisualFormat:vfl options:0 metrics:nil views:viewsDict];

[scrollView addConstraints:self.stackViewConstraints];
}

return scrollView;
}

@interface TSClipView : NSClipView

@end

@implementation TSClipView

- (BOOL)isFlipped
{
return YES;
}
@end

HTH

Jonathan


___

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


NSPredicateEditor query

2016-12-14 Thread Jonathan Mitchell
I have an NSPredicateEditor configured to generate my queries.

I have two questions:

1. I want my users to be able to construct queries from a simple initial 
predicate.
Ideally I would like the initial predicate to operate on a single key path and 
look something like:

@"(self.fullName CONTAINS[cd] '')”

However I would also like the composite predicate row to be visible initially - 
This is the row that says “”Any / All of the following are true”;
The following works but always logs Warning - unable to find template matching 
predicate 1 == 1

@"(self.fullName CONTAINS[cd] '') AND (1 == 1)”

Is there a workaround for this?

2. The second query is connected.

I would also like to offer the ability to add additional composite predicate 
operators (Any/All).
The default UI doesn’t seem to implement this.

Is the solution simply to implement an action that takes the current predicate 
format, append an “AND ()” statement and regenerate the predicate?


Thanks

J
___

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: Using floating point instructions

2016-12-06 Thread Jonathan Mitchell

> On 6 Dec 2016, at 15:27, G 3  wrote:
> 
> Is there a way to fix this problem?
> 
Have you tried lowering the release build optimisation level to match the level 
used for debug build?.
It might get you on the right track.

J


___

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: Substituting instance of cell subclass for instance of superclass

2016-11-12 Thread Jonathan Mitchell

> On 12 Nov 2016, at 01:34, James Walker  wrote:
> 
> However, the new cell has failed to copy much of the state of the old one.  
> Things like title, font, target, action, bezelStyle...  I can manually copy 
> anything that I notice is missing, but I'm just wondering why the keyed 
> archiver approach here doesn't work.

It might be that NSButton archives the missing properties and applies them to 
the unarchived cell during initialisation.


___

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: Programmatically Clear Dirty NSDocument

2016-11-07 Thread Jonathan Mitchell

> On 7 Nov 2016, at 18:46, Richard Charles  wrote:
> 
> NSChangeUndone

try NSChangeCleared



___

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: iOS: Preventing a singleton from being deallocated when the app is in the background.

2016-10-19 Thread Jonathan Mitchell

> On 19 Oct 2016, at 22:14, Jens Alfke  wrote:

>  So that’s not what the problem is.
> 
It may be that the a separate instance of the singleton is getting created via 
the normal alloc - init sequence outside of the normal singleton accessor.
That should be trivial to check for.
___

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: PDFKit on 10.12

2016-10-05 Thread Jonathan Mitchell

> On 5 Oct 2016, at 07:52, Antonio Nunes  wrote:
> 
> On 04 Oct 2016, at 14:26, Jonathan Mitchell  wrote:
>> 
>> PDFKit seems a bit disturbed on Sierra.
>> The 10.12 beta 3 seems to improve things but there are still some rendering 
>> stutters etc.
> 
> 1. Why are you referring to a beta, when 10.12 has been out for weeks now?

Oops. that should have been 10.12.1 Beta (16B2338c)..

> Whatever is going on with PDFKit, it’s not good.


I agree with that.

PDFKit is long in the tooth and the documentation is a bit patchy.
However there is no way I can just write it off.

My solution involves assembling multipage PDFs from templates that incorporate 
a static base PDF over which I write text derived from my object model.
The composed PDF is then viewed, printed or exported.
On 10.9 to 10.11 peace reigns.

The 10.12 issues are rather unpredictable.
Some documents render fine others don’t.
Obviously this makes tracking down the source of the issues tough.
It also makes it difficult to come up with meaningfully directed bug reports to 
send back in to bugreporter.apple.com.

It would be helpful if someone from the PDFKit development team would chip in 
with insight into how the kit has changed in 10.12.

If not I might need to go down the route of a TSI.

Jonathan


___

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

PDFKit on 10.12

2016-10-04 Thread Jonathan Mitchell
PDFKit seems a bit disturbed on Sierra.
The 10.12 beta 3 seems to improve things but there are still some rendering 
stutters etc.

Has PDFKit been reworked - there doesn’t seem to be any mention of it in the 
release notes?
If so it might be a question of waiting for the internal gremlins to be hunted 
down rather than me wasting too much time on this.

Before 10.12 PDFPage -(void)drawWithBox:(PDFDisplayBox)box was called.

In 10.12 PDFPage -(void)drawWithBox:(PDFDisplayBox)box 
toContext:(CGContextRef)context was defined.

However, on 10.12.0 when printing NSPrintThumbnailView calls 
drawWithBox:(PDFDisplayBox)box inContext:(CGContextRef)context not toContext:.
My only solution here has been to override the private  PDFPage 
-(void)drawWithBox:(PDFDisplayBox)box inContext:(CGContextRef)context

In addition screen rendering seems to be suffering.
Rendering now has to target the CGContextRef given in PDFPage 
drawWithBox:toContext:

I render additional text onto the PDF using NSLayoutManager using a flipped 
NSGraphicsContext.

Pre 10.12 this worked fine. Now it is flakey - often I just get a PDFPage rect 
filled with red (printing seems okay).
Perhaps I am not handling the context correctly.

It would seem that the actual generation is now called on a background thread 
and that [NSGraphicsContext currentContext] can be nil.
I try to deal with this but all is still not quite what it was.

- (void)drawWithBox:(PDFDisplayBox)box inContext:(CGContextRef)context
{
[super drawWithBox:box inContext:context];
   
  BOOL hasInitialNSGraphicsContext = NO;

if ([NSGraphicsContext currentContext]) {
[NSGraphicsContext saveGraphicsState];
hasInitialNSGraphicsContext = YES;
}
else {
CGContextSaveGState(context);
}

// life is much easier if we use a flipped co-ordinate system.
// NSLayoutManager expects a flipped NSGraphicsContext to be present.
NSGraphicsContext *flippedGC = [NSGraphicsContext 
graphicsContextWithGraphicsPort:context flipped:YES];
[NSGraphicsContext setCurrentContext:flippedGC];

// define the flip transform
NSAffineTransform* xform = [NSAffineTransform transform];
[xform translateXBy:0.0 yBy:self.mediaBoxRect.size.height];
[xform scaleXBy:1.0 yBy:-1.0];
[xform concat];

// draw all map items
… do my drawing here

if (hasInitialNSGraphicsContext) {
[NSGraphicsContext restoreGraphicsState];
}
else {
CGContextRestoreGState(context);
}

}

Jonathan
___

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: Mystery Threads

2016-09-30 Thread Jonathan Mitchell

> On 30 Sep 2016, at 10:57, Gerriet M. Denkmann  wrote:
> 
> 
> 
> But I just cannot see anything which forces my function to run 16 times 
> longer in the first case.
> 
> Any ideas where to look for a reason?

https://github.com/apple/swift-corelibs-libdispatch/blob/ab16f5e62859ff2f54996b8838f8304a8d125102/src/apply.c


___

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: Stupid objective-c question

2016-09-23 Thread Jonathan Mitchell

> On 23 Sep 2016, at 10:04, Quincey Morris 
>  wrote.
> 
> As previously mentioned, the safest way to do this is:
> 
>> static void* kMyContext = &kMyContext;
> 
Thats a neat trick. It’s not an initialisation that I have seen before and on 
first glance I thought it was a typo but it works.
I normally go with:

static char myContext;

However, being able to ditch the address of operator has some appeal.


___

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: Package installation on MacOS Sierra

2016-09-20 Thread Jonathan Mitchell
Sorry. This was a false alarm.
It turns out that I was anticipating a new installation into /Applications.
However I had a prior installation in username/Downloads so that got updated 
instead.

J

> On 18 Sep 2016, at 22:22, Jonathan Mitchell  wrote:
> 
> Hi
> 
> I have a MacOS package that installs into /Applications on 10.11.
> On 10.12 it appears to install into the user’s Downloads folder.
> 
> Is this change related to the new feature in MacOS 12 to encapsulate 
> downloaded apps into a read only container?
> 
> Thanks
> 
> J
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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

Package installation on MacOS Sierra

2016-09-18 Thread Jonathan Mitchell
Hi

I have a MacOS package that installs into /Applications on 10.11.
On 10.12 it appears to install into the user’s Downloads folder.

Is this change related to the new feature in MacOS 12 to encapsulate downloaded 
apps into a read only container?

Thanks

J
___

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: C callbacks with NSNotificationCenter?

2016-09-07 Thread Jonathan Mitchell

> Of course, I can't use this code in a normal C function because there are
> references to "self" and the selector thing doesn't look like it's compatible 
> to
> C. So I could just subclass AVPlayerItem and voila, everything's fine.
I forgot to say that as long as your c function is in a .m file you can create 
and manipulate Obj-C objects freely.

void testNsObjectInCfunc() {
NSString *q = @"Am I alive";
}

Self is just a pointer to an object so within your c Functions you can cast it 
to the right type and call methods etc at will.
Obj-C methods are C functions that receive self as a parameter.

Note that using the CF objects is generally more of a challenge than using 
NSObject objects.

Jonathan
___

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: C callbacks with NSNotificationCenter?

2016-09-07 Thread Jonathan Mitchell

> On 7 Sep 2016, at 17:09, Andreas Falkenhahn  wrote:
> 
> 
> Still, I'm wondering: Is it also possible to have NSNotificationCenter call
> a C function for me whenever the notification triggers? Can this somehow
> be achieved or am I forced to use full Objective C here?
> 
I would go about this by creating a singleton Obj-C object to handle all my 
notifications.
I would then register C Function pointers with this, perhaps using an 
NSMapTable or its CF equivalent to track the relationship between the incoming 
notification and the desired c function.
When the notification comes in I look up my map and call the C function.

HTH

J


___

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: Unusual Conditional Formatting

2016-09-07 Thread Jonathan Mitchell
A couple of suggestions.

> Here is what I have so far: I used a category on NSNumber to add a 
> "valueType" attribute as described at 
> http://nshipster.com/associated-objects/.
> 
> The formatter checks this and the user preference when formatting an incoming 
> value.  It sets some instance variables on itself to remember what it last 
> saw so that it can correctly default its interpretation of an entered value 
> when trying to send it back.
> 


On your associated object setter add KVO support.

- (void)setValueType:(int)valueType
{
[self willChangeValueForKey:@"valueType"];
objc_setAssociatedObject(self, @selector(valueType), @(valueType), 
OBJC_ASSOCIATION_RETAIN);
[self didChangeValueForKey:@"valueType"];
}



> The binding for the values is indirect - to the effect of "myThing.value" - 
> and if I change "myThing" but the new thing has the same numeric value, the 
> formatter does not always seem to trigger to render the value in the correct 
> format - it holds that of the previous thing.  If I change the value from 
> another control, when the bindings update the field, the formatting is 
> suddenly corrected.

The formatter will only receiver the value part of “myThing.value”.
It may well be that the formatter doesn’t re-format because the actual value 
doesn’t change - formatting may be an expensive operation.
In this case you may want to reformat so:

1.  consider Manual triggering of reformat if valueType changes.
2. Try overriding NSFormatter -stringForObjectValue: - that should give you a 
low enough foothold into the rendering.

HTH

J


___

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: Emailing from a daemon process

2016-07-07 Thread Jonathan Mitchell

> On 7 Jul 2016, at 17:13, Carl Hoefs  wrote:
> 
> I have a daemon app built on Foundation (aka "command line tool") running in 
> the background and I need it to issue a textual email on certain conditions. 
> 
> The solutions for emailing that I've been able to find (NSWorkspace, 
> NSSharingService, LSOpenCFURLRef) all involve launching an email client like 
> Mail.app, which is inappropriate for a backgraound daemon process.
> 
> Is there a way to fire off a simple email from an ObjC Foundation-only app 
> running in the background on OS X 10.10.5 (not Server)? I'm told that ages 
> ago there was a handly class named NSMailDelivery, but it's long gone...


Not sure if this will pass muster. It seems reasonably alive in some forks.

https://github.com/MailCore/MailCore

It is a framework though.

J



___

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

NSTextView pagination

2016-07-07 Thread Jonathan Mitchell
Is there a recommended way to change the content of an NSTextView subclass 
during an NSPrintOperation preview?
My subclass needs to adjust its content depending on the NSPrintInfo page 
orientation.
Drawing into the margin with NSView -drawPageBorderWithSize: is not an 
appropriate solution in this case.

I have tried manipulating the views attributed string content in
- (BOOL)knowsPageRange:(NSRangePointer)range
but this logs CG warnings and can behave unpredictably - presumably because the 
content is getting manipulated at an inappropriate point.
It also doesn’t produce the correct paginated output.

Any ideas?

I could supply a new view that would correspond to the new page orientation (if 
I could get an appropriate   notification) but NSPrintOperation’s -view is 
readonly.

Thanks

Jonathan



___

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: NSArrayController - error inserting object at arranged object index N

2016-06-24 Thread Jonathan Mitchell

> On 23 Jun 2016, at 23:03, Quincey Morris 
>  wrote:
> 
> On Jun 23, 2016, at 13:39 , Jonathan Mitchell  <mailto:li...@mugginsoft.com>> wrote:
>> 
>> Do you mean something like this?
>> NSMutableArray *proxy = [NSArrayController 
>> mutableArrayValueForKey:@"content"];
> 
> That wasn’t what I had in mind. I meant that you would make the array a 
> property of a real model object, and update *that* property, without 
> referring to the array controller directly at all. If you do a KVO compliant 
> update under those circumstances, the array controller will get a KVO 
> notification and update its internal state automatically. You shouldn’t need 
> to re-filter manually.
> 
Okay. I see what you mean now.
Yes - I think that would work.

The downside would be having to implement the compliant accessor methods in the 
real model object (in my case the array is a constructed property of an 
NSViewController subclass which obtains its array data from a non native Obj-C 
model)
This would be beneficial if the array property was also being observed 
externally.

My usage case scenario is mainly bindings based and so the NSArrayController 
provides an effective and concise means of providing a KVO compliant to-many 
property to the likes of NSTableView etc. I think this is the essence point you 
were making about using NSArrayControllers in code previously. I find them 
hugely useful for UI related bindings. Outside of that their utility is less 
obvious.

Thanks for taking the time and effort to respond to this - i definitely 
improved my knowledge by thinking about your points.
KVO compliance for to-many properties was always something I was a bit wooly 
about and I suspect that many others will be too,
IMHO getting to grips with this is one of the most difficult aspects of AppKit.

J
___

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: unnamed function586 $$ AMDRadeon X4000GLDriver

2016-06-23 Thread Jonathan Mitchell

> On 23 Jun 2016, at 21:39, Ken Thomases  wrote:
> 
> O
> 
> Are there any logs generated from the above call (other than your app's crash 
> log)?  Browse around within Console.app's log list to see.
Had a poke around but nothing significant that I can see.
> 
>>   CIFilter *colorFilter = [CIFilter filterWithName:@"CIColorControls"];
>>   [colorFilter setDefaults];
>>   [colorFilter setValue:image forKey:kCIInputImageKey];
>>   [colorFilter setValue:[NSNumber numberWithFloat:saturationValue]  
>> forKey:kCIInputSaturationKey];
>>   [colorFilter setValue:[NSNumber numberWithFloat:brightnessValue] 
>> forKey:kCIInputBrightnessKey];
>>   [colorFilter setValue:[NSNumber numberWithFloat:contrastValue] 
>> forKey:kCIInputContrastKey];
> 
> Any chance these values are out of valid range?
No. Everything looks sane. The range of arguments passed into the method is 
very small so there isn’t much variation.
> 
>> 
>>   CIImage *filterImage = [colorFilter valueForKey:kCIOutputImageKey];
>> 
>>   [filterImage drawAtPoint:NSZeroPoint // << this is the call site that 
>> eventually aborts
>>   fromRect:bounds
>>  operation:NSCompositeCopy
>>   fraction:alphaValue]; 
> 
> What does it mean to use a potentially non-1.0 fraction for a copy to an 
> as-yet-uninitialized image?  No idea if that might contribute to the problem. 
>  Maybe clearing the image to some background color first would help.
> 
> Also, have you considered using -[CIContext createCGImage:fromRect:] to 
> create the image instead of drawing into a focus-locked NSImage?  To get an 
> NSImage from the CGImage, you can use [[NSImage alloc] initWithCGImage:… 
> size:NSZeroSize].

Thanks for the suggestions I will give them a go.

J


___

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: NSArrayController - error inserting object at arranged object index N

2016-06-23 Thread Jonathan Mitchell

> On 23 Jun 2016, at 17:51, Quincey Morris 
>  wrote:
> 
> 
>> My workaround was to set controller.clearsFilterPredicateOnInsertion == YES 
>> and reset the filterPredicate following -addObject:
>> 
>> It might be possible to subclass NSArrayController …
> 
> There’s no need to work around at all. The correct, straightforward solution 
> is to update the content array (i.e. the unfiltered objects being managed via 
> the array controller) directly in a KVO compliant manner, using 
> ‘mutableArrayValueForKey:’.
> 

Do you mean something like this?

NSMutableArray *proxy = [NSArrayController mutableArrayValueForKey:@"content"];
[proxy addObject:object];
[proxy filterUsingPredicate:self.filterPredicate];

This does work but is very slow even with a small collection (the subclass 
returned is an instance of NSKeyValueSlowMutableArray).
Perhaps NSArrayController does not override all the required KVC  methods for 
the content key?

[self.submissionsArrayController addObject:object];
self.submissionsArrayController.filterPredicate = self.filterPredicate;

The above amounts to the same thing and seems much more performant.

I suppose I could make my NSViewController class KVC compliant for the content 
array but that seems overkill in this case.

Thanks

J


___

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

unnamed function586 $$ AMDRadeon X4000GLDriver

2016-06-23 Thread Jonathan Mitchell
On a rare occasion I encounter the following abort while rendering an image in 
an NSImage category.
The method (shown below) gets called frequently to render resources as 
grayscale.
Looks like the driver has issues but beyond that I am stuck.
Any ideas?

Thread 1 (main-thread)
#0  0x7fff9972ef06 in __pthread_kill ()
#1  0x00010183642d in pthread_kill ()
#2  0x7fff8d3426e7 in abort ()
#3  0x7fff9b3ace5c in gpusGenerateCrashLog ()
#4  0x0001127259dc in 
___lldb_unnamed_function586$$AMDRadeonX4000GLDriver ()
#5  0x7fff9b3ae204 in gpusSubmitDataBuffers ()
#6  0x000112762813 in 
___lldb_unnamed_function1027$$AMDRadeonX4000GLDriver ()
#7  0x000112778d37 in 
___lldb_unnamed_function1175$$AMDRadeonX4000GLDriver ()
#8  0x7fff91a1f22f in glReadPixels_Exec ()
#9  0x7fff91f0ceb9 in CI::GLContext::readback_bitmap(CI::Bitmap*, 
CI::swizzle_info) ()
#10 0x7fff91dd43d9 in CI::image_get_cgimage(CI::Context*, CI::Image*, 
CGRect, CGColorSpace*, CI::PixelFormat) ()
#11 0x7fff91db606a in -[CIContext 
createCGImage:fromRect:format:colorSpace:] ()
#12 0x7fff91db476e in -[CIContext drawImage:inRect:fromRect:] ()
#13 0x7fff9ba09801 in -[CIImage(NSAppKitAdditions) 
drawInRect:fromRect:operation:fraction:] ()
#14 0x7fff9ba09914 in -[CIImage(NSAppKitAdditions) 
drawAtPoint:fromRect:operation:fraction:] ()
#15 0x000100028f47 in -[NSImage(Test) 
bp_grayscaleImageWithAlphaValue:saturationValue:brightnessValue:contrastValue:] 
at 

NSImage category:

- (NSImage *)bp_grayscaleImageWithAlphaValue:(CGFloat)alphaValue
  saturationValue:(CGFloat)saturationValue
  brightnessValue:(CGFloat)brightnessValue
contrastValue:(CGFloat)contrastValue
{
NSSize size = [self size];
NSRect bounds = { NSZeroPoint, size };
NSImage *tintedImage = [[NSImage alloc] initWithSize:size];

[tintedImage lockFocus];

CIImage *image = [CIImage imageWithData:[self TIFFRepresentation]];
   
CIFilter *colorFilter = [CIFilter filterWithName:@"CIColorControls"];
[colorFilter setDefaults];
[colorFilter setValue:image forKey:kCIInputImageKey];
[colorFilter setValue:[NSNumber numberWithFloat:saturationValue]  
forKey:kCIInputSaturationKey];
[colorFilter setValue:[NSNumber numberWithFloat:brightnessValue] 
forKey:kCIInputBrightnessKey];
[colorFilter setValue:[NSNumber numberWithFloat:contrastValue] 
forKey:kCIInputContrastKey];

CIImage *filterImage = [colorFilter valueForKey:kCIOutputImageKey];

[filterImage drawAtPoint:NSZeroPoint // << this is the call site that 
eventually aborts
fromRect:bounds
   operation:NSCompositeCopy
fraction:alphaValue]; 

[tintedImage unlockFocus];

return tintedImage;
}


___

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: NSArrayController - error inserting object at arranged object index N

2016-06-23 Thread Jonathan Mitchell

> On 23 Jun 2016, at 14:27, Jonathan Mitchell  wrote:
> 
> The following raises with NSInternalInconsistencyException when :
> 
> 1. an NSArrayController filter is in place, 
> 2. controller.clearsFilterPredicateOnInsertion = NO
> 3. added content object is rejected by the filter.
> 
> Is this behaviour by design?
> 

It would seem there is some intention here according to the header:

- (void)insertObject:(id)object atArrangedObjectIndex:(NSUInteger)index;// 
inserts into the content objects and the arranged objects (as specified by 
index in the arranged objects) - will raise an exception if the object does not 
match all filters currently applied

-addObject: obviously calls  - insertObject: atArrangedObjectIndex: (the 
exception stack trace agrees)

The logic of this is a bit puzzling though as setting 
controller.clearsFilterPredicateOnInsertion == NO seems to designed to fail.
What’s the point of a filter that raises when it filters?

It is possible to catch the exception raised from -addObject: and proceed.
In some cases this may be acceptable but the object that was to be added won’t 
appear in the NSArrayController content collection which may be an issue if the 
filterPredicate is subsequently changed.

My workaround was to set controller.clearsFilterPredicateOnInsertion == YES and 
reset the filterPredicate following -addObject:

It might be possible to subclass NSArrayController but it might turn into a bit 
of a rabbit hole.

> #import “AppDelegate.h"
> 
> @interface AppDelegate ()
> 
> @property (weak) IBOutlet NSWindow *window;
> @end
> 
> @implementation AppDelegate
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 
>NSArrayController *controller = [[NSArrayController alloc] 
> initWithContent:@[@"foo"].mutableCopy];
>controller.filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id  
> _Nonnull evaluatedObject, NSDictionary * _Nullable bindings) {
>return [evaluatedObject isKindOfClass:[NSString class]];
>}];
>controller.clearsFilterPredicateOnInsertion = NO;
>[controller addObject:@"bar"];
>[controller addObject:@1]; // raises
> }
> @end
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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

NSArrayController - error inserting object at arranged object index N

2016-06-23 Thread Jonathan Mitchell
The following raises with NSInternalInconsistencyException when :

1. an NSArrayController filter is in place, 
2. controller.clearsFilterPredicateOnInsertion = NO
3. added content object is rejected by the filter.

Is this behaviour by design?

#import “AppDelegate.h"

@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

NSArrayController *controller = [[NSArrayController alloc] 
initWithContent:@[@"foo"].mutableCopy];
controller.filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id  
_Nonnull evaluatedObject, NSDictionary * _Nullable bindings) {
return [evaluatedObject isKindOfClass:[NSString class]];
}];
controller.clearsFilterPredicateOnInsertion = NO;
[controller addObject:@"bar"];
[controller addObject:@1]; // raises
}
@end
___

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: TableView crash with Delegate

2016-06-14 Thread Jonathan Mitchell

> On 14 Jun 2016, at 12:26, Gerriet M. Denkmann  wrote:
> 
> 
> But no problem, as long one keeps in mind (as you recommended) that 
> awakeFromNib “can get called many times”.
> 
You may be experiencing this, as described in docs for view based table views:

NSTableView - (__kindofNSView 

 *)makeViewWithIdentifier:(NSString 

 *)identifier
 owner:(id)owner

This method is usually called by the delegate in 
tableView:viewForTableColumn:row: 
,
 but it can also be overridden to provide custom views for the identifier. Note 
that awakeFromNib 

 is called each time this method is called, which means that awakeFromNib is 
also called on owner, even though the owner is already awake.

This has thrown me for loop in the past - especially when the above note was 
only in the headers.

J

> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.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: iOS - the joy of observers and NSInternalInconsistancyException for KVO

2016-05-19 Thread Jonathan Mitchell

> On 19 May 2016, at 17:55, Jonathan Mitchell  wrote:
> 
> That way the observed object can get deallocated before the observer.
Should say 
That way the observed object cannot get deallocated before the observer.

J

___

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: iOS - the joy of observers and NSInternalInconsistancyException for KVO

2016-05-19 Thread Jonathan Mitchell

> 
> Is there any safer KVO technique to prevent or detect the dreaded "An 
> instance of xx was deallocated while key value observers were still 
> registered with it"?
> 
I have a ton of observers in NSViewController subclasses.
Generally when I use an observer I make 100% sure I have a strong property 
reference (held by the NSViewController instance) to the observed object.
That way I know that the observed object will live as long as the 
NSViewController.
That way the observed object can get deallocated before the observer.
I then always make sure to remove my observers in NSViewController -dealloc.

If you want the observer to stop observing on command then use a delegate 
pattern or a notification to explicitly request that.

It is a futile task IMHO to dig into the KVO machinery and try and second guess 
it.

Jonathan



___

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: Set font on NSTextView that uses bindings?

2016-05-19 Thread Jonathan Mitchell

> On 19 May 2016, at 04:47, Rick Mann  wrote:
> 
> I seem to be unable to set the font used in an NSTextView that uses bindings 
> to set the text content. The property it's bound to creates a plain NSString 
> (no attributes).
> 
> I've tried setting the font, setting the typing attributes, setting the font 
> on textStorage, all to no avail.
> 
> Any ideas? Thanks.
> 
Try setting the text field to allow rich text.
Or use the attributedString binding to bind your string and use a value 
transformer to add in the required text attributes.
I find that I can get a lot more flexibility from my bindings by building them 
in code.

I use the block based transformer shown below to build ad hoc transformers.
You could do the same thing to do you attributed string conversion.
The beauty about using this block approach is that you can capture any other 
dependencies need for the transformation.
This can great increase the bindings scope.

eg:

BPBlockValueTransformer *blockValueTransformer = [BPBlockValueTransformer 
valueTransformerWithBlock:^id(NSNumber *gender)  {
return [gender integerValue] == BPGenderUnknown ? @NO : @YES;
}];
[self.genderPromptImageView bind:NSHiddenBinding toObject:self 
withKeyPath:@"employee.gender"
 options:@{NSValueTransformerBindingOption: 
blockValueTransformer}];

The transformer class:
=

@interface BPBlockValueTransformer : NSValueTransformer

+ (instancetype)valueTransformerWithBlock:(id(^)(id value))block;
@property (nonatomic,strong) id (^transform)(id value);

@end

@implementation BPBlockValueTransformer

+ (instancetype)valueTransformerWithBlock:(id(^)(id value))block
{
BPBlockValueTransformer *transformer = [[self alloc] init];
transformer.transform = block;

return transformer;
}

+ (Class)transformedValueClass
{
return [NSObject class];
}

- (id)transformedValue:(id)value
{
return self.transform(value);
}

@end

J


___

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: Codesigning pain, god it hurts!

2016-05-18 Thread Jonathan Mitchell

> On 18 May 2016, at 04:29, Quincey Morris 
>  wrote:
> 
> Yes, it’s awful.
> 
I agree. Screwing it up is easy.
I use the following project archive scheme post action script to run a 
Gatekeeper security check on archive builds.
This provides decent confirmation that all is well.

 if [ "${CONFIGURATION}" == "Release" ]; then

# xcode post build build/archive cannot directly return or log error 
conditions but we can:
# 1. put up a dialog
# 2. post a notification
# 3. say someting
# 4. write to the syslog
# 5. write to a file and open the file

# Execute a project folder script.
# Note that Git checkout may mutate the execute permissions
#${PROJECT_DIR}/${PROJECT_NAME}/script.sh

# audible feedback
say "Processing post action script for ${PROJECT_NAME}"

# show avaiable vars - helps a lot when debugging
SHOW_EXPORTS=0
if [ $SHOW_EXPORTS -eq 1 ]; then
OUT_FILE="${HOME}/Desktop/${PROJECT_NAME}-xcode-post-action-exports.txt"
rm "${OUT_FILE}"
export -p > "${OUT_FILE}"
open "${OUT_FILE}"
fi

# make archived app path
APP_PATH="${ARCHIVE_PRODUCTS_PATH}/Applications/${EXECUTABLE_PATH}"

# update syslog
syslog -s -l Error "xcode-post-action APP_PATH = ${APP_PATH}"

# do Gatekeeper security check
spctl -v --assess --type execute "${APP_PATH}"
SPCTL_OUT=$?

# output result
syslog -s -l Error "xcode-post-action spctl result code = $SPCTL_OUT"
if [ $SPCTL_OUT -eq 0 ]; then
say "Gatekeeper security check passed for ${PROJECT_NAME}"
osascript -e 'display notification "Gatekeeper security check passed" 
with title "Archive Security Check"'
else
say "Gatekeeper security check faile for ${PROJECT_NAME}"
osascript -e 'tell app "Xcode" to display dialog "Security failure: 
spctl rejected app and Gatekeeper will too." buttons {"Okay"} default button 
"Okay"'
fi
fi
___

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: discontiguous bounds ?

2016-05-09 Thread Jonathan Mitchell

> On 9 May 2016, at 08:59, Graham Cox  wrote:
> 
> I’ve done this, based on that code. Yes, it was a bit buggy, but I got it to 
> work. The app it’s a part of still works when compiled with the latest tools 
> and SDK. But yes, you need two separate table views to do this.
> 
I have done something similar - using a separate table view to create a non 
scrolling total row at the bottom of a table view.
NSStackView makes a suitable container for sticking this sort of thing together.
In this case I can bind the table column widths together.

I load the table view form a nib but put the view hierarchy together in code.
In particular I clone the initial NSTableView using 
NSKeyedArchiver/NSKeyedUnarchiver so that I don’t have to try and maintain two 
duplicate NSTableViews in the nib.

J
___

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: NSTableView is messaging zombie delegate

2016-05-06 Thread Jonathan Mitchell

> On 6 May 2016, at 21:03, Matthew LeRoy  wrote:
> 
> Hello,
> 
> I'm having an issue where an NSTableView appears to be messaging its delegate 
> after the delegate has been deallocated, causing an EXC_BAD_ACCESS crash. It 
> doesn't always happen, but it happens regularly. My understanding is that 
> NSTableView's delegate is a zeroing weak reference, and so I'm stumped as to 
> how/why it is sending a message to the delegate after the delegate has been 
> deallocated.
Its a weak reference, not a zeroing weak reference.
So when your delegate disappears the NSTableView delegate still points to it 
unless you manually intervene.
You only get the zeroing weak behaviour when you build with arc.
I don’t know if AppKit is built with arc enabled or not but the NSTableView 
delegate is declared as a getter/setter pair rather than a weak property.

This catches us out because we are used to seeing the arc zeroing behaviour in 
our own arc enabled code.
We forget that some of the objects we interact with don’t act quite the same. 

WebView delegates for instance behave in the same way.
I generally set my table and web view delegates to nil in the NSViewController 
dealloc - this precaution seems to pay off in terms of increased stability when 
view hierarchies get torn down.
 
J
___

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: Yosemite NSCollectionView appropriate for spreadsheet-like view?

2016-05-03 Thread Jonathan Mitchell

> On 1 May 2016, at 17:06, thatsanicehatyouh...@me.com wrote:
> 
>  My guess is that since the basic unit here is NSTableRowView, all of the 
> columns are loaded into each row view whether they are on the screen or not.
> 
View based table views recycle their views and I have found them to be very 
flexible in use.
There is a lot of functionality in there.
If the default behaviour of NSTableRowView is causing an issue them you can 
always subclass this and provide it to the NSTableView via. 

- (NSTableRowView *)tableView:(NSTableView *)tableView 
rowViewForRow:(NSInteger)row 

J


___

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: Thoughts on autolayout

2016-04-21 Thread Jonathan Mitchell

> On 21 Apr 2016, at 11:48, Stephane Sudre  wrote:
> 
> 
> - you still have to use intermediary subviews to deal with complex cases.
NSLayoutGuide can help out here
https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSLayoutGuide_ClassReference/index.html#//apple_ref/doc/uid/TP40016078-CH1

J



___

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: Thoughts on autolayout

2016-04-21 Thread Jonathan Mitchell

> On 21 Apr 2016, at 08:12, Quincey Morris 
>  wrote:
> 
> I think I’d much rather have a scheme where you can’t drag or resize UI 
> elements at all, but you would essentially drag on the constraints (or on 
> attributes that uniquely represent constraints that can be consistently 
> altered by dragging) instead.
Not quite the same but Xcode used to have an option, I forget the terminology 
used in the IB menu, to exercise a view’s/window’s constraints within the edit 
as the view.window was resized. So you could resize the view/window and check 
that AL was playing along as you had hoped. I agree that a more dynamic editor 
would be a huge boon.

> 
> 5. The second-biggest autolayout-related design flaw is the idea that IB 
> provides invisible default constraints for any object that doesn’t have any 
> explicit constraints. This is a consequence of the drag-it-till-it-hurts 
> problem (#4), because it initially allows you to *seem* to place a lot of 
> stuff by dragging the stuff. However, as soon as you need to use explicit 
> constraints, you end up with a horrible hodgepodge of implicit and explicit 
> constraints.
The implicit constraint assassin is a continual source of problems. At least 
with the constraint UI editor in Xcode we can at least get some insight into 
what constraints actually turn up to the layout party

> What’s much more annoying is that the contents of a stack view are also a 
> different editing context from the sub-hierarchy containing the stack view, 
> which means a hierarchy with stack views is a mixture of explicit and 
> implicit constraints. On top of that, stack views have constraint behavior 
> that’s specified in the view inspector, not as constraints, which makes them 
> simultaneously more and less confusing. Although stack views are great in 
> other respects, they turn the editing hierarchy into a horrible mess.
I agree that stack views are supremely useful however they are a usability mess 
from a development point of view in IB.
Personally I have a subclassed NSStackView and construct all of my view 
hierarchies in code.

The biggest single issue I have with AL is that it is a  development time hog.
WPF layout is way more straightforward - I have ported a complex WPF app to OS 
X and the effort I have had to put into AL is substantial.

I think that a XAML like approach provides a more modern approach to UI layout 
that what is currently offered by IB.
Why can’y we have a modern public extensible XIB format that can be edited 
directly or via an IB like tool?
I am not sure just how AL constraints could be easily expressed in such an 
approach but the new anchor API’s might help out a lot.

J
___

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 find the file (url) that was double-clicked to open my Cocoa Application?

2016-03-30 Thread Jonathan Mitchell

> On 30 Mar 2016, at 06:47, Motti Shneor  wrote:
> 
> Hi Everyone.  My issue is tied to a very specific scenario, but still a Cocoa 
> question.
> 
> I write a custom Installer Plugin (code bundle), used to customize our 
> installations (done via Mac Installer). The plugin bundle is loaded at some 
> arbitrary time by the Installer App. It needs access to the actual package 
> file on disk.
Can the required package resources not be copied as part of the installation?
Could the actual package not have been deleted by the time the bundle runs?

> 
> The Installer application logs (in /var/log/install.log) its actions and near 
> to the start, it emits the following line:
> 
> Mar 30 07:47:54 CyberMotti Installer[19943]: Opened from: 
> /Users/motti/Documents/Projects/MyTestLogDistribution/build/MyTestLogDistribution.pkg
> 
> Which contains exactly the info I need. Furthermore - at a much later stage 
> of the installation, when the Installer runs some install-scripts I wrote, 
> the Installer supplies this information also in the first argument sent to 
> the scripts. 
Can one of the scripts not cache this path for you to consume later?

J
___

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: Xcode 7.2.1 - Apps not running on 10.8 and 10.9

2016-03-16 Thread Jonathan Mitchell

> On 16 Mar 2016, at 07:02, Quincey Morris 
>  wrote:
> 
> On Mar 7, 2016, at 09:29 , Frank Bitterlich  wrote:
>> 
>> Does anybody have a suggestion what this could be?
> 
> It sort of sounds like your main XIB or storyboard is failing to load. 
> Possibly your file is set to compile for a later version of OS X than your 
> deployment target.

In my case I had refactored which resulted in a nil nib name being sent to an 
NSViewController designated initialiser

- (nullable instancetype)initWithNibName:(nullable NSString *)nibNameOrNil 
bundle:(nullable NSBundle *)nibBundleOrNil 

On 10.10 and higher, a nil nibName can be used, and NSViewController will 
automatically attempt to load a view with the same class name. See loadView for 
more information.

On 10.9 and below sending a nil nib name causes unreliable behaviour - IIRC It 
may be that the last nib loaded gets reused.

J


___

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: Xcode 7.2.1 - Apps not running on 10.8 and 10.9

2016-03-16 Thread Jonathan Mitchell

> On 7 Mar 2016, at 17:29, Frank Bitterlich  wrote:
> 
> Hi,
> 
> I have a weird problem. When I build a Cocoa app in Xcode 7.2.1, it fails to 
> run properly on certain machines running OSX versions 10.8 and 10.9. The app 
> launches (=icon in dock), but no window shows up, and the menus are all but 
> gone (the Apple and application menu is visible in the menu bar, but nothing 
> else, and the app menu is empty.)
> 
> It happens even with the simplest apps (ie. just building the Cocoa 
> application.) Due to limited resources I have only access to one Mac where it 
> happens, but apart from having 10.9 installed, there is nothing special with 
> that machine. The very same app runs fine on other machines (El Capitan.)
> 
> -application:didFinishLaunching: is apparently never called (an NSLog() call 
> there never show up in the console.)
> 
> Searching for that problem on the web did not return a single hint.
> 
> Does anybody have a suggestion what this could be?

I have just encountered a similar issue on a 10.9 vm.
I agree with Quincey that nib loading might be at the root of it.

However a clean cocoa test app with a deployment target of 10.9 launches fine.

J


___

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: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?

2016-03-08 Thread Jonathan Mitchell
Alex

> On 8 Mar 2016, at 20:59, Alex Zavatone  wrote:
> 
> I'm browsing the Dubrovnik classes now to see the it handles returning the 
> data now and am thinking of using another Obj-C object to register itself to 
> have the data I care about sent to it.

KVO is very particular about the occurrence and sequencing of the 
willChangeValueForKey: and didChangeValueForKey: methods. Get it right and joy 
Reigns. Get it wrong and well…

It can tolerate some missing calls on the end component of a key path but a 
failure higher up a key path chain is usually fatal. Of course there are 
potential memory issues too. The objects in an observed key path need to stick 
around while the observation is live. 

In Dubrovnik I translate the managed INotifyPropertyChanging and 
INotifyPropertyChanged interface events into their KVO equivalents. I 
incorporated a simple tracking mechanism that fired out warnings if an anomaly 
in the KVO xxxChangeValueForKey: sequencing occurred.

It took a bit of time to get the kinks out of it all but in the end I have a 
system that works reliably and enables me to bind many hundreds of NSControl 
instances to properties of .Net managed classes.

So the KVO route may not be dead, just wounded. In my case to get things sweet 
I had to disable automatic KVO notifications. For regular Cocoa classes auto 
KVO is the way to go but if you need more precise control maybe not.

J

> 
> Yeah, it's getting complex, that's for sure.
> 
> 
> 
> On Mar 4, 2016, at 7:06 PM, John McCall wrote:
> 
>> 
>>> On Mar 4, 2016, at 4:03 PM, Greg Parker  wrote:
>>> 
>>> 
>>>> On Mar 4, 2016, at 2:24 PM, Jonathan Mitchell  wrote:
>>>> 
>>>> Hi Alex
>>>> 
>>>> Not sure if this will help at all as I am not 100% sure what you are doing.
>>>> In my case, using Mono, I needed to track events being raised in the Mono 
>>>> C runtime back into Obj-C space.
>>>> You need some method of defining a call back function in the target C Api 
>>>> - without that thinks would look rather bleak.
>>>> 
>>>> Basically the C Mono runtime is configured to a call static C function in 
>>>> an Obj C .m file in response to a C# managed event firing.
>>>> The static then calls a static method on an Obj-C class.
>>>> This Obj-C static uses collections to track registered events and invokes 
>>>> performSelector: on a registered Obj-C target.
>>>> See here:
>>>> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBManagedEvent.m
>>>> 
>>>> One of the arguments based in as part of the event callback is a pointer 
>>>> that is used as a a key to retrieve the target NSObject.
>>>> This is complicated by the fact that the incoming pointer represents a 
>>>> moveable memory location so there is some extra indirection too.
>>>> https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBPrimaryInstanceCache.m
>>>> 
>>>> This can get a bit complex but its all doable.
>>> 
>>> Block objects can help. clang supports block objects in plain C code 
>>> (-fblocks, I think).
>> 
>> They're just enabled by default on our platform in all language modes.
>> 
>> John.
>> 
>>> Your Objective-C code can create a block object that performs the callback 
>>> and pass it to the C code to store and call. The block object would capture 
>>> the target NSObject so you don't need the dictionary of callback targets.
>>> 
>>> 
>>> -- 
>>> Greg Parker gpar...@apple.com Runtime Wrangler
>>> 
>>> 
>>> 
>>> ___
>>> 
>>> 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/rjmccall%40apple.com
>>> 
>>> This email sent to rjmcc...@apple.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
&g

Re: Returning a string value from a c function to a Objective-C class method. Is there an approved approach?

2016-03-04 Thread Jonathan Mitchell
Hi Alex

Not sure if this will help at all as I am not 100% sure what you are doing.
In my case, using Mono, I needed to track events being raised in the Mono C 
runtime back into Obj-C space.
You need some method of defining a call back function in the target C Api - 
without that thinks would look rather bleak.

Basically the C Mono runtime is configured to a call static C function in an 
Obj C .m file in response to a C# managed event firing.
The static then calls a static method on an Obj-C class.
This Obj-C static uses collections to track registered events and invokes 
performSelector: on a registered Obj-C target.
See here:
https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBManagedEvent.m

One of the arguments based in as part of the event callback is a pointer that 
is used as a a key to retrieve the target NSObject.
This is complicated by the fact that the incoming pointer represents a moveable 
memory location so there is some extra indirection too.
https://github.com/ThesaurusSoftware/Dubrovnik/blob/master/Framework/XCode/Representations/DBPrimaryInstanceCache.m

This can get a bit complex but its all doable.

Jonathan

> On 4 Mar 2016, at 21:14, Alex Zavatone  wrote:
> 
> Great!  It certainly does… but here's where my brain breaks.
> 
> The call is originating from the C lib and within the C function.  I am not 
> calling the C function from Objective-C.
> 
> I'm looking at somehow passing this as a string (UTF-8, yep) back to an OC 
> class instance, so this implies either a callback or some reference to the OC 
> instance that that cares about the response and a means to get that message 
> to it.
> 
> If this is as simple as setting up a callback or a pointer reference, from 
> the c class to the OC instance?  Is it sane programming for the C class to 
> have more than one callback to different OC object instances?
> 
> I was thinking one for data and one for method calls for organizational 
> purposes.
> 
> Or should there be one layer that serves as a clearly defined API to create a 
> walled garden between the OC world and the C interface to the compiled C lib? 
>  
> 
> I'm working with PJSIP and PJ's docs clearly state, "we are going to crater 
> unless you do everything SIP related on the main thread."  The code that I am 
> rewriting replacing has nasty try/catch clauses and forces many operations to 
> the main thread just in case they call PJSIP operations - which clearly makes 
> for a sucky user experience and really clunky application architecture.
> 
> I'm looking to avoid that nastiness by starting from ground zero so that we 
> can wrap a solidly conceived architecture around a neatly walled off 
> interface layer to PJSIP.
> 
> 
> Would it make sense to send a notification from the C method to an 
> Objective-C object to get the value from the C class?  Then I'd need to worry 
> about storing it,  that seems clunky and too involved just to return a string.
> 
> Thank you, sir.  Loads for me to learn here.  
> 
> Alex Zavatone
> 
> 
> 
> On Mar 4, 2016, at 3:48 PM, Doug Hill wrote:
> 
>> Alex,
>> 
>> I’ve worked on a few wrapper libraries, so I have some experience with this.
>> 
>> In your Obj-C wrapper, you would need to create the NSString yourself. So, 
>> if you have a C function:
>> 
>> char* MyCFunc(void);
>> 
>> The Objective-C wrapper method would do something like:
>> 
>> - (void) myObjcMethod
>> {
>>   char* cStr = MyCFunc();
>>   NSString* objcStr = [[NSString alloc] initWithUTF8String:cStr];
>> 
>>   return objCStr;
>> }
>> 
>> Depending on the C function implementation, you might have to deal with 
>> releasing the C string in your wrapper. Also, I assume UTF-8 encoding, which 
>> may or may not be true.
>> 
>> Hopefully this helps you.
>> 
>> Doug Hill
>> 
>> 
>>> On Mar 4, 2016, at 12:07 PM, Alex Zavatone  wrote:
>>> 
>>> I'm in the middle of some fun where there is a wrapper class to a lib 
>>> that's written in C and the c function has a char string that I'd like to 
>>> return back to or somehow pass on to an Cbjective-C class.
>>> 
>>> I'm sure there is an established practice for performing this type of task, 
>>> but while I have the opportunity to do this, I'd like to start be learning 
>>> the right way to handle this operation.
>>> 
>>> I've seen really poor use of a catch all delegate for this approach, but am 
>>> pretty unsure on viable and safe methods to handle this.
>>> 
>>> Any tips to how to handle this?
>>> 
>>> Thanks in advance,
>>> 
>>> Alex Zavatone
>> 
>> 
> 
> 
> ___
> 
> 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/lists%40mugginsoft.com
> 
> This email sent to li...@mugginsoft.com


_

Re: CG Error with popovers - known issue?

2015-12-30 Thread Jonathan Mitchell
HI Graham

I am seeing the exact same issue with NSPopover on 10.11.
The stack trace is identical.
Did you manage to make any further progress with this?

Thanks

Jonathan

> On 9 Dec 2015, at 22:42, Graham Cox  wrote:
> 
> I’m getting this message logged when I show a popover sometimes:
> 
> Dec 10 09:33:47  ##myApp##[4602] : Error: this application, or a 
> library it uses, has passed an invalid numeric value (NaN, or not-a-number) 
> to CoreGraphics API and this value is being ignored.Please fix this problem.
> 
> 
> Stack trace:
> 
> #00x7fff946b2073 in CGPostError ()
> #10x7fff9468c55e in CGFloatValidateWithLog ()
> #20x7fff943b4a26 in CGPathAddLineToPoint ()
> #30x7fff925600d7 in _CUICreateNewPopoverPathWithArrowPosition ()
> #40x7fff925605cc in _CUICreateNewPopoverPath ()
> #50x7fff9258d792 in CUICoreThemeRenderer::DrawPopover(CUIDescriptor 
> const*) ()
> #60x7fff9251d065 in CUIRenderer::Draw(CGRect, CGContext*, 
> __CFDictionary const*, __CFDictionary const**) ()
> #70x7fff9251f9c4 in CUIDraw ()
> #80x7fff8d04156d in __44-[NSAppearance 
> _drawInRect:context:options:]_block_invoke ()
> #90x7fff8cfb5af3 in -[NSCompositeAppearance _callCoreUIWithBlock:] ()
> #10   0x7fff8d041526 in -[NSAppearance _drawInRect:context:options:] ()
> #11   0x7fff8d943e93 in -[NSPopoverFrame _drawFrameMaskInRect:] ()
> #12   0x7fff8d943b06 in -[NSPopoverFrame _frameMask] ()
> #13   0x7fff8d226dcd in -[NSPopoverFrame shapeWindow] ()
> #14   0x7fff8d227e3d in -[NSPopoverFrame 
> tileAndSetWindowShape:updateContentView:] ()
> #15   0x7fff8d2279b8 in -[NSPopover _updateAnchorPointForFrame:reshape:] 
> ()
> #16   0x7fff8d227855 in -[_NSPopoverWindow setFrame:display:] ()
> #17   0x7fff8d2251e1 in -[NSPopover _makePopoverWindowIfNeeded] ()
> #18   0x7fff8d224ae5 in -[NSPopover 
> showRelativeToRect:ofView:preferredEdge:] ()
> 
> 
> As far as I can see the parameters I’m passing to 
> -showRelativeToRect:ofView:preferredEdge: are sane and sensible:
> 
> _cmd  SEL "showRelativeToRect:ofView:preferredEdge:"
> positioningRect   NSRect  (origin = (x = 20, y = 74), size = (width = 55, 
> height = 19))   
> positioningView   NSView *0x60334fa0
> preferredEdge NSRectEdge  2
> 
> Anyone else seen this? Seems to be arsing deep in the internals of drawing 
> the popover frame.
> 
> It’s not happening on all popovers, but frequently enough that it’s causing 
> me concern.
> 
> —Graham
> 
> 
> 
> ___
> 
> 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/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.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: applicationSupportDirectory access for admin and standard users

2015-12-22 Thread Jonathan Mitchell


> On 22 Dec 2015, at 12:21, Roland King  wrote:
> 
> 
>> On 22 Dec 2015, at 20:11, Jonathan Mitchell  wrote:
>> 
>> 
>>> On 21 Dec 2015, at 22:24, Sean McBride  wrote:
>>> 
>>> On Mon, 21 Dec 2015 22:16:39 +, Jonathan Mitchell said:
>>> 
>>>> My app seems to be having trouble reading and writing to the
>>>> applicationSupportDirectory.
>> 
>> 
>> 1. My preferences file does not get updated on first launch. This causes 
>> trouble further on.
>> I can probably insert a try/catch block in  -applicationDidFinishLaunching: 
>> but the main issue is the write failure of the preferences file.
>> 
> 
> What’s trying to write the preferences file and how is that related to the 
> applicationSupportDirectory?
Likely none. I probably misdiagnosed the issue initially.
When I say write the user preferences what I mean is that the preferences I 
initially establish for my app do not get ultimately persisted by the defaults 
system.

> Are you trying to hand-write a preferences file instead of setting the user 
> defaults and synchronize them?
No. I use the standard approach.

> The connection between the preferences files in the ~/Library/Preferences 
> directory and the things loaded by NSUserDefaults has been tenuous for a few 
> releases of the OS, the plist files get written, and read, only when the OS 
> jolly well feels like it, the rest of the time they’re cached probably in a 
> daemon. 
Yes. I am aware of all that.
Regardless of when the prefs get persisted the user defaults available to the 
app are not what I anticipate.

As I said the issue only appears for a signed archive build for non admin users.
For admin users and debug builds for non admin users everything is fine.

J


___

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: applicationSupportDirectory access for admin and standard users

2015-12-22 Thread Jonathan Mitchell

> On 21 Dec 2015, at 22:24, Sean McBride  wrote:
> 
> On Mon, 21 Dec 2015 22:16:39 +, Jonathan Mitchell said:
> 
>> My app seems to be having trouble reading and writing to the
>> applicationSupportDirectory.
> 
> What's "trouble"?  What error code do you get trying to write to the 
> directory?
> 
> Cheers,
The “trouble” seems  systemic.
The issues appear only when I use a signed archived release of my app for a 
standard or guest user.
Debug builds are fine.

The issues seem to be:

1. My preferences file does not get updated on first launch. This causes 
trouble further on.
2. In -applicationDidFinishLaunching: an exception is raised because of the 
failure to find a key in NSUserDefaults.
3. NSApplication logs the exception in 2 but does not abort. This effectively 
short circuits -applicationDidFinishLaunching leaving the app in an 
unanticipated state.

I probably mis-diagnosed the original issue.

I can probably insert a try/catch block in  -applicationDidFinishLaunching: but 
the main issue is the write failure of the preferences file.

Perhaps I need to try sandboxing and see what happens. I ‘seem' to be tripping 
over some code signing / security infrastructure that comes into play for non 
admin users.

J



___

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

applicationSupportDirectory access for admin and standard users

2015-12-21 Thread Jonathan Mitchell
Hi

My app seems to be having trouble reading and writing to the 
applicationSupportDirectory depending on whether the logged in user is an admin 
or standard user.
I don’t use the sandbox.

NSURL *appSupportDir = [[NSURL alloc] initFileURLWithPath:[[NSFileManager 
defaultManager] applicationSupportDirectory] isDirectory:YES];

Is there anything I need to be aware of here?

Thanks

J










___

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

NSView -identifier - is there more to it?

2015-12-09 Thread Jonathan Mitchell
The docs for the NSUserInterfaceItemIdentification protocol for @property(copy) 
NSString *identifier say:

If you create an item in Interface Builder and do not set a value for this 
string, a unique value is created for the item when the nib file is loaded. 

and

You should not change the value of a window’s identifier after adding any views 
to the window. For views and controls in a window, the value you specify for 
this string must be unique on a per-window basis.

I have a ton of deeply nested dynamic UI and it really helps when using the 
Xcode UI debug tools to have a meaningful view identifier - say the view 
controller class name.

When views are loaded from nibs they do have an identifier but it seems to be 
very far from unique - the trace below is for initial views for one window.

So the questions are:

1. Does AppKit make any use of NSView -identifier to influence actual rendering 
behaviour? Accessibility APIs?
2. Is uniqueness at all necessary?

Thanks

Jonathan

2015-12-09 22:55:46.752 Buster[-] _NS:9
2015-12-09 22:55:47.000 Buster[-] _NS:17
2015-12-09 22:55:47.327 Buster[-] _NS:9
2015-12-09 22:55:47.334 Buster[-] _NS:132
2015-12-09 22:55:47.340 Buster[-] _NS:11
2015-12-09 22:55:47.341 Buster[-] _NS:10
2015-12-09 22:55:47.390 Buster[-] _NS:10
2015-12-09 22:55:47.392 Buster[-] _NS:10
2015-12-09 22:55:47.396 Buster[-] _NS:10
2015-12-09 22:55:47.399 Buster[-] _NS:10
2015-12-09 22:55:48.495 Buster[-] _NS:10
2015-12-09 22:55:48.960 Buster[-] _NS:10
2015-12-09 22:55:49.197 Buster[-] _NS:10
2015-12-09 22:55:49.804 Buster[-] _NS:48
2015-12-09 22:55:49.807 Buster[-] _NS:53
2015-12-09 22:55:49.809 Buster[-] _NS:10
2015-12-09 22:55:49.811 Buster[-] _NS:10
2015-12-09 22:55:49.814 Buster[-] _NS:12
2015-12-09 22:55:49.815 Buster[-] _NS:10
2015-12-09 22:55:49.817 Buster[-] _NS:10
2015-12-09 22:55:49.819 Buster[-] _NS:10
2015-12-09 22:55:49.820 Buster[-] _NS:10
2015-12-09 22:55:49.821 Buster[-] _NS:10
2015-12-09 22:55:49.822 Buster[-] _NS:10
2015-12-09 22:55:49.824 Buster[-] _NS:10
2015-12-09 22:55:49.825 Buster[-] _NS:10
2015-12-09 22:55:49.827 Buster[-] _NS:10
2015-12-09 22:55:49.828 Buster[-] _NS:10
2015-12-09 22:55:49.830 Buster[-] _NS:10
2015-12-09 22:55:49.831 Buster[-] _NS:10
2015-12-09 22:55:49.833 Buster[-] _NS:10
2015-12-09 22:55:49.836 Buster[-] _NS:9
2015-12-09 22:55:49.843 Buster[-] _NS:9
2015-12-09 22:55:49.847 Buster[-] _NS:43
2015-12-09 22:55:50.038 Buster[-] _NS:53
2015-12-09 22:55:50.376 Buster[-] _NS:36
2015-12-09 22:55:50.377 Buster[-] _NS:9
2015-12-09 22:55:50.394 Buster[-] _NS:36
2015-12-09 22:55:50.395 Buster[-] _NS:9
2015-12-09 22:55:50.419 Buster[-] _NS:10
2015-12-09 22:55:50.460 Buster[-] _NS:10



Regards

Jonathan Mitchell
Mugginsoft LLP

jonat...@mugginsoft.com
-
KosmicTask - the Integrated Scripting Environment for OS X.
http://www.mugginsoft.com/KosmicTask
-
Follow on Twitter @KosmicTask
-
Github http://github.com/mugginsoft













___

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: NSViewController -identifier unrecognized selecto problem

2015-12-09 Thread Jonathan Mitchell
HI Kyle.
Thanks for that.
I totally missed the fact that NSUserInterfaceItemIdentification is a recent 
addition.
Looks like I will just have to refactor.

J
> On 9 Dec 2015, at 21:19, Kyle Sluder  wrote:
> 
> On Wed, Dec 9, 2015, at 11:20 AM, Jonathan Mitchell wrote:
>> NSViewController conforms to NSUserInterfaceItemIdentification so should
>> implement 
>> @property (nullable, copy) NSString *identifier;
>> 
>> I build my app on 10.11 with a deployment target of 10.9
>> 
>> Om 10.10 and 10.11 no issues.
>> On 10.9 I get
>> 
>> 'NSInvalidArgumentException', reason: '-[TSToolbarGroup identifier]:
>> unrecognized selector sent to instance 0x6018ee10’
>> TSToolbarGroup is an NSViewController subclass of mine
> 
> As per the AppKit release notes, NSViewController only started
> conforming to NSUserInterfaceItemIdentification in 10.10. Sadly, the are
> no availability macros for conformances.
> 
> You might consider filing a bug report about this, but in the meantime
> you'll need to stop sending -identifier to your view controllers when
> running on 10.9.
> 
> --Kyle Sluder
> 
> ___
> 
> 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/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.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

NSViewController -identifier unrecognized selecto problem

2015-12-09 Thread Jonathan Mitchell
NSViewController conforms to NSUserInterfaceItemIdentification so should 
implement 
@property (nullable, copy) NSString *identifier;

I build my app on 10.11 with a deployment target of 10.9

Om 10.10 and 10.11 no issues.
On 10.9 I get

'NSInvalidArgumentException', reason: '-[TSToolbarGroup identifier]: 
unrecognized selector sent to instance 0x6018ee10’
TSToolbarGroup is an NSViewController subclass of mine

How can this be?
I didn’t have this issue when I built against 10.9 rather than 10.11.

Curiously the header for NSViewController on 10.11 doesn’t define any 
identifier accessors.

When building solely for 10.9 I used to declare an identifier property on my 
view controller subclasses (obviously with good reason, though why I thought 
this was necessary I don’t know now)
@property (strong) NSString *identifier;
But Xcode 7 moans about property synthesis when this is present.

J














___

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: Best Control for a Matrix these days?

2015-12-04 Thread Jonathan Mitchell

> On 4 Dec 2015, at 11:21, Dave  wrote:
> 
> Hi All,
> 
> Well, I’ve got plenty of options to be going on with!
> 
> I’ve got a better “Spec” now, the Maximum is up to 3 Columns, but with a 
> variable number of rows in each Column. So, I don’t think I can base it on 
> NSTableView as (off to the top, not used NSTableVIew on Mac for a long time), 
> I seem to remember it supports a fixed number of Rows per Column…..
The guts of what I use is here. SorryI forgot to post it earlier.

https://gist.github.com/Thesaurus/f6e6d60495cb8f29eb48/edit

> 
> I leaning towards doing it either as Nested Stack Views or just as an NSView 
> Subclass, although the Auto-Layout stuff complicates this greatly so I think 
> is the way to go on this………
> 
> All the Best
> Dave
> 
>> On 3 Dec 2015, at 18:54, Lee Ann Rucker  wrote:
>> 
>> That doesn't give you enough control over row/column layout. How about 
>> nested NSStackViews?
>> 
>> 
>> NSCollectionView
>> --
>> Gary L. Wade (Sent from my iPad)
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.garywade.com_&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=Ovx3p7ZngLjpJw59NjTdXanjpTLNJOtQ2jbtXQvp1LU&s=bN3Fn68sVADDHN4nV5L5JDZKhAD1-eJgMxuVVWacYjg&e=
>>  
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.garywade.com_&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=Ovx3p7ZngLjpJw59NjTdXanjpTLNJOtQ2jbtXQvp1LU&s=bN3Fn68sVADDHN4nV5L5JDZKhAD1-eJgMxuVVWacYjg&e=>
>> 
>>> On Dec 3, 2015, at 5:00 AM, Dave  wrote:
>>> 
>>> Hi,
>>> 
>>> This is a Mac question, not iOS.
>>> 
>>> Which Class is the latest best practise for displaying a matrix in a View.
>>> 
>>> The matrix can be maximum 3 rows x 4 columns and each item contains a small 
>>> Icon type image and a Text String.
>>> 
>>> I get an array of arrays and two parameters that tell me how many rows and 
>>> columns to populate:
>>> 
>>> numColumns = 3;
>>> numRows = 2;
>>> 
>>> Would be:
>>> 
>>> columnArray [0] = rowArray[0] - Payload Object
>>> columnArray [0] = rowArray[1] - Payload Object
>>> 
>>> columnArray [1] = rowArray[0] - Payload Object
>>> columnArray [1] = rowArray[1] - Payload Object
>>> 
>>> columnArray [2] = rowArray[0] - Payload Object
>>> columnArray [2] = rowArray[1] - Payload Object
>>> 
>>> 
>>> Thanks a lot
>>> All the Best
>>> Dave
>>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
>> <mailto: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 
>> <http://lists.apple.com/>
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com 
>> <https://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com>
>> 
>> This email sent to lruc...@vmware.com <mailto: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/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.com

Regards

Jonathan Mitchell
Mugginsoft LLP

jonat...@mugginsoft.com
-
KosmicTask - the Integrated Scripting Environment for OS X.
http://www.mugginsoft.com/KosmicTask
-
Follow on Twitter @KosmicTask
-
Github http://github.com/mugginsoft













___

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

Overriding property attributes

2015-12-03 Thread Jonathan Mitchell
Hi

NSObject declares:
@property(readonly, copy) NSString *description

However, on occasion I may require a non atomic variant:
@property (nonatomic, readonly, copy) NSString * description;

My usage case involves using a code generator that outputs property 
declarations in a standardised way that can cause these attribute clashes and 
associated warnings:
Two things:

1. What is the best way to deal with this situation? I can disable the warning 
with a pragma targeting -Wproperty-attribute-mismatch. Is that it?
2. Does the attribute mismatch have the potential to cause any serious issues 
for ARC?

Thanks

Jonathan














___

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: Best Control for a Matrix these days?

2015-12-03 Thread Jonathan Mitchell

> On 3 Dec 2015, at 16:23, Jim Crate  wrote:
> 
> On Dec 3, 2015, at 8:00 AM, Dave  wrote:
>> 
>> This is a Mac question, not iOS. 
>> 
>> Which Class is the latest best practise for displaying a matrix in a View.
>> 
>> The matrix can be maximum 3 rows x 4 columns and each item contains a small 
>> Icon type image and a Text String. 

I have found that an NSTableView can do the job with a bit of subclassed TLC.
If you are interested I can stick my subclass on github and you can check it 
out.
It’s pretty simple and likes bindings.

J















___

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

Helper tool

2015-12-03 Thread Jonathan Mitchell

I need to install a persistent always on launch daemon/agent for my app that 
queries an external URL and optionally communicates with the app if it is 
running.

Is EvenBetterAuthorizationSample the current best practice?

J














___

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: NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-11-06 Thread Jonathan Mitchell
This thread is a bit long in the tooth but I thought I would conclude it.
My final solution to this was not to try and split a separate NSResponder class 
off from my NSViewController.
I could have been gone down this route but the sheer amount of donkey work put 
me off.
The app was designed to work with NSViewController instances between the 
NSWindow and the NSWindowController in the chain - period.
The 10.10 API changes simply invalidated my design.
You could argue that the NSViewController should not have been inserted into 
the chain as I had done but there was nothing that I know of that would have 
mandated against this design.

Anyhow, my fix was to give my controllers an additional NSViewController proxy 
property.
The proxy does not load the controller’s nib, it merely references the parent 
controller’s view and participates in the auto responder chain building.
The parent controller can then be inserted higher up in the responder chain as 
before.

https://github.com/mugginsoft/XSViewController/commit/29b406a4e1882edea2203eaff3c44f1c6a2f4cbd


> On 4 Oct 2015, at 11:02, Jonathan Mitchell  wrote:
> 
> 
>> On 3 Oct 2015, at 18:43, Quincey Morris 
>>  wrote:
>> 
>> 
>> I suggest you consider breaking your view controllers apart into two 
>> objects. One, a “view responder” would be a NSResponder subclass that you 
>> insert into the responder chain just below the window controller. The other, 
>> an actual NSViewController subclass, would be inserted into the responder 
>> chain wherever the frameworks want, or possibly not at all pre-10.10.
> That’s a good idea!
> 
>> 
>> Ideally, all of the business logic would be moved from its current home in 
>> the view controller to the view responder, including the action messages. 
>> All that’d be left in the view controller would be the outlets (if any), and 
>> the viewDidLoad logic necessary to prepare the view itself (and also to 
>> create the view responder, and insert it in the responder chain). 
>> Alternatively, you could keep all the local-to-view logic in the view 
>> controller, and put only the trans-view logic in the view responder, but 
>> this may get a bit messy if both share the same custom data structures.
> 
> The business logic is all in a separate framework.
> The view controllers simply hookup the UI bindings by calling into the BL.
> So I might go along the lines of of an additional lightweight NSResponder 
> that acts an action receiver that routes actions back to proxies in the view 
> controller.
> 
> Or, it might be simpler to just accept the 10.10 design changes and refactor 
> accordingly.
> In the long term this might be best in terms of reducing overall complexity.
> 
> Thanks a bunch for you input. It helped a lot.
> 
> J


___

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: Crash running C code built on OS X El Capitan in Xcode 7

2015-11-02 Thread Jonathan Mitchell

> On 2 Nov 2015, at 17:24, Jens Alfke  wrote:
> 
> 
>> On Nov 2, 2015, at 6:27 AM, Jonathan Mitchell  
>> wrote:
>> 
>> It fails if I build and run it on OS X 10.11 using Xcode 7.1 - 
>> EXC_BAD_ACCESS in mono_jit_runtime_invoke() when calling 
>> AssemblyName:GetName()
>> However the built binary runs fine outside of the Xcode environment.
> 
> I agree with Fritz that you’re probably best off asking about this on a Mono 
> forum, since it sounds like an issue with Mono on 10.11 (or Xcode 7) and 
> you’re probably not the only person to run into it.
I have a query in on the Mono list already.
Most mac users of Mono likely use the Xamarin Studio IDE as opposed to Xcode.

> 
> If you do keep troubleshooting on your own, what I would try next is starting 
> an lldb session from a shell and running your program in it. That will 
> isolate whether it’s something to do with Xcode itself.

I agree that this sounds like the best next step.

Thanks

J
___

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: Crash running C code built on OS X El Capitan in Xcode 7

2015-11-02 Thread Jonathan Mitchell



> On 2 Nov 2015, at 16:40, Fritz Anderson  wrote:
> 
> [Cross-ref the query “EXC_BAD_ACCESS puzzle when not running as test bundle” 
> on cocoa-dev. The OP determined this was likely a tools issue, and has 
> brought it here.]
> 
> 
> On 2 Nov 2015, at 8:27 AM, Jonathan Mitchell  wrote:
>> 
>> The following C test code calls the current Mono 4.2.1-91 framework.
>> It builds and runs fine on Xcode 6.4 on 10.10.
>> 
>> It fails if I build and run it on OS X 10.11 using Xcode 7.1 - 
>> EXC_BAD_ACCESS in mono_jit_runtime_invoke() when calling 
>> AssemblyName:GetName()
>> However the built binary runs fine outside of the Xcode environment.
>> 
>> This obviously makes life difficult.
>> Any ideas or suggestions as to why this is occurring?
>> Is there anyway to mitigate it?
> 
> Not being familiar with the Mono runtime (within which the crash occurs), I 
> can’t offer anything specific. Maybe there’s a Mono list where you could find 
> more-experienced help. You ask for mitigation; maybe I can offer ideas.
> 
> 1. Systemic
> 
> 1 a. Where is the Mono runtime installed, and therefore whence is it loaded? 
> Is it different between Xcode and bare execution? It often is. [Cross-ref 3 
> b, below]
Mono is always loaded from /Library/Frameworks
> 
> 1 b. Can you say, hand-to-God, that not one component of the runtimes comes 
> from a different build? 
Hand to whoever, wherever. This issue arose in Dubrovnik, my objc-Mono bridge. 
The code here is the issue distilled.
The test code links to a prebuilt Mono and CoreFoundation, period.
> 
> 1 d. The location alone might uncover an issue with 10.11’s System Integrity 
> Protection (rootlessness), though I’d think the bug/no-bug split would go the 
> other way. This list could be of help from there.
> 
> 1 e. A shortcut to determining whether SIP is the problem is to reboot from 
> the recovery partition (hold R down when the startup gong sounds) and disable 
> it.
I suspected SIP earlier and zapped it without effect.

> 
> 
> 2. Debugging
> 
> 2 a. If you have the Mono runtime source, of course you’ve already set a 
> breakpoint at the exception site and re-run so you could examine the frames 
> in the call chain.
> 
> 2 b. If you have the source but can’t get the debugger to show it to you (you 
> should research ways to relieve that), you can audit the likely call chains 
> to the crash site. Maybe you can trace the pointer — or its provenance — that 
> went bad.
> 
> 2 c. Of course you’ve already audited the pointer as it leaves your own code, 
> and examined the values in the struct(s) it points to.
Needless to say the Mono code is one complex ball of C.
Looking in that haystack will be my last approach I think.
Objects look kosher as they leave my code.
I did try to use Xcode to inspect some objects along the call chain but with  
only mixed results.

> 
> 2 d. Address sanitizer.
This option was disabled in the diagnostic settings for my C command line tool.
> 
> 
> 3. Alternatives
> 
> 3 a. If it works standalone and fails in the Xcode testing harness, split the 
> difference: Run the problem code under lldb from the command line. Find 
> tutorials and explore the help text (practically the only current user 
> documentation) before you start debugging, don’t try to learn and debug 
> simultaneously.
> 
> 3 b. The Xcode debugging wrapper will tell you where it found its dynamic 
> libraries, but lldb can do it more explicitly.
> 
> (Special case of the maxim never to learn a development tool with a gun to 
> your head. I’ve been amazed at how people even do that _by choice._)
I hadn’t though of that. Thanks, will do.
I am rolling my dev environment back to 10.4 and will try and chase this down 
in a VM.

Thanks again.

Jonathan


___

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: EXC_BAD_ACCESS puzzle when not running as test bundle

2015-11-02 Thread Jonathan Mitchell
Hmm.
Some more testing has enabled me to remove my Cocoa wrapper altogether and the 
issue persists.
So I will move the query over to the Xcode list.

> On 2 Nov 2015, at 09:45, Jonathan Mitchell  wrote:
> 
> This has me puzzled.
> 
> I have some code that is giving trouble only when built on 10.11.
> I have set up a simple test scenario and it boils down to the following.
> If I execute the same 4 line test code as part of a unit test bundle it works 
> fine.
> If I try and execute the exact same code as part of a foundation tool then it 
> crashes with EXC_BAD_ACCESS.
> 
> The actual code is calling down into Mono and the crash is associated with 
> the AOT compiler (my Cocoa code provides a wrapper to Mono).
> So there is plenty there that could be going askew on 10.11.
> However the fact that the code executes successfully when running as part of 
> test bundle has me stumped.
> The code runs fine on 10.10 and code built on 10.10 runs fine on 10.11.
> 
> Enabling the usual debug stuff (Zombies etc) show up little.
> There are some dlopen() failures logged, but these get logged for the passing 
> unit test case too.
> 
> Does anyone have any idea what could be occurring here?
> I though it was perhaps a SIP related issue, but I have disabled that.
> 
> Thanks
> 
> Jonathan
> 
> 
> 
> 
> ___
> 
> 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/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.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

EXC_BAD_ACCESS puzzle when not running as test bundle

2015-11-02 Thread Jonathan Mitchell
This has me puzzled.

I have some code that is giving trouble only when built on 10.11.
I have set up a simple test scenario and it boils down to the following.
If I execute the same 4 line test code as part of a unit test bundle it works 
fine.
If I try and execute the exact same code as part of a foundation tool then it 
crashes with EXC_BAD_ACCESS.

The actual code is calling down into Mono and the crash is associated with the 
AOT compiler (my Cocoa code provides a wrapper to Mono).
So there is plenty there that could be going askew on 10.11.
However the fact that the code executes successfully when running as part of 
test bundle has me stumped.
The code runs fine on 10.10 and code built on 10.10 runs fine on 10.11.

Enabling the usual debug stuff (Zombies etc) show up little.
There are some dlopen() failures logged, but these get logged for the passing 
unit test case too.

Does anyone have any idea what could be occurring here?
I though it was perhaps a SIP related issue, but I have disabled that.

Thanks

Jonathan




___

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: NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-10-04 Thread Jonathan Mitchell

> On 3 Oct 2015, at 18:43, Quincey Morris  
> wrote:
> 
> 
> I suggest you consider breaking your view controllers apart into two objects. 
> One, a “view responder” would be a NSResponder subclass that you insert into 
> the responder chain just below the window controller. The other, an actual 
> NSViewController subclass, would be inserted into the responder chain 
> wherever the frameworks want, or possibly not at all pre-10.10.
That’s a good idea!

> 
> Ideally, all of the business logic would be moved from its current home in 
> the view controller to the view responder, including the action messages. All 
> that’d be left in the view controller would be the outlets (if any), and the 
> viewDidLoad logic necessary to prepare the view itself (and also to create 
> the view responder, and insert it in the responder chain). Alternatively, you 
> could keep all the local-to-view logic in the view controller, and put only 
> the trans-view logic in the view responder, but this may get a bit messy if 
> both share the same custom data structures.

The business logic is all in a separate framework.
The view controllers simply hookup the UI bindings by calling into the BL.
So I might go along the lines of of an additional lightweight NSResponder that 
acts an action receiver that routes actions back to proxies in the view 
controller.

Or, it might be simpler to just accept the 10.10 design changes and refactor 
accordingly.
In the long term this might be best in terms of reducing overall complexity.

Thanks a bunch for you input. It helped a lot.

J
___

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: NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-10-03 Thread Jonathan Mitchell

> On 3 Oct 2015, at 03:40, Quincey Morris  
> wrote:
> 
> On Oct 2, 2015, at 15:03 , Jonathan Mitchell  wrote:
> 
> “When a view is assigned” sounds to me an awful lot like “when 
> [NSViewController setView:] is called”. You might have more success moving 
> the super call to the beginning of your method, if you haven’t tried that 
> already.
Moving the call site makes no difference. The posted code is padded out with 
test logic.

> 
> At a different level, though, I’d recommend you don’t do what you’re doing. 
> My Apple tea-leaf reading instincts tell me that pretty soon you won’t have 
> the choice of where to insert the view controller in the responder chain, so 
> your methodology may not have long term survival prospects. 
I would say this has occurred already. Looks as if you cannot reassign an 10.10 
NSViewController -view’s next responder.

> 
> Unfortunately, the problem you’re trying to solve is awkward to deal with. 
> Your intention makes perfect sense, but it happens to be in direct conflict 
> with the design of the responder chain. Your solution only works if there’s 
> only *one* view controller (for a given action message) below the window 
> controller. If there were multiple candidate view controllers, it’d be 
> ambiguous which one should receive the action vs. which one would receive it. 
> If there’s only one candidate, it’s straightforward for the window controller 
> to know or be told which view controller handles which action message.
The responder chain is, as you know, very flexible.
I used the FOSS XSViewController component to manage the responder chain.
This has a distinct design, placing the view controller responders above the 
views and below the window.
It has worked well for me and you can choose which controllers to insert into 
the the chain and which to omit,
It however looks like it really doesn’t fly with the 10.10+ NSViewController 
changes.

>  I think you’re better off, long term, in simply putting the/an action method 
> in the window controller, and letting the window controller call the view 
> controller action method directly. (You’d also need the view controller to 
> have a ‘canDoAction’ method, so that the window controller could query it 
> during interface validation, if you want to keep your view controller logic 
> partitioned neatly.)

The target app is basically a form processor and has ~300 nibs swapping in and 
out of a single document window.
The view hierarchy is just too deep to let the window controller redirect the 
actions.
Plus I have used the responder chain in preference to a constructing a second 
network of -delegate references (a custom action sender class enables 
interaction between the action sender and the eventual action receiver).

Ahh well, looks like there might some bullet biting ahead…

Thanks for the FWIW

J
___

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: NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-10-02 Thread Jonathan Mitchell
Hi Conrad
> On 2 Oct 2015, at 18:35, Conrad Shultz  wrote:
> 
>> 
>> On Sep 30, 2015, at 9:15 AM, Jonathan Mitchell  
>> wrote:
>> 
>> In my app i manage the responder chain on 10.8 and 10.9 to insert the 
>> NSViewController into the responder chain.
>> The view controllers are inserted just below the NSWindowController so that 
>> designated view controllers can respond to actions coming up the chain from 
>> any source.
>> ie: the NSViewController for any view will NOT be the view’s next responder 
>> - it will be higher up in the chain.
>> 
>> On 10.10 the view controller is automatically assigned to be the view’s next 
>> responder.
>> I want to override this behaviour to not assign the controller as the view’s 
>> next responder. 
>> I thought this would be trivial but once the NSView nextResponder has been 
>> set to the controller the view seems reluctant to have its next responder 
>> changed.
>> The next responder remains set to the view controller;
> 
> Starting with 10.10, -[NSView setNextResponder:] forwards to the view 
> controller, which is what you are seeing.
> 
I am not disputing the veracity of the release notes!

The troublesome aspect is that I cannot override this new behaviour.
The view will not seemingly permit its nextResponder to be diverted from the 
NSViewController.
I am not aware of anywhere else in app kit where this occurs nor can I really 
understand why this sticky responder behaviour has been adopted.
Normally I can assign the nextResponder as I see fit.

I had hoped that whoever coded this new behaviour might chip in…

Thanks for the reply.

Jonathan


___

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

NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-09-30 Thread Jonathan Mitchell
In my app i manage the responder chain on 10.8 and 10.9 to insert the 
NSViewController into the responder chain.
The view controllers are inserted just below the NSWindowController so that 
designated view controllers can respond to actions coming up the chain from any 
source.
ie: the NSViewController for any view will NOT be the view’s next responder - 
it will be higher up in the chain.

On 10.10 the view controller is automatically assigned to be the view’s next 
responder.
I want to override this behaviour to not assign the controller as the view’s 
next responder. 
I thought this would be trivial but once the NSView nextResponder has been set 
to the controller the view seems reluctant to have its next responder changed.
The next responder remains set to the view controller;

On 10.10
The following works when linked against the 10.9 SDK but fails when linked 
again the 10.10 SDK.

@interface TestViewController : NSViewController

@end

@implementation TestViewController

- (void)setView:(NSView *)view
{
NSResponder *controlleNextResponder = self.nextResponder; // a window, the 
view is already in a nib
NSResponder *viewNextResponder = view.nextResponder;

NSLog(@"Before : %@ (== %@)", view.nextResponder, viewNextResponder);

NSView *interimResponder = [NSView new];
view.nextResponder = interimResponder;

NSLog(@"Interim : %@ (== %@)", view.nextResponder, interimResponder);

[super setView:view];

self,view.nextResponder = viewNextResponder;
self.nextResponder = controlleNextResponder;

NSLog(@"After : %@", view.nextResponder);

NSAssert(self.view.nextResponder == viewNextResponder, @"next responder is 
not restored");
}
@end

Jonathan













___

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: best way to implement a clickable grid?

2015-09-15 Thread Jonathan Mitchell

> On 15 Sep 2015, at 01:17, Patrick J. Collins  
> wrote:
> 
> Hi everyone,
> 
> I am looking to implement something that would look somewhat like a
> graphic equalizer.  Meaning, a grid of blocks...  Clicking on a single
> grid block would change the appearance of all cells directly under it..
> So in other words, clicking on 1,1 would turn on 1,1. but clicking 1,5
> woudl turn on 1,5, 1,4, 1,3, 1,2, 1,1…
> 
You might find this useful.

https://github.com/ThesaurusSoftware/TSUniformGrid

Jonathan














___

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: StackViews and XCode 6.4

2015-09-10 Thread Jonathan Mitchell
Hi Dave

NSStackView works great and I use it extensively to build my entire UI, 
encapsulating one stack view inside another.
I don’t use XCode at all to manage the stack view content.
I generally create my stack view in code, set its properties then load in 
subviews from a nib(s).

I use a Stack view subclass at https://github.com/mugginsoft/TSStackView
This provides observation behaviour to remove a view form the stack using 
view.hidden. I find this very useful.
It also provides an auto height options that expands the stack to fit the 
content - very handy when embedding one stack view within another.
+ it provides an option to embed the stack view within a scroll view.

Getting the stack view internal and subview constraints sorted can be tricky.
The best approach is to start with nada and slowly add constrains one at a time.

Note that the stack view minimises its subviews by calling -fittingSIze.
If your view is not fully constrained in both width and height then the view 
will collapse in the stack view and effectively vanish.
If you ask Xcode to 'Add missing constraints' it will do so, but in general it 
will not add a constraint from the bottom subview to the container view.
Such a view will collapse in the stack view.
You need to add a vertical spacing constraint between the last subview and the 
container.

In general I use stack view as a universal layout container for main UI.
I don’t usually use the detachment/reattachment functionality.

Jonathan


> On 9 Sep 2015, at 17:46, Dave  wrote:
> 
> HI,
> 
> It is worth trying to use NSStackViews in XCode 6.4? I watched a WWDC 2015 
> video about auto layout and StackViews and it looks likes XCode 7 fixes a 
> *lot* of issues with StackViews and auto layout in general. 
> 
> The reason I ask about XCode 6.4 is because I’m trying to take an existing 
> View Hierarchy and add it to a StackVIew in the hope it will make layout 
> easier. But I’m having all kind of problems setting this up in XCode 6.4 Mac 
> OS X 10,10.
> 
> I’m trying to do what is described here in XCode:
> 
> https://developer.apple.com/videos/wwdc/2015/?id=218
> 
> But of course 6.4 doesn’t have the “Add to Stack Button” so I’ve been trying 
> to do it manually without much success.
> 
> If I want to use StackVIew should I wait for XCode 7? If so does it also mean 
> that I have to target 10.11 in order to make it work like in the above video?
> 
> Any help or suggestions greatly appreciated.
> 
> All the Best
> Dave
>  
> ___
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list  (xcode-us...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/xcode-users/jonathan%40mugginsoft.com
> 
> This email sent to jonat...@mugginsoft.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: Swift generics, circular type declarations, and segfaults, oh my!

2015-09-06 Thread Jonathan Mitchell

> On 6 Sep 2015, at 21:19, Quincey Morris  
> wrote:
> 
> I’ve been thinking about the implications of this for a couple of days now. 
> Of course, you should file a Radar if you see some compiler behavior that 
> looks like it ought to work. But I think there’s a higher order problem 
> that’s worth noting.
> 
> In my experience (which is to say, after a couple of months spent converting 
> a fair-sized app from Obj-C to Swift), converting an Obj-C implementation to 
> directly an “equivalent” Swift implementation is a lousy experience with poor 
> results. There are several waves of consequences from the attempt:
> 
> 1. You struggle to find a Swift equivalent of your Obj-C code. It takes 
> forever.
> 
> 2. You find your equivalent code ends up wordier and somehow more 
> "unfactored" than the Obj-C code, even though it is somehow “the same”. You 
> hate using it.
> 
> 3. You fiddle with the Swift implementation (leaving Obj-C behind, finally) 
> to make it a bit more streamlined. It takes forever.
> 
> 4. You crash the compiler AND SourceKit, because you’ve ventured into 
> uncharted territory in order to hide an Obj-C-derived mess behind Swift 
> syntax. You have to look for workarounds at least until the next Xcode beta.
> 
Very interesting indeed. This is the sort of ‘from the trenches' report we need.

I did a few days work on my own fair substantially app with regard to Swift 
integration / conversion and made a reluctant gut instinct decision to stay 
with Obj-C (even though I really wanted to utilise Swift). There was just too 
much stuff (KVO, bindings etc) that didn’t feel like a good fit with Swift 
within an established project.

Jonathan
___

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

NSXMLDocument - XSLT version

2015-09-06 Thread Jonathan Mitchell
It seems that NSXMLDocument only supports XSLT v 1.0.
In particular I am interested in the date format support that is part of XSLT 2.

I have found extension code such as this:

http://exslt.org/date/functions/format-date/

But it seems rather old school.
Is there a better approach out there?

Sample NSDocument XSLT console output:

compilation error: element stylesheet
xsl:version: only 1.0 features are supported
xmlXPathCompOpEval: function current-dateTime not found
XPath error : Unregistered function
xmlXPathCompiledEval: evaluation failed
runtime error: element value-of
XPath evaluation returned no result.


Thanks

Jonathan













___

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: Xcode 6.4 on the Developer download site.

2015-08-07 Thread Jonathan Mitchell

> On 7 Aug 2015, at 20:45, Alex Zavatone  wrote:
> 
> We were told a few times that the latest Xcodes should always be on the 
> developer downloads site at:
> 
> https://developer.apple.com/downloads/
> 
> I'm trying to download a copy of Xcode 6.4's installer and I can't see 
> anything up on that site that's more recent than 6.1.1 using Safari and 
> searching for Xcode
> 
> Any ideas here?
hmm...
I can see it fine and can download from 
http://adcdownload.apple.com/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg.
Not sure what gremlins you have encountered.

Jonathan













___

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: Xcode 6.4 on the Developer download site.

2015-08-07 Thread Jonathan Mitchell

> On 7 Aug 2015, at 20:45, Alex Zavatone  wrote:
> 
> We were told a few times that the latest Xcodes should always be on the 
> developer downloads site at:
> 
> https://developer.apple.com/downloads/
> 
> I'm trying to download a copy of Xcode 6.4's installer and I can't see 
> anything up on that site that's more recent than 6.1.1 using Safari and 
> searching for Xcode
> 
> Any ideas here?
hmm...
I can see it fine and can download from 
http://adcdownload.apple.com/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg.
Not sure what gremlins you have encountered.

Jonathan













___

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: Occasional NSInternalInconsistencyException - could not load nib

2015-08-07 Thread Jonathan Mitchell
Hi Sean
> On 7 Aug 2015, at 15:30, Sean McBride  wrote:
> 
> On Fri, 7 Aug 2015 15:04:19 +0100, Jonathan Mitchell said:
> 
>> Occasionally I get crash reports like so:
>> 
>> Terminating app due to uncaught exception
>> 'NSInternalInconsistencyException', reason: '-[TSStackMenuItem loadView]
>> could not load the "TSStackMenuItem_Image_Info" nib.’
> 
> Jonathan,
> 
> It rings a bell.  Try moving/renaming your app while it's running.  The guts 
> of Cocoa may have a stale cache and/or load things by full path.
> 
Thanks for that - I hadn’t considered that bit of user sabotage in this case.
Unfortunately it doesn’t seem to trigger this issue - though it does more or 
less render the app inoperable, even it doesn’t crash.

Jonathan


___

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

Occasional NSInternalInconsistencyException - could not load nib

2015-08-07 Thread Jonathan Mitchell
Occasionally I get crash reports like so:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: '-[TSStackMenuItem loadView] could not load the 
"TSStackMenuItem_Image_Info" nib.’

They are very infrequent and don’t occur in testing.
I doubt that the nibs are actually missing from the bundle as the problem 
report rate would be much higher.

I now have two reported instances of this in two separate NSViewController 
subclasses.

Looking at these the only oddity that they seem to have in common is that I 
have inadvertently included calls to -view (which causes nib loading) during 
-initWithNibName:bundle:.
This is something I generally take pains to avoid.

Has anyone else encountered something similar?
The infrequency of the execution makes it hard to confirm my suggested fix 
(which is to not call -view during -init). 

Thanks

Jonathan












___

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: Dubrovnik Sucesss!

2015-07-23 Thread Jonathan Mitchell

> On 22 Jul 2015, at 11:54, Uli Kusterer  wrote:
> 
> On 22 Jul 2015, at 11:58, Dave  wrote:
>> Success! Thanks so much for your help Jonathan, I definitely owe you a pint 
>> or two! 
>> 
>> If anyone is trying use Dubrovnik/Mono on Mac OS X and needs to know how to 
>> make it work - give me a shout and I’d be happy to lend a hand. It’s 
>> probably better to mail me directly as it’s a little bit OT for this list.
>> 
>> Thanks to everyone that contributed.
> 
> 
> Could you maybe post the question and answer somewhere and do a quick 
> follow-up here with a link? It's always infuriating to find sth. via search 
> that says "I've solved it" and nothing more.
In short:

1. Dubrovnik requires a 64 bit Mono build in order to make use of ARC. At 
present there is no 64 bit binary download and a Mono 64 build results in 
folder of framework components (which you may or may not be able to link to - 
not sure) but not an actual framework bundle. Dubrovnik has some instructions 
on how to cobble together a working framework but there is a bit of tinkering. 
There is a separate build tool call bockbuild but it is pretty opaque. Xamarin 
have a year end timeline for a supported 64 bit - and hopefully a working build 
workflow too.

2. The Dubrovnik repo as is has an issue with its one and only submodule. The 
submodule is not being correctly retrieved when pulling the initial repo. This 
needs sorted. Personally I often find that I have a working repo with 
submodules that looks hunky-dory but which, when initially pulled, has issues. 
Submodules are very useful but cause pain. I should be able to sort this fairly 
easily.

3. The mscorlib target is a work in progress and does not yet quite build 
successfully. I need to point this out in the docs.

4. The GUI sample app has a link issue. Again this is something that tends to 
appear when the repo is newly pulled. 2 targets generate frameworks and those 
frameworks are linked to by and embedded into the sample app. Linkage fails as 
the frameworks, though built cannot be found. The solution is to ensure that 
the framework location (as set in the inspector) is relative to the build 
folder not a realtive group path or so such. Again this is a straightforward 
fix.

5. The unit tests could not be run as I recalled previously running them. 
Perhaps this is due to a change in Xcode. Instead of running the tests from the 
Project navigator via menu Product - Test I had to use the Test navigator. The 
tests passed okay. It seemed to be then that after that initial test I could 
use menu Product - Test test to run the tests. A bit confusing.

Jonathan













___

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: Has anyone used Dubrovnik?

2015-07-21 Thread Jonathan Mitchell

> On 21 Jul 2015, at 14:11, Dave  wrote:
>  Probably something is out of date, but with no real support, who knows?
With FOSS perseverance is the only game in town.

Jonathan
___

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

  1   2   >