Re: Mantaining legacy APIs in a framework

2015-09-03 Thread Maxthon Chan
Is it possible to respect the old contract throughout? The extra information 
can be exposed to the concrete subclasses through private interface.

Sent from my iPhone

> On Sep 3, 2015, at 07:44, Graham Cox  wrote:
> 
> 
>> On 3 Sep 2015, at 1:34 am, Maxthon Chan  wrote:
>> 
>> If this is your use case you can internally call the new method throughout, 
>> and the new method discards the useless information and calls the old method 
>> using the old contract. Updated programs will override the new method, 
>> adopting the new behaviour, while contract of the old override point is 
>> still respected and old program will still work.
>> 
>> By the way mark your old method as deprecated, as it will generate a warning 
>> and motivate the users of your library to adopt the new interface faster.
> 
> 
> This is usually how I handle this sort of thing. However in this case there 
> are a few additional kinks that made that approach awkward - I 
> (over)simplified the use case.
> 
> The real case is that the framework itself subclasses GCBase for a couple of 
> concrete implementations, and client code then typically subclasses one of 
> these concrete classes (though also sometimes will subclass GCBase itself). 
> The framework’s own concrete classes need the extra parameter so override the 
> new version of the method, but the client subclasses override the old method. 
> So the updated internal subclasses either need to individually consider all 
> the possible overrides and make sure they’re called, or the underlying base 
> class can worry about it in one place and detect which one to call, which was 
> what I was asking about.
> 
> I guess it does make a difference whether this intermediate subclassing takes 
> place or not, so sorry I oversimplified by leaving it out of the story.
> 
> —Graham
> 
> 


smime.p7s
Description: S/MIME cryptographic signature
___

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: Rows from bottom up

2015-09-03 Thread Eric Gorr
I went ahead and used a DTS ticket and the response I got back from Apple is 
that there is no supported way to do what I want.

So, I am left with something custom or attempting to fake it by determining the 
number of rows I need to fill the table (when there aren’t enough already) and 
ordering my data appropriately.


___

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

Unrecognized Selector Exception from IBAction's?

2015-09-03 Thread Dave
Hi,

This is a Mac Project.

I’m getting an Unrecognized Selector Exceptions when clicking on a Button 
Control:

2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
leftButtonAction:]: unrecognized selector sent to instance 0x601221c0
2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
leftRightAction:]: unrecognized selector sent to instance 0x601221c0
2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
toggleDisclosureAction:]: unrecognized selector sent to instance 0x601221c0

I’ve checked in IB and the controls in question seem to be wired up correctly.

The way this works is that I have a WindowController that has a NIB file which 
contains a View Hierarchy. The WindowController then creates an Instance of a 
View Controller (LTWDetailViewController) and adds its View to a StackView 
which is inside a Scroll View. The View Outlets seem to be wired up ok, but the 
IBAction’s cause an Exception.

Please see the following code:

LTWDisclosureViewController.h

@interface LTWDisclosureViewController : NSViewController
{
NSView* _disclosedView;
BOOL_disclosureIsClosed;
}

@property (nonatomic,weak) IBOutlet NSTextField*
titleTextField;
@property (nonatomic,weak) IBOutlet NSButton*   
disclosureButton;
@property (nonatomic,weak) IBOutlet NSView* 
headerView;


-(IBAction) toggleDisclosureAction:(id) theSender;  
//* Causes Exception when Clicked (the methods are 
defined in the corresponding .m file).

@end

——
LTWDetailViewController.h

@interface LTWDetailViewController : LTWDisclosureViewController
{
}

-(id) initWithWindowKind:(NSString*) theWindowKind;
-(NSView*) startup;

@property (nonatomic,weak)  IBOutlet NSView*
pDetailView;


-(IBAction) leftButtonAction:(id) theSender;
//* Causes Exception when Clicked (the methods are defined 
in the corresponding .m file).
-(IBAction) rightButtonAction:(id) theSender;   
//* Causes Exception when Clicked (the methods are defined 
in the corresponding .m file).

@end




——

This code is in the Window Controller, setupStackView is called from 
awakeFromNib.

-(void) setupStackView 
{
CGFloat myMinunumWidth;
NSView* myDetailView;
BOOL
myClipStackViewHorizFlag;
NSMutableDictionary*myViewsDictionary;
NSNotificationCenter*   myNotificationCenter;
LTWDetailViewController*myValidationDetailViewController;

myNotificationCenter = [NSNotificationCenter defaultCenter];

myValidationDetailViewController = [[LTWDetailViewController alloc] 
initWithWindowKind:@"Validation"];

[myValidationDetailViewController setTitle:@"* Test Title 1 *"];
myDetailView = myValidationDetailViewController.view;


[self.pValidationListStackView addView:myDetailView 
inGravity:NSStackViewGravityTop];
  
//**  
//**Use the size of this view as an Minimum
//**
myMinunumWidth = myDetailView.frame.size.width;

//**  
//**Vertically Centered Stack  
//**  
self.pValidationListStackView.orientation = 
NSUserInterfaceLayoutOrientationVertical;
self.pValidationListStackView.alignment = NSLayoutAttributeTop;
self.pValidationListStackView.spacing = 0;

//**  
//**Do Not Hug Horizontally - Let the Fixed Width Subviews Float Centrally
//**  
[self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultLow 
forOrientation:NSLayoutConstraintOrientationHorizontal];

//**  
//**Allow StackView Clipping
//**  
myClipStackViewHorizFlag = YES;

//**  
//**Do Not Resist clipping Horizontally
//**
//**NSScrollView Wrapper Will Allow the Clipped View to be Scrolled into 
View.
//**  
if (myClipStackViewHorizFlag == YES)
[self.pValidationListStackView 
setClippingResistancePriority:NSLayoutPriorityDefaultLow 
forOrientation:NSLayoutConstraintOrientationHorizontal];

//**  
//**The StackView Min Width Will Match the SubView Minimum Width
//**  
else 
[self.pValidationListStackView 
setClippingResistancePriority:NSLayoutPriorityDefaultHigh 
forOrientation:NSLayoutConstraintOrientationHorizontal];

//**  
//**Hug vertically  
//**  
[self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultHigh 
forOrientation:NSLayoutConstraintOrientationVertical];

//**  
//**Do Not Resist Clipping Vertically
//**  
[self.pValida

Re: Unrecognized Selector Exception from IBAction's?

2015-09-03 Thread Mike Abdullah
Try running with zombies turned on. Almost certainly, the object your actions 
are wired up to has been deallocated, and since replaced by the hash table.

> On 3 Sep 2015, at 13:09, Dave  wrote:
> 
> Hi,
> 
> This is a Mac Project.
> 
> I’m getting an Unrecognized Selector Exceptions when clicking on a Button 
> Control:
> 
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> leftButtonAction:]: unrecognized selector sent to instance 0x601221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> leftRightAction:]: unrecognized selector sent to instance 0x601221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> toggleDisclosureAction:]: unrecognized selector sent to instance 
> 0x601221c0
> 
> I’ve checked in IB and the controls in question seem to be wired up correctly.
> 
> The way this works is that I have a WindowController that has a NIB file 
> which contains a View Hierarchy. The WindowController then creates an 
> Instance of a View Controller (LTWDetailViewController) and adds its View to 
> a StackView which is inside a Scroll View. The View Outlets seem to be wired 
> up ok, but the IBAction’s cause an Exception.
> 
> Please see the following code:
> 
> LTWDisclosureViewController.h
> 
> @interface LTWDisclosureViewController : NSViewController
> {
> NSView*   _disclosedView;
> BOOL  _disclosureIsClosed;
> }
> 
> @property (nonatomic,weak) IBOutlet NSTextField*  
> titleTextField;
> @property (nonatomic,weak) IBOutlet NSButton* 
> disclosureButton;
> @property (nonatomic,weak) IBOutlet NSView*   
> headerView;
> 
> 
> -(IBAction) toggleDisclosureAction:(id) theSender;
> //* Causes Exception when Clicked (the methods 
> are defined in the corresponding .m file).
> 
> @end
> 
> ——
> LTWDetailViewController.h
> 
> @interface LTWDetailViewController : LTWDisclosureViewController
> {
> }
> 
> -(id) initWithWindowKind:(NSString*) theWindowKind;
> -(NSView*) startup;
> 
> @property (nonatomic,weak)IBOutlet NSView*
> pDetailView;
> 
> 
> -(IBAction) leftButtonAction:(id) theSender;  
> //* Causes Exception when Clicked (the methods are 
> defined in the corresponding .m file).
> -(IBAction) rightButtonAction:(id) theSender; 
> //* Causes Exception when Clicked (the methods are 
> defined in the corresponding .m file).
> 
> @end
> 
> 
> 
> 
> ——
> 
> This code is in the Window Controller, setupStackView is called from 
> awakeFromNib.
> 
> -(void) setupStackView 
> {
> CGFloat   myMinunumWidth;
> NSView*   myDetailView;
> BOOL  
> myClipStackViewHorizFlag;
> NSMutableDictionary*  myViewsDictionary;
> NSNotificationCenter* myNotificationCenter;
> LTWDetailViewController*  myValidationDetailViewController;
> 
> myNotificationCenter = [NSNotificationCenter defaultCenter];
> 
> myValidationDetailViewController = [[LTWDetailViewController alloc] 
> initWithWindowKind:@"Validation"];
> 
> [myValidationDetailViewController setTitle:@"* Test Title 1 *"];
> myDetailView = myValidationDetailViewController.view;
> 
> 
> [self.pValidationListStackView addView:myDetailView 
> inGravity:NSStackViewGravityTop];
> 
> //**
> //**  Use the size of this view as an Minimum
> //**
> myMinunumWidth = myDetailView.frame.size.width;
> 
> //**
> //**  Vertically Centered Stack  
> //**
> self.pValidationListStackView.orientation = 
> NSUserInterfaceLayoutOrientationVertical;
> self.pValidationListStackView.alignment = NSLayoutAttributeTop;
> self.pValidationListStackView.spacing = 0;
> 
> //**
> //**  Do Not Hug Horizontally - Let the Fixed Width Subviews Float Centrally
> //**
> [self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultLow 
> forOrientation:NSLayoutConstraintOrientationHorizontal];
> 
> //**
> //**  Allow StackView Clipping
> //**
> myClipStackViewHorizFlag = YES;
> 
> //**
> //**  Do Not Resist clipping Horizontally
> //**
> //**  NSScrollView Wrapper Will Allow the Clipped View to be Scrolled into 
> View.
> //**
> if (myClipStackViewHorizFlag == YES)
>   [self.pValidationListStackView 
> setClippingResistancePriority:NSLayoutPriorityDefaultLow 
> forOrientation:NSLayoutConstraintOrientationHorizontal];
> 
> //**
> //**  The StackView Min Width Will Match the SubView Minimum Width
> //**
> else 

Autolayout and Scroll Views?

2015-09-03 Thread Dave
Hi,

I’m trying to setup a Scroll View for Auto Layout, at the suggestion to someone 
on the list, I’m looking at:

http://natashatherobot.com/ios-autolayout-scrollview/

I have the following View Hierarchy setup in the Window NIB.

Window
Custom View
WindowHeaderView

Bordered Scroll View
Flipped Clip View
View
StackView
Scroller
Scroller

Currently I have no constraints setup, so I follow the above link to the “Equal 
Widths” section, I then select “Flipped Clip View” in XCode/IB and add the top, 
bottom, left, right constraints as shown. But then it says:

 “To create the Equal Width Constraint between the ContentView and the View, 
select the ContentView on the view hierarchy and Control + Drag to the View – 
you should get a pop-up that gives you the “Equal Widths” option:”

I’m confused as to how to do this, what do I control drag to what? I’ve tried 
selecting "Flipped Clip View” and Control Dragging it to "Bordered Scroll 
View”, but I don’t get the Pop Up Window as described in the link. How do I do 
this?

All the Best
Dave


___

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: Unrecognized Selector Exception from IBAction's?

2015-09-03 Thread David Durkee
It looks like the buttons may be hooked up to an object of the wrong class? 
Your actions aren’t defined in NSConcreteHashTable. Check your connections.

David

> On Sep 3, 2015, at 7:09 AM, Dave  wrote:
> 
> Hi,
> 
> This is a Mac Project.
> 
> I’m getting an Unrecognized Selector Exceptions when clicking on a Button 
> Control:
> 
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> leftButtonAction:]: unrecognized selector sent to instance 0x601221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> leftRightAction:]: unrecognized selector sent to instance 0x601221c0
> 2015-09-03 12:46:04.464 LTWTest1[1970:896242] -[NSConcreteHashTable 
> toggleDisclosureAction:]: unrecognized selector sent to instance 
> 0x601221c0
> 
> I’ve checked in IB and the controls in question seem to be wired up correctly.
> 
> The way this works is that I have a WindowController that has a NIB file 
> which contains a View Hierarchy. The WindowController then creates an 
> Instance of a View Controller (LTWDetailViewController) and adds its View to 
> a StackView which is inside a Scroll View. The View Outlets seem to be wired 
> up ok, but the IBAction’s cause an Exception.
> 
> Please see the following code:
> 
> LTWDisclosureViewController.h
> 
> @interface LTWDisclosureViewController : NSViewController
> {
> NSView*   _disclosedView;
> BOOL  _disclosureIsClosed;
> }
> 
> @property (nonatomic,weak) IBOutlet NSTextField*  
> titleTextField;
> @property (nonatomic,weak) IBOutlet NSButton* 
> disclosureButton;
> @property (nonatomic,weak) IBOutlet NSView*   
> headerView;
> 
> 
> -(IBAction) toggleDisclosureAction:(id) theSender;
> //* Causes Exception when Clicked (the methods 
> are defined in the corresponding .m file).
> 
> @end
> 
> ——
> LTWDetailViewController.h
> 
> @interface LTWDetailViewController : LTWDisclosureViewController
> {
> }
> 
> -(id) initWithWindowKind:(NSString*) theWindowKind;
> -(NSView*) startup;
> 
> @property (nonatomic,weak)IBOutlet NSView*
> pDetailView;
> 
> 
> -(IBAction) leftButtonAction:(id) theSender;  
> //* Causes Exception when Clicked (the methods are 
> defined in the corresponding .m file).
> -(IBAction) rightButtonAction:(id) theSender; 
> //* Causes Exception when Clicked (the methods are 
> defined in the corresponding .m file).
> 
> @end
> 
> 
> 
> 
> ——
> 
> This code is in the Window Controller, setupStackView is called from 
> awakeFromNib.
> 
> -(void) setupStackView 
> {
> CGFloat   myMinunumWidth;
> NSView*   myDetailView;
> BOOL  
> myClipStackViewHorizFlag;
> NSMutableDictionary*  myViewsDictionary;
> NSNotificationCenter* myNotificationCenter;
> LTWDetailViewController*  myValidationDetailViewController;
> 
> myNotificationCenter = [NSNotificationCenter defaultCenter];
> 
> myValidationDetailViewController = [[LTWDetailViewController alloc] 
> initWithWindowKind:@"Validation"];
> 
> [myValidationDetailViewController setTitle:@"* Test Title 1 *"];
> myDetailView = myValidationDetailViewController.view;
> 
> 
> [self.pValidationListStackView addView:myDetailView 
> inGravity:NSStackViewGravityTop];
> 
> //**
> //**  Use the size of this view as an Minimum
> //**
> myMinunumWidth = myDetailView.frame.size.width;
> 
> //**
> //**  Vertically Centered Stack  
> //**
> self.pValidationListStackView.orientation = 
> NSUserInterfaceLayoutOrientationVertical;
> self.pValidationListStackView.alignment = NSLayoutAttributeTop;
> self.pValidationListStackView.spacing = 0;
> 
> //**
> //**  Do Not Hug Horizontally - Let the Fixed Width Subviews Float Centrally
> //**
> [self.pValidationListStackView setHuggingPriority:NSLayoutPriorityDefaultLow 
> forOrientation:NSLayoutConstraintOrientationHorizontal];
> 
> //**
> //**  Allow StackView Clipping
> //**
> myClipStackViewHorizFlag = YES;
> 
> //**
> //**  Do Not Resist clipping Horizontally
> //**
> //**  NSScrollView Wrapper Will Allow the Clipped View to be Scrolled into 
> View.
> //**
> if (myClipStackViewHorizFlag == YES)
>   [self.pValidationListStackView 
> setClippingResistancePriority:NSLayoutPriorityDefaultLow 
> forOrientation:NSLayoutConstraintOrientationHorizontal];
> 
> //**
> //**  The StackView Min Width Will Match the SubView Minimum Width
> //**

Swift generics, circular type declarations, and segfaults, oh my!

2015-09-03 Thread has

Hi all,

Stuck and looking for ideas here. I need to define a base class whose 
methods vends instances of its subclasses (thus enabling chained method 
calls; your basic query builder). Trivial to do in untyped languages 
like Python (where 'type safety' is a matter of mopping up _after_ the 
runtime craters):


#!/usr/bin/python

class ObjectBase:

def makeNewObject(self):
return self.__class__()

class MyObject(ObjectBase):

def foo(self):
print("foo")


print(MyObject().makeNewObject()) # result is new MyObject instance


MyObject().makeNewObject().foo() # prints "foo"


It's even somewhat doable in ObjC, as `instancetype` declares the return 
type to the type system without having to state an exact type:


@implementation ObjectBase

-(instancetype)makeNewObject {
return [[self.class alloc] init];
}

@end

Although that only works when returning instances of the _same_ class; 
there's no way to express that it'll return a different type that only 
the subclass knows about, e.g.:


@implementation ObjectBase

typealias Other = OtherSubclass

-(instancetype.Other)makeNewObject { // wishful thinking
return [[self.class alloc] init];
}

@end


Swift though? Can't even get that far. Giant headaches all round. 
Creating new instances in itself is not a problem as we can just use 
`self.dynamicType` to get the subclass object and instantiate that:



class ObjectBase {

required init() { }

func makeNewObject() -> ObjectBase {
return self.dynamicType.init()
}
}


class MyObject: ObjectBase {

required init() { }

func foo() {
print("foo")
}
}

print(MyObject().makeNewObject()) // result is new MyObject instance (Yay!)

MyObject().makeNewObject().foo() // error: value of type 'ObjectBase' 
has no member 'foo' (Boo!)



The problem is the base class's method's lousy type signature requires 
clients to force-cast the result to the actual type before they can 
refer to the returned subclass's own members:


(MyObject().makeNewObject() as! MyObject).foo() // this works 
(prints "foo"), but is ugly as sin


Of course, this would make a joke of usability, so isn't even a 
consideration. A kludy solution would be to override all of the base 
class's methods in the subclass, allowing the correct type signatures to 
be declared on its interface:



class MyObject: ObjectBase {

required init() { }

func makeNewObject() -> MyObject {
return super.makeNewObject() as! MyObject
}

func foo() {
print("foo")
}
}

But as this means replicating almost the entire base class each time, 
you have to wonder what the value of subclassing over just copying and 
pasting the original class each time really is. Besides, this is what 
we've got generics for, so we can do nice things like tailor a reusable 
class's method signatures to each specific use cases.


And which is fine… until the type parameter happens to be part of the 
same inheritance tree, whereupon we tie ourselves and the compiler in 
recursive knots.


First attempt, a simple generic class without any constraints:

class ObjectBase {

required init() { }

func makeNewObject() -> T {
return T() // error: 'T' cannot be constructed because it has 
no accessible initializers

}
}

class MyObject: ObjectBase {

required init() { }

func foo() {
print("foo")
}
}

Um, pretty sure it does have an initializer, but okay, let's try using 
dynamicType again:



func makeNewObject() -> T {
return T.dynamicType.init()
}


Now it compiles successfully… and immediately crashes on execution. 
Okay, so take that method out for now and reduce the code to the minimum 
crash case:



class ObjectBase {
required init() { }
}

class MyObject: ObjectBase {
required init() { }
}

MyObject() // crash: EXC_BAD_ACCESS on type metadata accessor for MyObject


Huh. Any completely unrelated type for T, no problem. Anything self 
related, and swiftc and SourceKit DIAF at every turn, usually in a C++ 
stack-blowing infinite recursion of their own doing. And if it's not the 
parser or compiler, it's the runtime. So before I stagger off to write a 
code generator (ick) that mashes absolutely everything into single 
self-contained bespoke generated class every single time, can anyone see 
a way out of this recursive underbaked betaware hole I might've missed?


Thanks,

has


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Unrecognized Selector Exception from IBAction's?

2015-09-03 Thread Dave
Hi,

> It looks like the buttons may be hooked up to an object of the wrong class? 
> Your actions aren’t defined in NSConcreteHashTable. Check your connections.
> 
> David

The Action Handlers are defined in LTWDisclosureViewController and 
LTWDetailViewController as shown in the original post.

The File’s owner in the LTWDetailViewController.xib is set to 
LTWDetailViewController and this is a subclass of LTWDisclosureViewController.

leftButtonAction and leftRightAction are hooked up in IB and defined in 
LTWDetailViewController.

toggleDisclosureAction  is hooked up in IB and defined in 
LTWDisclosureViewController.

If I open the NIB file and the above .m files and hover the mouse over the 
IBAction’s in the .m, it lights up the corresponding Control in IB.

I’m a bit lost as to know where to start to track this down. The only thing I 
can think of is that the VC is created in code inside the WindowController and 
the ViewController is using the WindowController as the file’s owner, but then 
it shouldn’t/wouldn’t light up in IB?

Thanks in advance for any help.

All the Best
Dave




___

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: Unrecognized Selector Exception from IBAction's?

2015-09-03 Thread Dave
Hi,

> On 3 Sep 2015, at 14:00, Mike Abdullah  wrote:
> 
> Try running with zombies turned on. Almost certainly, the object your actions 
> are wired up to has been deallocated, and since replaced by the hash table.

That fixed it thanks - it was the View Controller I forgot to assign to a 
strong property. I thought I did have Zombies turned on, but that was in 
another project.

Thanks again and All the Best
Dave



___

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-03 Thread Fritz Anderson

On 3 Sep 2015, at 8:55 AM, has  wrote:

> Stuck and looking for ideas here. I need to define a base class whose methods 
> vends instances of its subclasses (thus enabling chained method calls; your 
> basic query builder).


I’m assuming Swift 1.2. The following works in an OS X 10.10 playground:

//

class Factory: Printable {
required init() {}

class func makeNew() -> Self {
return self()
}

var description: String { return "This is a Factory." }
}

class Product: Factory, Printable {
override var description: String { return "This is a Product." }
}

let f = Factory.makeNew()  // => __lldb_expr_580.Factory
f.description  // => "This is a Factory."
let p = Product.makeNew()  // => {__lldb_expr_580.Factory}
p.description  // => "This is a Product."

//

* Using an instance as a factory for its own class is contrary to general 
usage, so is a smell at best. It’s a job for a class func. (Yes, 
functional-programming operators do exactly that, but this is an example of the 
Factory pattern, not an operator. You shouldn’t have to instantiate a Product 
to make a Product.)

* Explicitly calling init should be legitimate, as the changes to map{} and the 
like now allow you to use it in the closure. I could still imagine support for 
that usage being withdrawn. I’m not comfortable as a matter of style with 
making it Just Another Func — and the solution above makes it moot.

* Self is the new instancetype. It takes care of casting issues. (I haven’t 
thought out all the corner cases, so don’t hit me. I wear glasses.)

* I was confused by the REPL’s calling Product.makeNew() an 
{__lldb_expr_580.Factory}, but apparently the braces mean “some subclass of.” 
If anyone can offer an authoritative explanation, I’d be glad to know.

* I assume the call to self() in makeNew() goes through to an initializer for 
Product, but my day job calls.

— F


___

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: Auto Layout Problems

2015-09-03 Thread Dave

> On 27 Aug 2015, at 20:09, Glenn L. Austin  wrote:
> 
> I've had great success with auto-layout, even inside scrollviews.
> 
> All it takes is a bit of time to realise that (1) auto-layout isn't like your 
> current layout code; and (2) auto-layout has its own set of rules, that 
> sometimes take a bit of patience to understand (e.g. you aren't going to just 
> "get it" when you're under a deadline to release).
> 
> That all being said, I now prefer auto-layout to what I used to do -- and I 
> used to write my own layout managers.

It’s not that I don’t “get it”, I do get it and I’ve used similar system in 
other OSes, it’s how to actually adapt a working sample App to work my my own 
app using XCode/IB. For instance there’s very little I can find on how to make 
layout work with Scroll Views and/or StackViews for the Mac using XCode/IB. 
There is quite a detailed explanation (as far as I can tell) for iOS, but its 
much different on the Mac.

All I want is a dynamic list of views that can be disclosed or undisclosed. I’m 
really beginning to think I’d be better off using Manual Layout and using Table 
View or whatever.

All the Best
Dave



___

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: Auto Layout Problems

2015-09-03 Thread Gary L. Wade
Check out this year's WWDC videos on autolayout, the part 1/2 ones. I believe 
(just now seeing this post) they will answer what you want and help you know 
that  you are not alone in your pain.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Sep 3, 2015, at 10:23 AM, Dave  wrote:
> 
> All I want is a dynamic list of views that can be disclosed or undisclosed. 
> I’m really beginning to think I’d be better off using Manual Layout and using 
> Table View or whatever.

___

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-03 Thread has

On 03/09/2015 17:05, Fritz Anderson wrote:

On 3 Sep 2015, at 8:55 AM, has  wrote:


Stuck and looking for ideas here. I need to define a base class whose methods 
vends instances of its subclasses (thus enabling chained method calls; your 
basic query builder).


I’m assuming Swift 1.2. The following works in an OS X 10.10 playground:


Swift 2 beta.



class Factory: Printable {
 required init() {}

 class func makeNew() -> Self {
 return self()
 }


Urgh. Usually when I try to use Self anywhere, the compiler just whines 
at me cos I'm thick and it's unhelpful. But yeah, Self does [annoyingly] 
work here, thanks:


func makeNewObject() -> Self {
return self.dynamicType.init()
}

Must've missed it during my experiments. (Ironic when I must've tried 
everything else under the sun.) Durr. I shall console myself with the 
thought I'm not the only one: SourceKit is falling over in a heap of 
infinite recursion [sic] whenever it tries to parse this code. (Will 
have to file a bug on that later.)



* Using an instance as a factory for its own class is contrary to general 
usage, so is a smell at best. It’s a job for a class func.


No, it's fine. It's for an Apple event query builder. Any odd smells are 
probably the Apple event architecture's doing.


Chained var/method calls let you build and send AE queries using a 
non-atrocious syntax, e.g.:


let result: [String] = try TextEdit().documents[1].text.words.get()

I already prototyped the Swift API using code generation on top of an 
existing ObjC API  and now 
I'm trying to simplify and reimplement the whole thing in pure Swift.


In particular, I want to avoid duplicating base classes' general-purpose 
methods in application-specific glues and introduce a little bit of 
compile-time rigour, since different types of queries support different 
sets of operations (e.g. the compiler shouldn't allow you to ask for a 
range of elements on a property specifier, because that's not a valid AE 
query form).


So I guess this brings me to my next question: what if I want the base 
class methods to instantiate more than one subclass? For example, a 
MyObject instance needs to be able to vend instances of both MyObjects 
and MyElements, while a MyElements instance needs to be able to do the 
same, e.g. much simplified pseudocode:


// standard base class

class ObjectBase {

func makeObject() -> ObjectType
func makeElements() -> ElementsType
}


// custom glue subclasses

class MyObject: ObjectBase {
// adds glue-specific methods
}


class MyElements: MyObject {
// adds additional features only appropriate to elements, e.g. 
subscript

}


Needless to say, my only real success here appears to be setting new 
records for no. of Swift/SourceKit parse/compile/run crashes per hour. 
And that's before I even put constraints on the generic parameters 
(since the factory methods refuse to see the subclasses' inits without 
them). Ugh. I'm sure set algebra was never this painful in high school...


Many thanks,

has
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Auto Layout Problems

2015-09-03 Thread Dave
Hi,

> Check out this year's WWDC videos on auto-layout, the part 1/2 ones. I 
> believe (just now seeing this post) they will answer what you want and help 
> you know that  you are not alone in your pain.


Thanks for this, I’m watching them now.

In case anyone wants to watch them, they are at:

https://developer.apple.com/videos/wwdc/2015/?id=218

and

https://developer.apple.com/videos/wwdc/2015/?id=219

I take this requires XCode 7 and Mac OS X 10.11?

Thanks 
Dave

> On 3 Sep 2015, at 18:33, Gary L. Wade  wrote:
> 
> Check out this year's WWDC videos on auto-layout, the part 1/2 ones. I 
> believe (just now seeing this post) they will answer what you want and help 
> you know that  you are not alone in your pain.
> --
> Gary L. Wade (Sent from my iPhone)
> http://www.garywade.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: Auto Layout Problems

2015-09-03 Thread Gary L. Wade
Some of it does, but it still helps if you need to support earlier.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Sep 3, 2015, at 11:19 AM, Dave  wrote:
> 
> Hi,
> 
>> Check out this year's WWDC videos on auto-layout, the part 1/2 ones. I 
>> believe (just now seeing this post) they will answer what you want and help 
>> you know that  you are not alone in your pain.
> 
> 
> Thanks for this, I’m watching them now.
> 
> In case anyone wants to watch them, they are at:
> 
> https://developer.apple.com/videos/wwdc/2015/?id=218
> 
> and
> 
> https://developer.apple.com/videos/wwdc/2015/?id=219
> 
> I take this requires XCode 7 and Mac OS X 10.11?
> 
> Thanks 
> Dave
> 
>> On 3 Sep 2015, at 18:33, Gary L. Wade  wrote:
>> 
>> Check out this year's WWDC videos on auto-layout, the part 1/2 ones. I 
>> believe (just now seeing this post) they will answer what you want and help 
>> you know that  you are not alone in your pain.
>> --
>> Gary L. Wade (Sent from my iPhone)
>> http://www.garywade.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-03 Thread Quincey Morris
On Sep 3, 2015, at 11:16 , has  wrote:
> 
>> * Using an instance as a factory for its own class is contrary to general 
>> usage, so is a smell at best. It’s a job for a class func.
> 
> No, it's fine. It's for an Apple event query builder. Any odd smells are 
> probably the Apple event architecture's doing.

Huh? Why is it fine to create an additional unnecessary object? And what has 
this got to do with Apple events?

The problem with using an instance of the class as a factory is that by the 
time you’ve built the factory (instantiated the factory instance), you’re 
already done building the object you really wanted — you wanted an instance and 
you have it.

> Chained var/method calls let you build and send AE queries using a 
> non-atrocious syntax, e.g.:
> 
>let result: [String] = try TextEdit().documents[1].text.words.get()

Again: huh? Where’s the factory method in this?

In Obj-C, it is more or less viable to follow the factory-instance strategy. 
That’s because (a) Obj-C separates alloc from init, so you alloc an instance (a 
small waste of time) and then throw it away without going through a full init 
(which could be a large waste of time or have side effects); and (b) you’re 
allowed to bail out of init early (though it depends on multiple factors 
whether it’s actually safe to do so).

This situation doesn’t exist in Swift. You must initialize every object fully, 
and that includes a factory-instance. Because of that, you may as well (and 
ought to) use a class-level factory method instead.



___

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

NSAtomicStore and multi processes

2015-09-03 Thread Samir
Hi all,

I’m working on sharing a core data database between multiple processes. 
 
In the "Core Data Programming Guide”, it’s mentioned that core data databases 
does handle multiple processes.

However, I’m using NSAtomicStore as a persistent store and I’d like to know if 
multiple processes can still interact with it (read+write)?

Thanks 

Cheers,
Samir
___

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: objc_msgSend() selector name: tableView:objectValueForTableColumn:row:

2015-09-03 Thread Raglan T. Tiger
My solution to this problem was to set the tableview delegate to nil in the 
windowwillclose for the window containing the table.

My code now runs 10.5 and upward, built with 10.9 sdk on Xcode 6.2

-rags

> On May 26, 2015, at 6:17 PM, Scott Ribe  wrote:
> 
> On Apr 9, 2015, at 12:17 PM, Charles Srstka  > wrote:
>> 
>>> On Apr 9, 2015, at 12:41 PM, Raglan T. Tiger  
>>> wrote:
>>> 
>>> My app runs just fine on OS X version > 10.6.8.
>>> 
>>> On 10.6.8 it crashes.
>>> 
>>> The crash report indicates a bad object having called on it 
>>> tableView:objectValueForTableColumn:row:
>>> 
>>> The eax register has a value that does not match any table being used in 
>>> the app.
>>> 
>>> The call stack does not show reference to the app.
>>> 
>>> I have attempted to symbolicate this using atos but no results.
>>> 
>>> What is an appropriate methodology to determine the offending entry in the 
>>> eax register?
>>> 
>>> 
>>> Application Specific Information:
>>> objc_msgSend() selector name: tableView:objectValueForTableColumn:row:
>>> 
>>> 
>>> Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
>>> 0   libobjc.A.dylib 0x92f43f94 objc_msgSend + 36
>>> 1   com.apple.AppKit0x9179a1da -[NSTableView 
>>> preparedCellAtColumn:row:] + 335
>>> 2   com.apple.AppKit0x917b46bc -[NSTableView 
>>> _drawContentsAtRow:column:withCellFrame:] + 56
> ...
>>> 27  com.apple.AppKit0x9168c289 NSApplicationMain + 574
>>> 28  com.britonleap.Embrilliance 0x0001d938 main + 824
>>> 29  com.britonleap.Embrilliance 0x2985 start + 53
>>> ==
>> 
>> I had this same problem when I was still planning to make Pacifist 3.5 
>> compatible with 10.6.x. What I found was that if I compiled the same code 
>> with Xcode 5.x, it would work, but that Xcode 6 had some sort of problem 
>> compiling code that would work on Snow Leopard without getting that same 
>> crash in the NSTableView code. So basically your options are to downgrade to 
>> an older version of Xcode (which might mean downgrading your OS X 
>> installation as well, since I don’t know if Xcode 5 can run on Yosemite), or 
>> drop 10.6 support. My decision was to do the latter; Snow Leopard is four 
>> years old now. Time to move on.
> 
> Well now, if this isn’t totally strange. I’m starting to see this problem 
> *after* switching to Xcode 6.2 and switching my base SDK (& deployment 
> target) from 10.8 to 10.9.
> 
> Either of you ever figure out anything more about this?
> 
> -- 
> Scott Ribe
> scott_r...@elevated-dev.com 
> http://www.elevated-dev.com/ 
> https://www.linkedin.com/in/scottribe/ 
> 
> (303) 722-0567 voice
> 
> 
> 
> 
> 
> 
> ___
> 
> 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/koko%40highrolls.net 
> 
> 
> This email sent to k...@highrolls.net 
___

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: objc_msgSend() selector name: tableView:objectValueForTableColumn:row:

2015-09-03 Thread Raglan T. Tiger
Correction set the delegate and datasource to nil.
-rags



> On May 26, 2015, at 6:23 PM, Raglan T. Tiger  wrote:
> 
> My solution to this problem was to set the tableview delegate to nil in the 
> windowwillclose for the window containing the table.
> 
> My code now runs 10.5 and upward, built with 10.9 sdk on Xcode 6.2
> 
> -rags
> 
>> On May 26, 2015, at 6:17 PM, Scott Ribe > > wrote:
>> 
>> On Apr 9, 2015, at 12:17 PM, Charles Srstka > > wrote:
>>> 
 On Apr 9, 2015, at 12:41 PM, Raglan T. Tiger >>> > wrote:
 
 My app runs just fine on OS X version > 10.6.8.
 
 On 10.6.8 it crashes.
 
 The crash report indicates a bad object having called on it 
 tableView:objectValueForTableColumn:row:
 
 The eax register has a value that does not match any table being used in 
 the app.
 
 The call stack does not show reference to the app.
 
 I have attempted to symbolicate this using atos but no results.
 
 What is an appropriate methodology to determine the offending entry in the 
 eax register?
 
 
 Application Specific Information:
 objc_msgSend() selector name: tableView:objectValueForTableColumn:row:
 
 
 Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
 0   libobjc.A.dylib0x92f43f94 objc_msgSend + 36
 1   com.apple.AppKit   0x9179a1da -[NSTableView 
 preparedCellAtColumn:row:] + 335
 2   com.apple.AppKit   0x917b46bc -[NSTableView 
 _drawContentsAtRow:column:withCellFrame:] + 56
>> ...
 27  com.apple.AppKit   0x9168c289 NSApplicationMain + 574
 28  com.britonleap.Embrilliance0x0001d938 main + 824
 29  com.britonleap.Embrilliance0x2985 start + 53
 ==
>>> 
>>> I had this same problem when I was still planning to make Pacifist 3.5 
>>> compatible with 10.6.x. What I found was that if I compiled the same code 
>>> with Xcode 5.x, it would work, but that Xcode 6 had some sort of problem 
>>> compiling code that would work on Snow Leopard without getting that same 
>>> crash in the NSTableView code. So basically your options are to downgrade 
>>> to an older version of Xcode (which might mean downgrading your OS X 
>>> installation as well, since I don’t know if Xcode 5 can run on Yosemite), 
>>> or drop 10.6 support. My decision was to do the latter; Snow Leopard is 
>>> four years old now. Time to move on.
>> 
>> Well now, if this isn’t totally strange. I’m starting to see this problem 
>> *after* switching to Xcode 6.2 and switching my base SDK (& deployment 
>> target) from 10.8 to 10.9.
>> 
>> Either of you ever figure out anything more about this?
>> 
>> -- 
>> Scott Ribe
>> scott_r...@elevated-dev.com 
>> http://www.elevated-dev.com/ 
>> https://www.linkedin.com/in/scottribe/ 
>> 
>> (303) 722-0567 voice
>> 
>> 
>> 
>> 
>> 
>> 
>> ___
>> 
>> 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/koko%40highrolls.net 
>> 
>> 
>> This email sent to k...@highrolls.net 

___

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: Cocoa-dev Digest, Vol 12, Issue 299

2015-09-03 Thread Jonathan Prescott
How’s this?

#define SUPER_INIT  \
do {\
self = [super init];\
if (self == nil) return self;   \
}  while(1);

The do … while() construct is an old C/C++ trick used in macro programming to 
address issues with the pre-processor text insertion process.  Makes sure that 
an entire statement block is presented after the insertion is completed.  Most 
compilers these days optimize the test away.  Since you won’t be looking at it 
much during normal coding, you should not have to puzzle over the seeming 
nonsense of the code itself as you are using it.

Don’t forget the backslashes.

Jonathan

> On May 29, 2015, at 2:34 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
> Send Cocoa-dev mailing list submissions to
>   cocoa-dev@lists.apple.com
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   https://lists.apple.com/mailman/listinfo/cocoa-dev
> or, via email, send a message with subject or body 'help' to
>   cocoa-dev-requ...@lists.apple.com
> 
> You can reach the person managing the list at
>   cocoa-dev-ow...@lists.apple.com
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Cocoa-dev digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: Looking at self = [super init]. (Jean-Daniel Dupas)
>   2. Re: Looking at self = [super init]. (Quincey Morris)
>   3. Re: Looking at self = [super init]. (Simone Tellini)
>   4. Re: Looking at self = [super init]. (Alex Zavatone)
>   5. Re: NSDocumentTitlebarPopoverViewController zombie on
>  Yosemite (Matthew LeRoy)
>   6. Re: Looking at self = [super init]. (Alex Zavatone)
>   7. Re: Looking at self = [super init]. (Scott Ribe)
>   8. Re: Looking at self = [super init]. (Alex Zavatone)
>   9. Re: Looking at self = [super init]. (Jens Alfke)
>  10. Re: Looking at self = [super init]. (Scott Ribe)
>  11. Re: Looking at self = [super init]. (Alex Zavatone)
> 
> 
> --
> 
> Message: 1
> Date: Fri, 29 May 2015 19:40:58 +0200
> From: Jean-Daniel Dupas 
> To: Alex Zavatone 
> Cc: CocoaDev Cocoa-Dev 
> Subject: Re: Looking at self = [super init].
> Message-ID: <46526ba7-1515-47e9-af7d-e4c8b83c8...@xenonium.com>
> Content-Type: text/plain; charset=utf-8
> 
> 
>> Le 29 mai 2015 à 19:22, Alex Zavatone  a écrit :
>> 
>> Was just looking at good old object initialization and came across a stupid 
>> idea.
>> 
>> For most object initialization, we do this:
>> 
>> - (id)init {
>>   if (self = [super init]) {
>>   // Set up stuff here.
>>   // this could get long.
>>   }
>>   return self; 
>> }
>> 
>> in some cases, the set up within the parens could get pretty long.  In cases 
>> like that, I generally set up another method to handle that for 
>> organization, but if you're passing objects into into your init method, then 
>> you're passing more data again and the code could get less cleaner looking 
>> than it could be.
>> 
>> So, I thought, "why don't we check if self != [super init] and then 
>> immediately return if that is the case?"
>> 
>> That would change object initialization to this:
>> 
>> - (id)init {
>>   if (self != [super init]) {
>>   return;
>>   }
>> 
>>   // Set up stuff here.
>>   // We don't care if this gets long.
>>   // We really don't.  This could go on and on.
>>  
>>   return self; 
>> }
>> 
> 
> And now that a reread the code, it is patently wrong.
> 
> if (self = [super init]) is a assignment to self not a comparison.
> 
> If you want to do a fast path, you have to do
> 
> self = [super init];
> if (!self)
>   return nil;
> 
> 
> 
> 
> 
> 
> --
> 
> Message: 2
> Date: Fri, 29 May 2015 17:42:02 +
> From: Quincey Morris 
> To: Jean-Daniel Dupas 
> Cc: CocoaDev Cocoa-Dev 
> Subject: Re: Looking at self = [super init].
> Message-ID:
>   
> Content-Type: text/plain; charset=utf-8
> 
> On May 29, 2015, at 10:35 , Jean-Daniel Dupas  wrote:
>> 
>> You must at least returns nil in the fast path, else the compiler will not 
>> be happy.
> 
> Shame on you, Jean-Daniel, for not spotting the other error!
> 
> On May 29, 2015, at 10:22 , Alex Zavatone  wrote:
>> 
>>   if (self != [super init]) {
>>   return;
>>   }
> 
> The opposite of ‘if (self = [super init])’ isn’t ‘if (self != [super init])’. 
> The correct code is:
> 
>   self = [super init];
>   if (self == nil)
>   return nil;
> 
>> I'm not smoking crack here, am I?  
> 
> We only have your word for it.
> 
>> Does this actually seem like a good idea?
> 
> 
> Of course it’s a good idea (minus the two glaring bugs).
> 
> 
> 
> 
> 
> --
> 
> Message: 3
> Date: Fri, 29 May 2015 19:47:55 +0200
> From: Simone Tellini 
> To: CocoaDev Cocoa-Dev 
> Subject: Re: Looking at self = [super init].
> Message-ID: <0101be4f-ce00-4ef3-a538-a4f9cb40c...@tellini.info>

Re: Problem having a framework working in one of my targets (a screensaver)

2015-09-03 Thread Roland King
Perhaps it was only one - thought it was two - either way I learned most of 
what I knew about how dynamic loading works from that article + a bit of 
reading afterwards. 

So I have finally 15 minutes before Friday’s guests turn up, if I understand 
this rather long thread ..

You have a 3rd party library you’re linking into your app (a screensaver). When 
you link it in the screen save executable can’t find it. It can’t find it 
because the path it’s looking for it, which is buried in the load instructions 
in your binary, is @executable_path/../ but that’s not where 
you’re installing it, which is probably in ../Frameworks or similar. 

So where does the @executable_path/../ come from? That is the install 
name of the library you’re linking in, the 3rd party one. The install name is 
set when you build something and is a promise to the linker that you’re going 
to install the shared library/dynamic library/framework in that place, thats 
why it’s called the install name. So when whoever it was built it, built it, 
they specified @executable_path/../etc and that’s probably where most people 
install it, in the Frameworks directory just under their app in the bundle. 

I don’t know what the executable_path is for a screensaver, you’d think it was 
very much the same thing. So first simplest option is to work out what that is 
and then just put the library at the place it expects to be, 
@executable_path/../Frameworks/. As long as that’s within your 
bundle somewhere, trivial to do. You can even put it somewhere else and put a 
symlink in the bundle. 

If you don’t want to do that or for some reason can’t. The path put into your 
final binary is the ‘install name’ of the library from the library itself. You 
can’t rebuild the library but because this is a REALLY common problem which 
happens all the time, there exists an install_name_tool which lets you change 
it (as long as the new one is shorter than the old one and it helps if the 
developer was nice and padded the original one to leave lots of space). 

I believe the install name of an object can be found by running ‘otool -D 
’, if you do that on the library you’re linking, it  should say 
@executable_path/… 

If you want to change it to something like @rpath/whatever then

install_name_tool -id @rpath/whatever 

You run that on the original 3rd party library, it changes the install name 
compiled in to one of your choosing, and you can have whatever you like and 
then add whatever search paths to your binary you want which will then find it. 
@rpath/ is a good choice because you can always add a search path which will 
find it wherever you put it (and change it for different apps). 

So change the install name in the 3rd party library, re-link your app, the load 
commands should now reflect the install name you just chose. Job done. 

> On 3 Jul 2015, at 18:28, Juanjo Conti  wrote:
> 
> Sorry, Roland talked about the 2 articles on install_name_tool.
> 
> On Fri, Jul 3, 2015 at 7:26 AM, Juanjo Conti  > wrote:
> Yes, but he doesn't explain install_name_tool there. You said there were 2 
> articles about install_name_tool.
> 
> On Fri, Jul 3, 2015 at 6:56 AM, Kevin Meaney  > wrote:
> First result is the mike ash article I included in my first e-mail to this 
> thread.
> 
> Kevin
> 
>> On 3 Jul 2015, at 10:48, Roland King mailto:r...@rols.org>> 
>> wrote:
>> 
>> www.google.com 
>> 
>> "mike ash install_name_tool”
>> 
>> 
>>> On 3 Jul 2015, at 17:45, Juanjo Conti >> > wrote:
>>> 
>>> Could you point me to that articles please?
>>> 
>>> On Fri, Jul 3, 2015 at 6:38 AM, Roland King >> > wrote:
>>> 
 On 3 Jul 2015, at 17:29, Kevin Meaney >>> > wrote:
 
 I’m not sure either of those will work.
 
 On 3 Jul 2015, at 10:07, Roland King >>> > wrote:
> 
> There’s two other options
> 
> 1) Use install_name_tool to change the name in the library to the one you 
> want. If it’s shorter, and it should be as the install name in that 
> library seems rather long, you can do that
 
 I don’t think modifying the Installation Directory will work. I’ve checked 
 my framework using otool as Juanjo mentioned he did. Building my Framework 
 I’ve set Installation Directory to @rpath but the name I see using otool 
 still says @executable_path/… etc. so there is some information set 
 elsewhere which informs the linker. So I don’t think editing the path 
 using install_name_tool will help.
>>> 
>>> I think it’ll work just fine, that’s what install_name_tool is there for, 
>>> that’s what I’ve used it for and many others too. You change the install 
>>> name of the thing you’re linking to before you link it and it shows up in a 
>>> the right place in the final executable. 
>>> 
>>> I believe Mike Ash did a series of two gr

Puzzling memory creep

2015-09-03 Thread Richard Kennaway
I've written an iOS app that, according to Instruments, seems to very slowly 
allocate more and more memory over time, although I can see no reason for it.  
After starting it, and letting it settle down, I see in the Allocations tool 
several entries in the "#Persistent" column creeping upwards.  Typically, I see 
an item "CFArray (mutable-variable)" incrementing its #Persistent once a 
second, and an item "Malloc 32 Bytes" incrementing by 2 every second.  The 
Leaks tool shows nothing.  Taking Generation snapshots at intervals of a second 
or two shows the steady accumulation of small allocations, described as 
.

I'm using XCode 6.4 and running this in the simulator for iPhone 6 and iOS 8.4. 
 I've also tried the iPad2 and iOS 8.4 with similar results, although there the 
item that ticks up and up is "Malloc 64 bytes", at a rate of about 1 KB every 5 
seconds.  The project is compiled with ARC turned on.  The high water mark of 
total memory use displayed in XCode increases by a megabyte in something over 
an hour and an overnight run shows no sign of it stopping.

But I cannot see what is causing this.  It's a very small app, and if I let it 
run without interacting with it, the only code it executes is the following 
method of the single view controller, invoked by an NSTimer once a second to 
update a display of the time.

- (void)updateTime {
NSDate *now = [NSDate date];
double seconds = [now timeIntervalSinceReferenceDate];
double intseconds = round(seconds);
now = [NSDate dateWithTimeIntervalSinceReferenceDate:intseconds];

[dateFormatter setDateFormat:
[NSDateFormatter dateFormatFromTemplate:@"jjmmss" options: 0 locale: 
thelocale]];
[[self timestring] setText: [dateFormatter stringFromDate: now]];

[dateFormatter setDateFormat:
[NSDateFormatter dateFormatFromTemplate:@"EEEdMMM" options: 0 locale: 
thelocale]];
[[self daystring] setText: [dateFormatter stringFromDate: now]];

[dateFormatter setDateFormat:
[NSDateFormatter dateFormatFromTemplate:@"" options: 0 locale: 
thelocale]];
[[self yearstring] setText: [dateFormatter stringFromDate: now]];
}

timestring, daystring, and yearstring are properties of my ViewController class 
connected to labels in the storyboard:

@property (weak, nonatomic) IBOutlet UILabel *timestring;
@property (weak, nonatomic) IBOutlet UILabel *daystring;
@property (weak, nonatomic) IBOutlet UILabel *yearstring;

dateFormatter and thelocale are private instance variables, initialised once in 
viewDidLoad().   I've also tried versions where these are variables local to 
updateTime(), and where "now" is an instance variable, but moving these around 
gives the same results.  I've also tried, with equal lack of effect, splitting 
up some of the one-liners into things like:

NSString *thestring = [dateFormatter stringFromDate: now];
[[self timestring] setText: thestring];

When the app is in the background it does nothing (it invalidates the NSTimer 
and sets the instance variable holding it to NULL), and Allocations reports no 
activity.

What is causing this problem?  Instruments says the Responsible Library is 
libdispatch.dylib, and the Responsible Caller is 
_dispatch_continuation_alloc_from_heap.  The names suggest that this may be 
nothing to do with the code above.  Google turns up a small number of queries 
regarding memory leaks with similar symptoms, but no answers.

-- 
Richard Kennaway


___

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

Leakage from UILabel?

2015-09-03 Thread Richard Kennaway
I've run into a strange problem with a memory leak, apparently associated with 
setting the text of UILabels.  Googling for /UILabel memory leak/ shows several 
other people having come up against similar problems, both with and without 
ARC, but no solution.

My app (built with ARC) uses a timer to update a display of various components 
of the time once a second.  In Instruments, the Allocations tool reports a slow 
but steady increase in persistent memory allocations of a single size, although 
Leaks reports nothing.  I've tried the iPad2 and iPhone6 simulators, both with 
iOS 8.4.  Both show this leakage, although at different rates and with 
allocations of different sizes.

There are three UILabels that the app updates on every timer event. Commenting 
out the three lines of code that look like this:

[[self someUILabel] setText: resultOfADateFormatter];

where someUILabel is the name of one of the three UILabel properties, removes 
the leak.  (All of the code that gets the date and formats it in three 
different ways is still enabled.)  Enabling any one of those three lines brings 
the leak back.  In the background, the app does not update the labels or 
receive timer events, and does not leak.

The labels are declared as properties of my single view controller (by code 
automatically generated by Xcode when I set up the storyboard) as:

@property (weak, nonatomic) IBOutlet UILabel *timestring;
@property (weak, nonatomic) IBOutlet UILabel *daystring;
@property (weak, nonatomic) IBOutlet UILabel *yearstring;

The rate of leakage is the same whether I am updating only one label on each 
timer event or all three. If I reduce the timer interval from 1 second to 0.1 
seconds, the rate of leakage increases by a factor of about 6. Definitely less 
than 10.

The analyzer reports nothing, and building and validating an archive reports 
nothing.

Is this a problem I can fix?  Or is it a bug in Instruments, in the simulators, 
or in iOS?

-- Richard Kennaway

-- 
Richard Kennaway, rich...@kennaway.org.uk, http://www.cmp.uea.ac.uk/~jrk/
School of Computing Sciences,
University of East Anglia, Norwich NR4 7TJ, U.K.


___

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: Impossible leak warning in OS X init method

2015-09-03 Thread Bill Cheeseman
On Aug 29, 2015, at 2:54 PM, Jens Alfke  wrote:

Is it possible that, in removing details from your code, you left out some 
detail that’s what’s causing the warning? Do you mind posting the actual 
method, copied/pasted verbatim from Xcode?

You asked for it! -- sorry about the formatting.

- (id)initWithElementRef:(AXUIElementRef)uiElementRef delegate:(id)aDelegate {
if ((self = [super init])) {
if (uiElementRef != NULL) {
CFTypeRef role = NULL;
AXError err = 
AXUIElementCopyAttributeValue(uiElementRef, kAXRoleAttribute, &role);
if (err == kAXErrorSuccess) { // AXRole attribute of 
uiElementRef was successfully copied
if (CFEqual(role, kAXApplicationRole)) {
pid_t pid = 0;
AXUIElementGetPid(uiElementRef, &pid);
id newSelf = [[[PFApplicationUIElement 
applicationUIElementClass] alloc] initWithPid:pid delegate:aDelegate];
[self release];
self = newSelf;
} else {
elementRef = 
(AXUIElementRef)CFRetain(uiElementRef); // Save uiElementRef in this element's 
elementRef instance variable; it is CFReleased in -invalidate or -dealloc.

[self setDelegate:aDelegate];
[self setElementInfo:[self 
cacheElementInfo]];

[self registerDestructionObserver];
isValid = YES;
}

/*if (role) */CFRelease(role);

} else { // could not copy AXRole attribute of 
uiElementRef
if (err == kAXErrorInvalidUIElement) { // 
uiElementRef is destroyed
// Return a PFUIElement object without 
an elementInfo cache.
elementRef = 
(AXUIElementRef)CFRetain(uiElementRef); // Save uiElementRef in this element's 
elementRef instance variable; it is CFReleased in -invalidate or -dealloc.
isValid = YES;
} else {
[self release];
self = nil;
#ifdef PFA_DEBUG
NSLog(@"PFUIElement 
-initWithElementRef:delegate: method, error %@ while getting the AXRole 
attribute of a newly-created UI element.", [PFUIElement 
descriptionForError:err]);
#endif
}
}
} else {
[self release];
self = nil;
}
}
return self;
}

- (PFUIElement *)elementAtPoint:(NSPoint)point {
AXUIElementRef ref = NULL;
AXError err = AXUIElementCopyElementAtPosition([self elementRef], 
point.x, point.y, &ref);
if (err == kAXErrorSuccess) {
PFUIElement *element = [[PFUIElement alloc] 
initWithElementRef:ref delegate:[self delegate]];
if (ref) CFRelease(ref);
return [element autorelease];
}

// Log errors.
#ifdef PFA_DEBUG
NSLog(@"PFUIElement -elementAtPoint: instance method, error %@ for 
point %@.", [PFUIElement descriptionForError:err], NSStringFromPoint(point));
#endif

if ([[self delegate] 
respondsToSelector:@selector(PFUIElementReportError:)]) {
NSString *descriptionPrefix = 
NSLocalizedStringFromTableInBundle(@"Could not read the screen", 
@"PFAssistiveErrors", [NSBundle bundleForClass:[PFUIElement class]], 
@"Description prefix for -[PFUIElement elementAtPoint:]");
NSString *failureReasonSuffix = [NSString 
stringWithFormat:NSLocalizedStringFromTableInBundle(@"while reading the screen 
at %@", @"PFAssistiveErrors", [NSBundle bundleForClass:[PFUIElement class]], 
@"Failure reason suffix for -[PFUIElement elementAtPoint:]"), 
NSStringFromPoint(point)];
NSDictionary* userInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:descriptionPrefix, 
PFAssistiveDescriptionPrefixErrorKey, failureReasonSuffix, 
PFAssistiveFailureReasonSuffixErrorKey, self, PFAssistiveElementErrorKey, 
[NSNumber numberWithBool:NO], PFAssistiveIsExpectedErrorKey, NULL];
[[self delegate] PFUIElementReportError:[PFAssistiveError 
errorWithDomain:PFAssistiveErrorDomain code:err userInfo:userInfo]];
}

return nil;
}

-- 

Bill Cheeseman - wjcheese...@comcast.net
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator com

How to intercept the space key in an NSTextField

2015-09-03 Thread Frank Bitterlich
I’m having trouble finding a solution for a seemingly simple problem.

I need an NSTextField that will „catch“ the space key, and instead of adding a 
blank to its content, will trigger something different.

The reason: I have a window where I need to trigger starting/stopping of a 
clock by pressing the spacebar, regardless of whether a text field currently 
has the focus or not.

Subclassing NSTextField and implementing -keyDown dow not work; it is never 
called. (-keyUp, OTOH, is called - but that does not allow me to „intercept“ 
and filter out the space character. Or does it?)

This…

  NSText *fieldEditor = [self.view.window fieldEditor:YES forObject:nil];
  fieldEditor.delegate = self;

… does not appear to help either; the delegate method I was hoping for, 
-textDidChange, is not called either.

Somebody on StackOverflow suggested to „return my own field editor“, but based 
on my experiments it seems to be hugely complicated to supply your own NSText 
subclass there.

I thought it would be simple, because a long time ago I wrote a similar app in 
REAL Studio, which did allow me to subclass the Text Field class and implement 
a keydown event to do this.

Any suggestions?

Thanks,
 Frank+++


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to intercept the space key in an NSTextField

2015-09-03 Thread Frank Bitterlich
I’m having trouble finding a solution for a seemingly simple problem.

I need an NSTextField that will „catch“ the space key, and instead of adding a 
blank to its content, will trigger something different.

The reason: I have a window where I need to trigger starting/stopping of a 
clock by pressing the spacebar, regardless of whether a text field currently 
has the focus or not.

Subclassing NSTextField and implementing -keyDown dow not work; it is never 
called. (-keyUp, OTOH, is called - but that does not allow me to „intercept“ 
and filter out the space character. Or does it?)

This…

 NSText *fieldEditor = [self.view.window fieldEditor:YES forObject:nil];
 fieldEditor.delegate = self;

… does not appear to help either; the delegate method I was hoping for, 
-textDidChange, is not called either.

Somebody on StackOverflow suggested to „return my own field editor“, but based 
on my experiments it seems to be hugely complicated to supply your own NSText 
subclass there.

I thought it would be simple, because a long time ago I wrote a similar app in 
REAL Studio, which did allow me to subclass the Text Field class and implement 
a keydown event to do this.

Any suggestions?

Thanks,
Frank+++


___

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: Cocoa-dev Digest, Vol 12, Issue 355

2015-09-03 Thread Андрей Мишанин
You are accessing UI Kit objects from a background thread which is forbidden.

Sent from my iPad 5

> On 22 Jun 2015, at 13:16, cocoa-dev-requ...@lists.apple.com wrote:
> 
> Here is the stack-tace of crashed thread:
> 
> Thread : Crashed: com.apple.root.utility-qos
___

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: Subclassing a Subclass of SBApplication

2015-09-03 Thread Conrad Shultz
Note that this is a category, not a class extension.

-Conrad


> On Jun 30, 2015, at 6:19 AM, Jean-Daniel Dupas  wrote:
> 
> Using class extension is probably a safe way to extends such classes.
> 
> @interface SXPhotoshopApplication (MyExtension)
> 
> - (void)myWrapper;
> 
> @end
> 
> 
>> Le 29 juin 2015 à 13:54, Dave > > a écrit :
>> 
>> Hi,
>> 
>> I’m using the Scripting Bridge, and I was wondering if it ok to subclass 
>> SBXXX classes. Basically, I have a header file generated by the “sdp” tool 
>> with definitions as below:
>> 
>> And I’d like to subclass this to add some extra wrapping to hide some of the 
>> nastiness from the rest of the app and provide a tighter integration with 
>> the current app handling. I remember reading somewhere that these classes 
>> shouldn’t be subclassed, but I can’t seem to find it again now.
>> 
>> Thanks a lot
>> Dave
>> 
>> -
>> 
>> @interface SXPhotoshopApplication : SBApplication
>> 
>> - (SBElementArray *) documents;
>> - (SBElementArray *) fonts;
>> - (SBElementArray *) notifiers;
>> 
>> @property (copy, readonly) NSNumber *bestType;  // the best type for the 
>> object's value
>> @property (copy, readonly) NSNumber *defaultType;  // the default type for 
>> the object's value
>> @property (copy) NSDictionary *properties;  // all of this object's 
>> properties returned in a single record
>> @property (copy) SXPhotoshopColorValue *backgroundColor;
>> @property (copy, readonly) NSString *build;  // the build number of Adobe 
>> Photoshop application
>> @property (copy) id colorSettings;  // name of selected color settings' set
>> @property (copy) SXPhotoshopDocument *currentDocument;  // the frontmost 
>> document
>> @property SXPhotoshopE050 displayDialogs;  // controls whether or not 
>> Photoshop displays dialogs
>> @property (copy) SXPhotoshopColorValue *foregroundColor;
>> @property (readonly) double freeMemory;  // the amount of unused memory 
>> available to Adobe Photoshop
>> @property (readonly) BOOL frontmost;  // is Photoshop the frontmost 
>> application?
>> @property (copy, readonly) NSString *locale;  // language locale of 
>> application
>> @property (copy, readonly) NSArray *macintoshFileTypes;  // list of file 
>> image types Photoshop can open
>> @property (copy, readonly) NSString *name;  // the application's name
>> @property BOOL notifiersEnabled;  // enable or disable all notifiers
>> @property (copy, readonly) id preferencesFolder;  // full path to the 
>> preferences folder
>> @property (copy, readonly) NSArray *recentFiles;  // files in the recent 
>> file list
>> @property (copy, readonly) NSString *scriptingBuildDate;  // the build date 
>> of the scripting interface
>> @property (copy, readonly) NSString *scriptingVersion;  // the version of 
>> the Scripting interface
>> @property (copy, readonly) SXPhotoshopSettingsObject *settings;  // 
>> preference settings
>> @property (copy, readonly) NSString *systemInformation;  // system 
>> information of the host application and machine
>> @property (copy, readonly) NSString *version;  // the version of Adobe 
>> Photoshop application
>> @property (copy, readonly) NSArray *windowsFileTypes;  // list of file image 
>> extensions Photoshop can open
>> 
>> - (void) AETEScriptsScriptsJavaScriptNameName:(NSString *)JavaScriptNameName 
>> JavaScriptFileFile:(NSString *)JavaScriptFileFile 
>> JavaScriptTextText:(NSString *)JavaScriptTextText 
>> JavaScriptDebuggingDebugging:(BOOL)JavaScriptDebuggingDebugging 
>> JavaScriptMessageMessage:(NSString *)JavaScriptMessageMessage;  // Photoshop 
>> scripting support plug-in
>> - (void) open:(id)x as:(SXPhotoshopOpAs)as 
>> withOptions:(SXPhotoshopOpenOptions *)withOptions 
>> showingDialogs:(SXPhotoshopE050)showingDialogs 
>> smartObject:(BOOL)smartObject;  // open the specified document file(s)
>> - (void) print:(id)x sourceSpace:(SXPhotoshopE945)sourceSpace 
>> printSpace:(NSString *)printSpace intent:(SXPhotoshopE130)intent 
>> blackpointCompensation:(BOOL)blackpointCompensation;  // print the specified 
>> object(s)
>> - (void) quit;  // quit the application
>> - (NSArray *) PhotoshopOpenDialog;  // use the Photoshop open dialog to 
>> select files
>> - (NSString *) batch:(NSString *)x fromFiles:(NSArray *)fromFiles 
>> from:(NSString *)from withOptions:(SXPhotoshopBatchOptions *)withOptions;  
>> // run the batch automation routine
>> - (NSString *) createPDFPresentationFromFiles:(NSArray *)fromFiles 
>> toFile:(id)toFile withOptions:(SXPhotoshopPresentationOptions *)withOptions; 
>>  // create a PDF presentation file
>> - (NSString *) createContactSheetFromFiles:(NSArray *)fromFiles 
>> withOptions:(SXPhotoshopContactSheetOptions *)withOptions;  // create a 
>> contact sheet from multiple files
>> - (NSString *) createPhotoGalleryFromFolder:(id)fromFolder 
>> toFolder:(id)toFolder withOptions:(SXPhotoshopGalleryOptions *)withOptions;  
>> // Creates a web photo gallery
>> - (NSString *) cre

Problem having a framework working in one of my targets (a screensaver)

2015-09-03 Thread Juanjo Conti
Hi!

I've an XCode Swift project with 2 targets, an traditional app and a
screensaver. I want to use a framework in both (I've tried with at least 2
frameworks with no luck).

In the app they work ok but in the screensaver, despite that I'm able to
compile (I have a bridging file with the appropriate importe and I have the
framework copied and linked, see attachment) when the screensaver runs it
crash with this error in Console:

Jul  1 16:33:15 ironbird.local ScreenSaverEngine[60006]: Error loading
/Users/juanjo/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja:
 dlopen(/Users/juanjo/Library/Screen
Savers/Ninja.saver/Contents/MacOS/Ninja, 265): Library not loaded:
@executable_path/../Frameworks/Paddle.framework/Versions/A/Paddle
  Referenced from: /Users/juanjo/Library/Screen
Savers/Ninja.saver/Contents/MacOS/Ninja
  Reason: image not found

Can someone help me to solve the problem or at least to debug it? If I
search for the error I find people that forgotten to either copy or link
the framework, which is not my case.

Thanks in advance!

-- 

Juanjo Conti http://goog_2023646312>@carouselapps.com
>

Software Engineer - Carousel Apps 

-- 
Carousel Apps Limited, registered in England & Wales with registered number 
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
App Ltd or any of its subsidiary, holding or affiliated companies or 
entities (together "Watu") is confidential and may be privileged or 
otherwise protected. If you receive it in error please inform us and then 
delete it from your system. You should not copy it or disclose its contents 
to anyone. Messages sent to and from Watu may be monitored to ensure 
compliance with our internal policies and to protect our business. Emails 
are not secure and cannot be guaranteed to be error free. Anyone who 
communicates with us by email is taken to accept these risks.
___

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: Problem having a framework working in one of my targets (a screensaver)

2015-09-03 Thread Juanjo Conti
Like this? http://i.imgur.com/4L974ZH.png

The problem continues. I'll read the article. Thanks.

On Thu, Jul 2, 2015 at 6:22 PM, Contact Zukini 
wrote:

> Hi Juanjo,
>
> I had similar issues when wanting to load a framework. My specific problem
> was loading the framework in an application that was then being loaded when
> I was using IBDesignable.
>
> This article by Mike Ash was extremely helpful at understanding what was
> happening.
>
>
> https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
>
> I think your issue is that when linking your framework you need to set the
> installation directory path to @rpath. You have done half of what you need
> by setting Runpath Search Path to loader_path/../Frameworks. But that also
> means that your application target will have to do the same thing.
>
> I hope that helps.
>
> Kevin
>
> But then you will need to update your application target.
>
> On 2 Jul 2015, at 20:12, Juanjo Conti  wrote:
>
> More on this. It I change the Runpath Search Path for the target in
> question to use loader_path instead of executable_path, the error still
> mention executable_path. Why?
>
> http://i.imgur.com/yIoTWNe.png
>
> On Wed, Jul 1, 2015 at 5:04 PM, Juanjo Conti 
> wrote:
>
> Hi!
>
> I've an XCode Swift project with 2 targets, an traditional app and a
> screensaver. I want to use a framework in both (I've tried with at least 2
> frameworks with no luck).
>
> In the app they work ok but in the screensaver, despite that I'm able to
> compile (I have a bridging file with the appropriate importe and I have the
> framework copied and linked, see http://imgur.com/yniEY1b) when the
> screensaver runs it crash with this error in Console:
>
> Jul  1 16:33:15 ironbird.local ScreenSaverEngine[60006]: Error loading
> /Users/juanjo/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja:
> dlopen(/Users/juanjo/Library/Screen
> Savers/Ninja.saver/Contents/MacOS/Ninja, 265): Library not loaded:
> @executable_path/../Frameworks/Paddle.framework/Versions/A/Paddle
>  Referenced from: /Users/juanjo/Library/Screen
> Savers/Ninja.saver/Contents/MacOS/Ninja
>  Reason: image not found
>
> Can someone help me to solve the problem or at least to debug it? If I
> search for the error I find people that forgotten to either copy or link
> the framework, which is not my case.
>
> Thanks in advance!
>
> --
>
> Juanjo Conti http://goog_2023646312>@carouselapps.com
> >
>
> Software Engineer - Carousel Apps 
>
>
>
>
> --
>
> Juanjo Conti http://goog_2023646312>@carouselapps.com
> >
>
> Software Engineer - Carousel Apps 
>
> --
> Carousel Apps Limited, registered in England & Wales with registered number
>
> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
>
> App Ltd or any of its subsidiary, holding or affiliated companies or
> entities (together "Watu") is confidential and may be privileged or
> otherwise protected. If you receive it in error please inform us and then
> delete it from your system. You should not copy it or disclose its contents
>
> to anyone. Messages sent to and from Watu may be monitored to ensure
> compliance with our internal policies and to protect our business. Emails
> are not secure and cannot be guaranteed to be error free. Anyone who
> communicates with us by email is taken to accept these risks.
> ___
>
> 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/ktam%40yvs.eu.com
>
> This email sent to k...@yvs.eu.com
>
>
>


-- 

Juanjo Conti http://goog_2023646312>@carouselapps.com
>

Software Engineer - Carousel Apps 

-- 
Carousel Apps Limited, registered in England & Wales with registered number 
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
App Ltd or any of its subsidiary, holding or affiliated companies or 
entities (together "Watu") is confidential and may be privileged or 
otherwise protected. If you receive it in error please inform us and then 
delete it from your system. You should not copy it or disclose its contents 
to anyone. Messages sent to and from Watu may be monitored to ensure 
compliance with our internal policies and to protect our business. Emails 
are not secure and cannot be guaranteed to be error free. Anyone who 
communicates with us by email is taken to accept these risks.
___

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-admin

Re: Problem having a framework working in one of my targets (a screensaver)

2015-09-03 Thread Juanjo Conti
If I use install_name_tool to change the path where the image is looked for
for a absolute path, I make the screensaver run.

On Thu, Jul 2, 2015 at 8:22 PM, Juanjo Conti 
wrote:

> Like this? http://i.imgur.com/4L974ZH.png
>
> The problem continues. I'll read the article. Thanks.
>
> On Thu, Jul 2, 2015 at 6:22 PM, Contact Zukini  > wrote:
>
>> Hi Juanjo,
>>
>> I had similar issues when wanting to load a framework. My specific
>> problem was loading the framework in an application that was then being
>> loaded when I was using IBDesignable.
>>
>> This article by Mike Ash was extremely helpful at understanding what was
>> happening.
>>
>>
>> https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
>>
>> I think your issue is that when linking your framework you need to set
>> the installation directory path to @rpath. You have done half of what you
>> need by setting Runpath Search Path to loader_path/../Frameworks. But that
>> also means that your application target will have to do the same thing.
>>
>> I hope that helps.
>>
>> Kevin
>>
>> But then you will need to update your application target.
>>
>> On 2 Jul 2015, at 20:12, Juanjo Conti  wrote:
>>
>> More on this. It I change the Runpath Search Path for the target in
>> question to use loader_path instead of executable_path, the error still
>> mention executable_path. Why?
>>
>> http://i.imgur.com/yIoTWNe.png
>>
>> On Wed, Jul 1, 2015 at 5:04 PM, Juanjo Conti 
>> wrote:
>>
>> Hi!
>>
>> I've an XCode Swift project with 2 targets, an traditional app and a
>> screensaver. I want to use a framework in both (I've tried with at least 2
>> frameworks with no luck).
>>
>> In the app they work ok but in the screensaver, despite that I'm able to
>> compile (I have a bridging file with the appropriate importe and I have
>> the
>> framework copied and linked, see http://imgur.com/yniEY1b) when the
>> screensaver runs it crash with this error in Console:
>>
>> Jul  1 16:33:15 ironbird.local ScreenSaverEngine[60006]: Error loading
>> /Users/juanjo/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja:
>> dlopen(/Users/juanjo/Library/Screen
>> Savers/Ninja.saver/Contents/MacOS/Ninja, 265): Library not loaded:
>> @executable_path/../Frameworks/Paddle.framework/Versions/A/Paddle
>>  Referenced from: /Users/juanjo/Library/Screen
>> Savers/Ninja.saver/Contents/MacOS/Ninja
>>  Reason: image not found
>>
>> Can someone help me to solve the problem or at least to debug it? If I
>> search for the error I find people that forgotten to either copy or link
>> the framework, which is not my case.
>>
>> Thanks in advance!
>>
>> --
>>
>> Juanjo Conti http://goog_2023646312>@carouselapps.com
>> >
>>
>> Software Engineer - Carousel Apps 
>>
>>
>>
>>
>> --
>>
>> Juanjo Conti http://goog_2023646312>@carouselapps.com
>> >
>>
>> Software Engineer - Carousel Apps 
>>
>> --
>> Carousel Apps Limited, registered in England & Wales with registered
>> number
>> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
>> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
>>
>> App Ltd or any of its subsidiary, holding or affiliated companies or
>> entities (together "Watu") is confidential and may be privileged or
>> otherwise protected. If you receive it in error please inform us and then
>>
>> delete it from your system. You should not copy it or disclose its
>> contents
>> to anyone. Messages sent to and from Watu may be monitored to ensure
>> compliance with our internal policies and to protect our business. Emails
>>
>> are not secure and cannot be guaranteed to be error free. Anyone who
>> communicates with us by email is taken to accept these risks.
>> ___
>>
>> 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/ktam%40yvs.eu.com
>>
>> This email sent to k...@yvs.eu.com
>>
>>
>>
>
>
> --
>
> Juanjo Conti http://goog_2023646312>@carouselapps.com
> >
>
> Software Engineer - Carousel Apps 
>
>


-- 

Juanjo Conti http://goog_2023646312>@carouselapps.com
>

Software Engineer - Carousel Apps 

-- 
Carousel Apps Limited, registered in England & Wales with registered number 
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
App Ltd or any of its subsidiary, holding or affiliated companies or 
entities (together "Watu") is confidential and may be privileged or 
otherwise protected. If you receive it in error please inform us and then 
delete it from your system. You should not copy it or disclose its contents 
to anyone. Messages sent to and from Watu 

Re: Problem having a framework working in one of my targets (a screensaver)

2015-09-03 Thread Juanjo Conti
I think ScreensaverNinja target does not affect Saver target.

The Saver target builds a screen saver (a plugin in terms of XCode)
I'm trying to use the Paddle framework in both, a desktop app
(ScreensaverNinja target) and in the screensaver (Saver target).

In the desktop app works and in the screensaver not.

Was I clear? Is your reply still valid? What else should I try?

Thanks,

On Fri, Jul 3, 2015 at 4:46 AM, Kevin Meaney  wrote:

> You need to set the Runpath Search paths in your ScreensaverNinja target
> to @loader_path/../Frameworks not the target Saver which I’m assuming is
> building your framework.
>
> I’m assuming here your ScreenSaver is built from the ScreensaverNinja
> target (the one with the application icon).
>
> Kevin
>
> On 3 Jul 2015, at 00:22, Juanjo Conti  wrote:
>
> Like this? http://i.imgur.com/4L974ZH.png
>
> The problem continues. I'll read the article. Thanks.
>
> On Thu, Jul 2, 2015 at 6:22 PM, Contact Zukini  > wrote:
>
>> Hi Juanjo,
>>
>> I had similar issues when wanting to load a framework. My specific
>> problem was loading the framework in an application that was then being
>> loaded when I was using IBDesignable.
>>
>> This article by Mike Ash was extremely helpful at understanding what was
>> happening.
>>
>>
>> https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
>>
>> I think your issue is that when linking your framework you need to set
>> the installation directory path to @rpath. You have done half of what you
>> need by setting Runpath Search Path to loader_path/../Frameworks. But that
>> also means that your application target will have to do the same thing.
>>
>> I hope that helps.
>>
>> Kevin
>>
>> But then you will need to update your application target.
>>
>> On 2 Jul 2015, at 20:12, Juanjo Conti  wrote:
>>
>> More on this. It I change the Runpath Search Path for the target in
>> question to use loader_path instead of executable_path, the error still
>> mention executable_path. Why?
>>
>> http://i.imgur.com/yIoTWNe.png
>>
>> On Wed, Jul 1, 2015 at 5:04 PM, Juanjo Conti 
>> wrote:
>>
>> Hi!
>>
>> I've an XCode Swift project with 2 targets, an traditional app and a
>> screensaver. I want to use a framework in both (I've tried with at least 2
>> frameworks with no luck).
>>
>> In the app they work ok but in the screensaver, despite that I'm able to
>> compile (I have a bridging file with the appropriate importe and I have
>> the
>> framework copied and linked, see http://imgur.com/yniEY1b) when the
>> screensaver runs it crash with this error in Console:
>>
>> Jul  1 16:33:15 ironbird.local ScreenSaverEngine[60006]: Error loading
>> /Users/juanjo/Library/Screen Savers/Ninja.saver/Contents/MacOS/Ninja:
>> dlopen(/Users/juanjo/Library/Screen
>> Savers/Ninja.saver/Contents/MacOS/Ninja, 265): Library not loaded:
>> @executable_path/../Frameworks/Paddle.framework/Versions/A/Paddle
>>  Referenced from: /Users/juanjo/Library/Screen
>> Savers/Ninja.saver/Contents/MacOS/Ninja
>>  Reason: image not found
>>
>> Can someone help me to solve the problem or at least to debug it? If I
>> search for the error I find people that forgotten to either copy or link
>> the framework, which is not my case.
>>
>> Thanks in advance!
>>
>> --
>>
>> Juanjo Conti http://goog_2023646312>@carouselapps.com
>> >
>>
>> Software Engineer - Carousel Apps 
>>
>>
>>
>>
>> --
>>
>> Juanjo Conti http://goog_2023646312>@carouselapps.com
>> >
>>
>> Software Engineer - Carousel Apps 
>>
>> --
>> Carousel Apps Limited, registered in England & Wales with registered
>> number
>> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
>> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
>>
>> App Ltd or any of its subsidiary, holding or affiliated companies or
>> entities (together "Watu") is confidential and may be privileged or
>> otherwise protected. If you receive it in error please inform us and then
>>
>> delete it from your system. You should not copy it or disclose its
>> contents
>> to anyone. Messages sent to and from Watu may be monitored to ensure
>> compliance with our internal policies and to protect our business. Emails
>>
>> are not secure and cannot be guaranteed to be error free. Anyone who
>> communicates with us by email is taken to accept these risks.
>> ___
>>
>> 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/ktam%40yvs.eu.com
>>
>> This email sent to k...@yvs.eu.com
>>
>>
>>
>
>
> --
> Juanjo Conti http://goog_2023646312/>@carouselapps.com
> >
> Software Engineer - Carousel Apps 
>
>
> Carousel Apps Limited, registered in England & Wales with registered

Forcing an NSScroller to think its scroll document has a different width. Possible?

2015-09-03 Thread Charles Constant
Hi ladies and gentlemen,

I'm trying to make an infinite scrollview, but I've gotten stuck in the mud.

What I want to do is split, when the knob(thumb) reaches a point beyond the
right edge, is have it split into two, so that you see its right side,
peeking in from the left edge. That's the part I've got working.

The part I'm having problems with is the document width. To give the
illusion of the view being infinite, while still scrolling smoothly, I need
to add a duplicate section. When the user scrolls left beyond 0, I need to
copy the right side of the document, and a when he/she scrolls being the
right side, I need to copy the left side to the rightmost portion of the
screen.

So (at long last) the problem is: I need the document to be oversize (e.g.:
120% the width of its content with 20% duplicated) but in order for my
NSScroller to function the way I want, I need the NSScroller to still see
the width as 100%. I thought overriding the x position in "rectForPart"
would suffice, but it doesn't. It *looks* correct, sure enough, but when I
try to drag the knob, my clicks and drags no longer match up with the
visual location of the knob.

I'd greatly appreciate any advice you may have. It would be great if there
were a method I could override to tell the computer where the actual hit
area is, but I figured that would be "rectForPart" and it's apparently not
:(

Cheers,

Charles
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Puzzling memory creep

2015-09-03 Thread Scott Ribe
On Aug 14, 2015, at 2:29 PM, Richard Kennaway  wrote:
> 
> the Responsible Caller is _dispatch_continuation_alloc_from_heap

Sure sounds like something that *might* underly the implementation of NSTimer.

Quick experiment: change the delay in your NSTimer creation from 1.0 to 0.1 and 
see what happens to memory usage ;-)

Also, you are aware that you can get the full stack trace for any allocation, 
right? (You may have to set an option in the instrument before you start the 
run, I don't remember.)

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice






___

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: Puzzling memory creep

2015-09-03 Thread Quincey Morris
Two thoughts about this.

1. Are you sure that ‘updateTime’ is running on the main thread? It needs to 
be, since you’re updating the UI directly from this code.

2. The code inside ‘updateTime’ is very self-contained, so it seems easy to try 
a divide-and-conquer strategy. What happens if you remove all the code, so that 
the method consists of empty braces? What happens if you don’t format anything, 
but simply set the UILabel fields to a constant string each time?

My guess is that the problem will persist regardless of what the method does, 
and the problem is elsewhere. But at least it would be useful to rule this 
method’s code out, if you can.


___

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: Puzzling memory creep

2015-09-03 Thread Cosmo
Is there any chance you have Zombie checking turned on in your scheme settings? 
In my experience that might account for what you’ve described.

> On Aug 14, 2015, at 1:29 PM, Richard Kennaway  wrote:
> 
> I've written an iOS app that, according to Instruments, seems to very slowly 
> allocate more and more memory over time, although I can see no reason for it. 
>  After starting it, and letting it settle down, I see in the Allocations tool 
> several entries in the "#Persistent" column creeping upwards.  Typically, I 
> see an item "CFArray (mutable-variable)" incrementing its #Persistent once a 
> second, and an item "Malloc 32 Bytes" incrementing by 2 every second.  The 
> Leaks tool shows nothing.  Taking Generation snapshots at intervals of a 
> second or two shows the steady accumulation of small allocations, described 
> as .


___

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