Re: Tab Bar Item naming convention?

2012-07-06 Thread Takeichi Kanzaki Cabrera
On Fri, Jul 6, 2012 at 7:31 AM, Laurent Daudelin
 wrote:
> I've read all the documentation about the subject, did google everything I 
> could think of, but I still don't know how to name tab bar item icons. The 
> documentation recommends a standard icon of 20 x 20 and a high resolution one 
> at 40 x 40. But, do I follow the same naming convention as for the app icon 
> by adding a "@2x" to the file name?

Exactly, this convention works for all the images on your project.

>
> Thanks in advance.
>
> -Laurent.
> --
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin 
> http://www.nemesys-soft.com/
> Logiciels Nemesys Software  
> laur...@nemesys-soft.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/tkanzakic%40gmail.com
>
> This email sent to tkanza...@gmail.com



-- 
Regards,
Takeichi Kanzaki Cabrera
Linux Registered User #308138

If you want to be original,
be yourself.

___

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


wacky image stretching on rotation (repost)

2012-07-06 Thread Gavin Stokes
I have a UIImageView in a custom TableViewCell that I want to rotate to
arbitrary angles.  When I apply a rotation transformation like so:

CGAffineTransform rotation = CGAffineTransformMakeRotation(15 * (M_PI /
180));

[self.thumbImageView setTransform:rotation];

The image is not only rotated but stretched significantly in the horizontal
direction.  It's not a content-resizing problem, because the originally
square UIImageView is now clearly not square.  Screen shot here:
http://farm8.staticflickr.com/7132/7513267936_bbff9019b5_b.jpg

Anybody know what's going on with this?

Thanks!
___

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


Getting NSApplicationDelegate protocol

2012-07-06 Thread ecir hana
Hello,

I'm trying to get the methods a protocol specifies and just stumbled upon
one problem: the following code returns NULL:

Protocol *protocol = objc_getProtocol("NSApplicationDelegate");

I saw (
http://stackoverflow.com/questions/10212119/objc-getprotocol-returns-null-for-nsapplicationdelegate)
that the it is because the protocol was not:

Adopted by a class,
Or referred to somewhere in source code (using @protocol())

As am doing this at runtime, I cannot use "@protocol()", right?

So I thought I will add the protocol to the class:

Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
BOOL class_addProtocol(class, protocol);

The problem, obviously, is that I cannot add a protocol until it been
created and the protocol wont be created until used be a class.

Is there a way to get NSApplicationDelegate protocol besides the
compile-time "@protocol()"?

Also, when I do:

Protocol *protocol = objc_getProtocol("NSTextViewDelegate");

return the protocol even when I didn't create any textviews...?

PS: To get all the method descriptions of a protocol, do I have to call
four times "protocol_getMethodDescription"?

protocol_getMethodDescription(p, aSel, NO, NO);
protocol_getMethodDescription(p, aSel, NO, YES);
protocol_getMethodDescription(p, aSel, YES, NO);
protocol_getMethodDescription(p, aSel, YES, YES);
___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread Stephen J. Butler
On Fri, Jul 6, 2012 at 3:30 AM, ecir hana  wrote:
> I'm trying to get the methods a protocol specifies and just stumbled upon
> one problem: the following code returns NULL:
>
> Protocol *protocol = objc_getProtocol("NSApplicationDelegate");

Are you trying this on 10.5? Or are you building this application with
the 10.5 SDK?

Before 10.6 the NSApplicationDelegate was an informal protocol (that
is, a category of methods on NSObject). This is because "@optional"
didn't appear till the 10.6 SDK/compiler and previous to that for
protocols:

1) all methods were mandatory
2) you couldn't extend the protocol later; once you publish it's set
of methods in a Framework you were fixed at that set

Point (2) follows from point (1) if you think about it enough.

So some of the protocols, like NSApplicationDelegate, weren't really
protocols at all. But in 10.6 they introduced "@optional", and
NSApplicationDelegate became a formal protocol.
___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread ecir hana
Sorry I should've said that before: no, I'm on 10.6.

But thanks for the reply!

On Fri, Jul 6, 2012 at 11:14 AM, Stephen J. Butler  wrote:

> On Fri, Jul 6, 2012 at 3:30 AM, ecir hana  wrote:
> > I'm trying to get the methods a protocol specifies and just stumbled upon
> > one problem: the following code returns NULL:
> >
> > Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
>
> Are you trying this on 10.5? Or are you building this application with
> the 10.5 SDK?
>
> Before 10.6 the NSApplicationDelegate was an informal protocol (that
> is, a category of methods on NSObject). This is because "@optional"
> didn't appear till the 10.6 SDK/compiler and previous to that for
> protocols:
>
> 1) all methods were mandatory
> 2) you couldn't extend the protocol later; once you publish it's set
> of methods in a Framework you were fixed at that set
>
> Point (2) follows from point (1) if you think about it enough.
>
> So some of the protocols, like NSApplicationDelegate, weren't really
> protocols at all. But in 10.6 they introduced "@optional", and
> NSApplicationDelegate became a formal protocol.
>
___

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


Xcode 4.3, XIB files and deployment target iOS 3.1

2012-07-06 Thread John Michael Zorko

Hello, all ...

I'm working on an app that has to work on first-gen iPod touch devices. I set 
the deployment target to 3.1 and made sure armv6 was specified such that my app 
now at least launches on said firstgen iPod touch. However, it hangs before 
showing the tab bar or first view controller:

viewController1 = [[[FirstViewController alloc] 
initWithNibName:@"FirstViewController_iPhone" bundle:nil] autorelease];
viewController2 = [[[SecondViewController alloc] 
initWithNibName:@"SecondViewController_iPhone" bundle:nil] autorelease];

self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = [NSArray 
arrayWithObjects:viewController1, viewController2, nil];   // HANGS HERE
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

The view controllers are the Xcode-generated versions -- i've not added any UI 
elements yet. Though initWithNibName:bundle: is called on each VC, their 
viewDidLoad methods are _not_ called. Is there something special I need to do 
with the Xcode-generated XIB files in order to support iOS 3.1?

Regards,

John

___

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: wacky image stretching on rotation (repost)

2012-07-06 Thread Julius Oklamcak
Check self.thumbImageView.contentMode - it's probably the default
UIViewContentModeScaleToFill (should be UIViewContentModeCenter). Also
ensure that the UIImage that you provide really has square dimensions. I had
the exact same issue when rotating the UIImageView of a UIButton...

> I have a UIImageView in a custom TableViewCell that I want to rotate
> to arbitrary angles.  When I apply a rotation transformation like so:
>
> CGAffineTransform rotation = CGAffineTransformMakeRotation(15 * (M_PI /
180));
>
> [self.thumbImageView setTransform:rotation];
>
> The image is not only rotated but stretched significantly in the
horizontal
> direction.  It's not a content-resizing problem, because the originally
> square UIImageView is now clearly not square.  Screen shot here:
> http://farm8.staticflickr.com/7132/7513267936_bbff9019b5_b.jpg
>
> Anybody know what's going on with this?

___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread Ken Thomases
On Jul 6, 2012, at 3:30 AM, ecir hana wrote:

> I'm trying to get the methods a protocol specifies and just stumbled upon
> one problem: the following code returns NULL:
> 
>Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
> 
> I saw (
> http://stackoverflow.com/questions/10212119/objc-getprotocol-returns-null-for-nsapplicationdelegate)
> that the it is because the protocol was not:
> 
>Adopted by a class,
>Or referred to somewhere in source code (using @protocol())
> 
> As am doing this at runtime, I cannot use "@protocol()", right?

> Is there a way to get NSApplicationDelegate protocol besides the
> compile-time "@protocol()"?

No.  The run-time information about the protocol is obtained from information 
that would have to have been baked into the executable at build time.


> Also, when I do:
> 
>Protocol *protocol = objc_getProtocol("NSTextViewDelegate");
> 
> return the protocol even when I didn't create any textviews...?

You have presumably loaded AppKit, and AppKit does have the protocol details 
for NSTextViewDelegate baked into it, because it includes classes which adopt 
it and/or code which uses @protocol(NSTextViewDelegate).

Regards,
Ken


___

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

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

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

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


RE: Xcode 4.3, XIB files and deployment target iOS 3.1

2012-07-06 Thread Julius Oklamcak
Presuming that the firstgen iPod touch has iOS 3.x on it, it is probably
crashing here:

> self.window.rootViewController = self.tabBarController;

Since rootViewController was introduced to UIWindow in iOS 4.0. Pre-iOS 4.0
you need to use (from what I recall):

[self.window addSubview:self.tabBarController.view];

Which will cause newer versions of iOS to complain. Though there may be
other issues related to Xcode 4.3 supporting ancient versions of iOS (check
the developer forums) and pay attention to Xcode build warnings.

___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread ecir hana
On Fri, Jul 6, 2012 at 11:56 AM, Ken Thomases  wrote:

> > Is there a way to get NSApplicationDelegate protocol besides the
> > compile-time "@protocol()"?
>
> No.  The run-time information about the protocol is obtained from
> information that would have to have been baked into the executable at build
> time.
>
>
> > Also, when I do:
> >
> >Protocol *protocol = objc_getProtocol("NSTextViewDelegate");
> >
> > return the protocol even when I didn't create any textviews...?
>
> You have presumably loaded AppKit, and AppKit does have the protocol
> details for NSTextViewDelegate baked into it, because it includes classes
> which adopt it and/or code which uses @protocol(NSTextViewDelegate).
>

Thank you. And please, can you explain to me why is it that case? Is it
simply because AppKit includes the definition of NSTextViewDelegate
protocol and not includes one for NSApplicationDelegate? Is it somewhere
documented which protocols are not included? I mean,
besides NSApplicationDelegate, what other delegate definitions cannot be
obtained at runtime? Or is there anything like AppKit which, after being
loaded, provides the definitions?

And for the ones includes, how to get all the methods described?
___

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: wacky image stretching on rotation (repost)

2012-07-06 Thread Gavin Stokes
Thanks for the reply, Julius.  I had the mode set to
UIViewContentModeScaleToFill.

Setting it to UIViewContentModeCenter does allow the image to rotate
undistorted, but the frame is still ridiculously distorted.  And look at
the massive difference in distortion for a tiny difference in angle between
the top two:
http://farm8.staticflickr.com/7246/7513766824_c3c47de76b.jpg

This seems wrong.
___

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: Modal event processing

2012-07-06 Thread Uli Kusterer
On 05.07.2012, at 21:57, Charlie Dickman wrote:
> I have a demonstration app that is basically operating on a 0.15 second timer 
> loop. The problem I am having is that even with a periodic timer going off it 
> is very difficult to get menu events and mouse clicks in window controls 
> through to be processed. I have tried setting up an additional flow of events 
> using 
> (NSEvent) + 
> (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySecondswithPeriod:(NSTimeInterval)periodSeconds
> 
> as well as 
> 
> [[NSRunLoop currentRunLoop] runUntilDate: [NSDate 
> dateWithTimeIntervalSinceNow: t != 0. ? t * 1.01 : .01]]
> 
> (where t can be set arbitrarily but is typically called with a value of 0.15) 
> but none of this improves response. Is there anything else to try?

 It's not how long you give time to the event loop, it is how often. Also, 
startPeriodicEventsAfterDelay: is intended for mouse tracking, not for 
general-purpose timers. You're being very vague and fuzzy with your 
terminology, so I hope you don't mind if I just spell out how I'd do a periodic 
task, and then you can tell whether that's what you're doing and when you're 
doing it differently:

-> Use an NSTimer to get your periodic processing time, not other calls.
-> Let the rest of the app run normally
-> Do the minimum amount of work needed in your timer. Timers run on 
your main thread & run loop, so you have to do short bits of work so the OS can 
"come up for breath" often enough. E.g. do your pre-loop setup, then put the 
loop body in the timer (using instance variables for the counter & other stuff 
you need to keep around between iterations), and then do 1 iteration per timer 
fire.
-> Don't use blocking calls (like network access) on the main run loop, 
use calls that do their work on another thread and then call you back when 
they're done (e.g. NSURLConnection, not NSURL -initWithContentsOfURL:).

Or, if you can run your stuff on a secondary thread, queue up your little bits 
of work in an NSOperationQueue or other GCD-backed queue that runs on another 
thread.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."


___

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: wacky image stretching on rotation (repost)

2012-07-06 Thread Julius Oklamcak
I would suspect that the UIImageView's autoresizingMask might be the culprit
- if it isn't UIViewAutoresizingNone, then the frame may be resizing itself
when rotated. Sometimes it is less trouble to create your own
UITableViewCell subclass and have full control over your subviews instead of
trying to twiddle a standard UITableViewCell to do what you want... :)

> Setting it to UIViewContentModeCenter does allow
> the image to rotate undistorted, but the frame is
> still ridiculously distorted.  And look at the massive
> difference in distortion for a tiny difference in angle
> between the top two:
> http://farm8.staticflickr.com/7246/7513766824_c3c47de76b.jpg

___

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: Modal event processing

2012-07-06 Thread Charlie Dickman
Actually, no, I'm not trying to mimic user interaction but that's an idea worth 
thinking about.

The program demonstrates how to play Chinese Mah-Jong as described in A.D. 
Millington's (excellent) book "The Complete Book of Mah-Jong so it runs on a 
timer driven dispatcher to have each player in turn play his hand.

The problem I am having is that outside events like a click in the menu bar or 
a keyboard event have a hard time getting through.

On Jul 5, 2012, at 11:19 PM, Yingshen Yu wrote:

> Are you trying to mimic user interactions with Cocoa UI? 
> If I understand you right, it might be easier to do it with accessibility 
> API, so you can write a normal Cocoa App and a write another app to mimic 
> user interaction to this cocoa app.
> 
> -Jonny
> 
> 
> 在 2012-7-6,上午3:57,Charlie Dickman <3tothe...@comcast.net> 写道:
> 
>> I have a demonstration app that is basically operating on a 0.15 second 
>> timer loop. The problem I am having is that even with a periodic timer going 
>> off it is very difficult to get menu events and mouse clicks in window 
>> controls through to be processed. I have tried setting up an additional flow 
>> of events using 
>> (NSEvent) + 
>> (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySecondswithPeriod:(NSTimeInterval)periodSeconds
>> 
>> as well as 
>> 
>> [[NSRunLoop currentRunLoop] runUntilDate: [NSDate 
>> dateWithTimeIntervalSinceNow: t != 0. ? t * 1.01 : .01]]
>> 
>> (where t can be set arbitrarily but is typically called with a value of 
>> 0.15) but none of this improves response. Is there anything else to try?
>> 
>> Charlie Dickman
>> 3tothe...@comcast.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/yingshen.yu%40gmail.com
>> 
>> This email sent to yingshen...@gmail.com

Charlie Dickman
3tothe...@comcast.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: Modal event processing

2012-07-06 Thread Charlie Dickman
Uli,

Thanks for the education. The way you suggest is what I did pre-OS X and 
Xcode/Cocoa and I didn't have this problem Being self taught (by books, sample 
code and documentation) in programming in Xcode/Cocoa for OS X and IOS it 
sounds like I started off on the wrong foot with the versatility of timers.

I'll have to re-architect the app.

Thanks again.

On Jul 6, 2012, at 7:24 AM, Uli Kusterer wrote:

> On 05.07.2012, at 21:57, Charlie Dickman wrote:
>> I have a demonstration app that is basically operating on a 0.15 second 
>> timer loop. The problem I am having is that even with a periodic timer going 
>> off it is very difficult to get menu events and mouse clicks in window 
>> controls through to be processed. I have tried setting up an additional flow 
>> of events using 
>> (NSEvent) + 
>> (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySecondswithPeriod:(NSTimeInterval)periodSeconds
>> 
>> as well as 
>> 
>> [[NSRunLoop currentRunLoop] runUntilDate: [NSDate 
>> dateWithTimeIntervalSinceNow: t != 0. ? t * 1.01 : .01]]
>> 
>> (where t can be set arbitrarily but is typically called with a value of 
>> 0.15) but none of this improves response. Is there anything else to try?
> 
> It's not how long you give time to the event loop, it is how often. Also, 
> startPeriodicEventsAfterDelay: is intended for mouse tracking, not for 
> general-purpose timers. You're being very vague and fuzzy with your 
> terminology, so I hope you don't mind if I just spell out how I'd do a 
> periodic task, and then you can tell whether that's what you're doing and 
> when you're doing it differently:
> 
>   -> Use an NSTimer to get your periodic processing time, not other calls.
>   -> Let the rest of the app run normally
>   -> Do the minimum amount of work needed in your timer. Timers run on 
> your main thread & run loop, so you have to do short bits of work so the OS 
> can "come up for breath" often enough. E.g. do your pre-loop setup, then put 
> the loop body in the timer (using instance variables for the counter & other 
> stuff you need to keep around between iterations), and then do 1 iteration 
> per timer fire.
>   -> Don't use blocking calls (like network access) on the main run loop, 
> use calls that do their work on another thread and then call you back when 
> they're done (e.g. NSURLConnection, not NSURL -initWithContentsOfURL:).
> 
> Or, if you can run your stuff on a secondary thread, queue up your little 
> bits of work in an NSOperationQueue or other GCD-backed queue that runs on 
> another thread.
> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> 

Charlie Dickman
3tothe...@comcast.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: Modal event processing

2012-07-06 Thread Graham Cox

On 06/07/2012, at 11:38 PM, Charlie Dickman wrote:

> I'll have to re-architect the app.


Maybe.

The thing that's key is that you do not run the event loop - it runs you (we're 
in Soviet Russia now). It also runs any timers which are attached to it. Timers 
do not (and can not) run the event loop - it's the other way around.

Any time you feel tempted to "force" the event loop to run you have a big red 
flag (Russia again?) telling you something is wrong. If you look at the starter 
app that is created by Xcode, you will see no visible code that runs an event 
loop, but controls and menus you add to the basic xib work just fine.  

In the case of a game, if you have designed it so that the pieces can be moved 
by the user manually, adding automation shouldn't be too hard. You can use a 
timer to invoke movements at a lower level, just as the mouse events call down 
to cause movement at the same lower level. (With Core Animation and using a 
CALayer for each of the pieces, doing this with animation should be really 
easy, though the setup with CA would take a bit more time - look at the 
GeekGameBoard sample code, it's probably 90% of the necessary game mechanics as 
it is).



--Graham


___

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

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

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

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


Re: Modal event processing

2012-07-06 Thread Richard Altenburg (Brainchild)
In a situation similar to yours, I ended up replacing the NSTimer with an 
NSAnimation. The animation I was doing was way faster after this tiny change, 
plus the user interface was not blocked at all. I refresh my animation 30 times 
per second now without any negative effect for the user. I think it is worth a 
try in your case before you rethink your application.


[[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];

Op 6 jul. 2012, om 15:38 heeft Charlie Dickman het volgende geschreven:

> I'll have to re-architect the app.

___

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: Window-Frame Controls in Lion

2012-07-06 Thread Fritz Anderson
On 5 Jul 2012, at 8:43 PM, Richard Somers wrote:

> Does this bother anyone else besides me?

Are you asking for an advocacy opinion, or something practical that a forum 
dedicated to support for developing applications with Cocoa can help you with?

If the latter, I don't believe you can do what you apparently hope for using 
the stock NSToolbar. Apple is well-known for constructing UI elements that are 
similar to standard ones, but have completely different implementations. 
They're probably using a custom NSWindow class, because the "toolbar" has to 
blend seamlessly with the window frame.

For the advocacy question, go to .

— 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

Fwd: Need sample code for NSDocument / NSDocumentController

2012-07-06 Thread Keith Knauber
There is no sample code for the new -[NSDocumentController 
openDocumentWithContentsOfURL:display:completionHandler:]
Why is there no sample project for a standard NSDocumentController/NSDocument 
based app?

Can someone provide sample code for how to migrate from the deprecated
- (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL 
display:(BOOL)displayDocument error:(NSError **)outError
to the new approved
-[NSDocumentController openDocumentWithContentsOfURL:display:completionHandler:]

In particular, the hopefully soon-to-be-deprecated ^block syntax should always 
be documented
with sample code of how it should be used.
I need detailed documentation of the effect passing YES vs. NO for 
documentWasAlreadyOpen
 
In our case, there can only be one document open at a time.
However, NSDocument is useful for save, revert, edit, NSUndoManager, etc.

The Cocoa docs state that NSDocumentController should rarely need to be 
subclassed.
However, in Lion, I'm at a loss for why its complaining to me:

-[NSDocumentController 
openDocumentWithContentsOfURL:display:completionHandler:] failed during state 
restoration. Here's the error:
"The document “test.mboxshow” could not be opened. MyApp cannot open files in 
the “"MyApp.app Document” format.

My attempts to override the new function instead does bad things… like no new 
windows can be drawn.
My app seems to randomly do bad things, similar to what happens when there is 
an uncaught exception,
although I see no exceptions being thrown.
Cocoa spits out no log messages, and I have exhausted every conceivable debug 
method (NSException catch, NSZombie, MallocDebug, etc etc)

For what its worth, my now deprecated NSDocumentController  override never gets 
called,
whether I override the new method or not.  The documentation says that it 
should be called for binary compatibility, but
it isn't.

- (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL 
display:(BOOL)displayDocument error:(NSError **)outError
{
   if ( outError )
  *outError = nil;
   
   NSLog( @"openDocumentWithContentsOfURL %@", absoluteURL);
   NSString *path = [absoluteURL path];

  MbDocument *currShow = [self mbdocument];
  NSString *currShowPath = [currShow filePath];
  NSInteger retVal;
  if ( !( [[MbEController instance] isFinishedLaunching] & 
kFinishedPreLaunchCheck) )
  {
 // user double-clicked a file to start Director
 currShowPath = [[NSUserDefaults standardUserDefaults] 
objectForKey:@"LastSaveFile"];
 if ( [currShowPath isEqualToString: path] )
 {
if ( [[[NSUserDefaults standardUserDefaults] 
objectForKey:@"isDocumentEdited"] boolValue] == YES )
{
   retVal = NSRunAlertPanel(@"Open Show File", @"Revert to Saved?", 
@"Revert to Saved", @"Keep Changes", NULL);
   if ( retVal == NSAlertDefaultReturn )
   {
  [[MbEController instance] openShowFile:path];
   }
}
return currShow; // proceed with normal startup
 }
  }
  

  if ( [currShowPath isEqualToString: path] )
  {
 NSLog( @"is edited %d currShow %@", [currShow isDocumentEdited], 
currShow );
 if ( [currShow isDocumentEdited] )
[currShow revertDocumentToSaved:self]; // will prompt
 else // document is already open, so do what Apple's standard action 
is... 
[currShow showWindows];
  }
  else 
  {
 if ( [currShow isDocumentEdited] )
retVal = NSRunAlertPanel(@"Open Show File", [NSString 
stringWithFormat: @"The current show file has unsaved changes.  Discard unsaved 
changes and switch to show file '%@'?", path], @"Discard unsaved changes and 
switch to show", @"Keep Current", NULL);
 else
retVal = NSRunAlertPanel(@"Switch to Show File", [NSString 
stringWithFormat: @"Switch to Show File '%@'?\n\nCurrent show file '%@'", path, 
currShowPath ? currShowPath : @"Untitled"], @"Switch", @"Keep Current", NULL);
 if ( retVal == NSAlertDefaultReturn )
[[MbEController instance] openShowFile:path];
  }

  // user cancelled
  return currShow;

}



___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread Stephen J. Butler
On Fri, Jul 6, 2012 at 4:35 AM, ecir hana  wrote:
> Sorry I should've said that before: no, I'm on 10.6.
>
> But thanks for the reply!

You're positive you're linking against the 10.6 SDK? Even if you're on
10.6 you might be linking against the 10.5 SDK and that would explain
your problem perfectly.

> On Fri, Jul 6, 2012 at 11:14 AM, Stephen J. Butler > wrote:
>
>> On Fri, Jul 6, 2012 at 3:30 AM, ecir hana  wrote:
>> > I'm trying to get the methods a protocol specifies and just stumbled upon
>> > one problem: the following code returns NULL:
>> >
>> > Protocol *protocol = objc_getProtocol("NSApplicationDelegate");
>>
>> Are you trying this on 10.5? Or are you building this application with
>> the 10.5 SDK?
>>
>> Before 10.6 the NSApplicationDelegate was an informal protocol (that
>> is, a category of methods on NSObject). This is because "@optional"
>> didn't appear till the 10.6 SDK/compiler and previous to that for
>> protocols:
>>
>> 1) all methods were mandatory
>> 2) you couldn't extend the protocol later; once you publish it's set
>> of methods in a Framework you were fixed at that set
>>
>> Point (2) follows from point (1) if you think about it enough.
>>
>> So some of the protocols, like NSApplicationDelegate, weren't really
>> protocols at all. But in 10.6 they introduced "@optional", and
>> NSApplicationDelegate became a formal protocol.
>>
> ___
>
> 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/stephen.butler%40gmail.com
>
> This email sent to stephen.but...@gmail.com
___

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

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

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

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


Re: Window-Frame Controls in Lion

2012-07-06 Thread Alex Zavatone

On Jul 5, 2012, at 9:43 PM, Richard Somers wrote:

> Controls in the window-frame area (that is, in the toolbar or bottom bar) 
> normally have a textured style as stated in the OS X Human Interface 
> Guidelines. In 10.7 Lion textured controls became semi-transparent with some 
> of the background showing through. This results in most window-frame controls 
> taking on more of a bland gray look.
> 
> Not all applications suffer from the bland gray toolbar look in Lion. Apple's 
> iCal sports a bold new brown leather look. You may or may not like the new 
> look but one thing is does have and that is sharply defined window-frame 
> controls. Even though the window-frame background and controls are both 
> brown, the contrast between the two is sharp. Compare this to the Finder 
> window-frame in Lion where the controls are not nearly as sharp.
> 
> One measure of the contrast between the background and the control is the 
> difference in brightness between the two. The fact that the background and 
> control have the same base color makes this measurement especially meaningful.
> 
>Application OS XBase Color  Background-Control Brightness
>Finder  10.6Gray61 - 4 = 57%
>Finder  10.7Gray67 - 21 = 46%
>iCal10.7Brown   71 - 13 = 58%
> 
> These measurements correlate to the general perception that window-frame 
> controls the new iCal and the old Finder are sharp and identifiable. Whereas 
> window-frame controls in the new Finder appear less defined and muddy.

The desaturated look of Finder Window controls in the Lion Finder (and System 
Preferences) is an obvious step backwards in usability as far as I am 
concerned.  It's not nearly as obvious when a button in a Finder window is 
enabled or disabled and in certain lighting situations, I have to look twice to 
see what the state of the GUI is.  

Compared to Snow Leopard, I hate it.

> I have an application that relies heavily on the toolbar. In my option the 
> usability of standard toolbar controls has been degraded in Lion because of 
> this change.
> 
> Does this bother anyone else besides me?

Yep.   Doesn't exactly make me want to use Lion.

I reported it when I was on the Lion Beta.  Even wrote to Schiller and Jobs 
about stuff like this with the support of a few ex Apple employees.  It's 
decisions like this where obviously poorer functionality than in the previous 
shipping product makes it into a shipping product that make me wonder what's 
going on at Apple and if it's even worth reporting these issues.

IMHO, I think it's terrible for several reasons, but I also think that there's 
nothing we can do about it.  




___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Greg Parker
On Jul 5, 2012, at 7:50 PM, Erik Stainsby  wrote:
> My project employs a framework which loads several plugins. When the user 
> interacts with these plugins s/he generates an intermediate abstraction of 
> the plugin contents which I refer to as a rule. The rule abstraction exists 
> to facilitate round-tripping back to the plugin of origin or onward to the 
> rendered product. 
> 
> I am currently stuck in the stage of migrating the data from the plugin to a 
> newly created rule instance.  I hit on the notion of using categories to 
> shuffle the values from the plugin instance to the rule instance and vice 
> versa. Two small dedicated categories for each plugin family (I have three 
> families at the moment). Seems a manageable scheme.  However, I am getting an 
>   "unrecognized selector sent to instance 0xyaddayadda" when I try to run 
> this. I know the selector does exist, so I must have a scoping issue (?)

What exactly is the unrecognized selector message you get?

Are there any static libraries involved in your build process? Categories 
compiled into static libraries require special treatment.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Greg Parker
On Jul 5, 2012, at 9:24 PM, Graham Cox  wrote:
> If so, I don't think that will work. When your app is loaded and linked when 
> it's launched, the category won't be attached to the class 'MyClass' because 
> it doesn't exist. It is only loaded and linked when the plug-in is loaded, 
> but the runtime can't retrospectively attach the category - its opportunity 
> to do so automatically has passed. You might be able to use the low-level 
> runtime methods to attempt to reattach the category after you have loaded the 
> plug-ins.

This is usually not an issue because usually you get a missing symbol error 
from the linker if you try to arrange your code this way. (The category 
implementation has a C symbol reference to the class's implementation.)


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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

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

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

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


Re: Getting NSApplicationDelegate protocol

2012-07-06 Thread ecir hana
On Fri, Jul 6, 2012 at 8:01 PM, Stephen J. Butler
wrote:

>
> You're positive you're linking against the 10.6 SDK? Even if you're on
> 10.6 you might be linking against the 10.5 SDK and that would explain
> your problem perfectly.
>
>
NSAppKitVersionNumber says "1038.36" which is 10.6.
___

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: Modal event processing

2012-07-06 Thread Charlie Dickman
I just had a look at the NSAnimation class document and it actually suggests 
very prominently that, because of the limited capabilities of an NSAnimation, 
an NSTimer be used.

I also just went back over the architecture of my app with Uli's comments in 
mind and have discovered that I think I am actually doing what he suggests. I 
am not polling for events nor am I trying to drive the run loop myself.

In my view's drawRect method I use a global state variable that defines the 
next function to perform. When drawRect gets called I do what is necessary for 
the current state, set up for the next state, set the value for the next state 
and then return from drawRect. So the primary driving force is the periodic 
view update requirement (which is guaranteed by actions invoking [self 
setNeedsDisplay: YES]).

Within the execution of a particular function I use NSTimers to drive the steps 
of that function ultimately exiting back to the dispatch stack in drawRect.

So I am at a loss as how to better allow the system to do a better job of 
servicing menu clicks or keyboard presses.

Can you help me to see what I am missing?


On Jul 6, 2012, at 10:22 AM, Richard Altenburg (Brainchild) wrote:

> In a situation similar to yours, I ended up replacing the NSTimer with an 
> NSAnimation. The animation I was doing was way faster after this tiny change, 
> plus the user interface was not blocked at all. I refresh my animation 30 
> times per second now without any negative effect for the user. I think it is 
> worth a try in your case before you rethink your application.
> 
> 
> [[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];
> 
> Op 6 jul. 2012, om 15:38 heeft Charlie Dickman het volgende geschreven:
> 
>> I'll have to re-architect the app.
> 

Charlie Dickman
3tothe...@comcast.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: Modal event processing

2012-07-06 Thread Fritz Anderson
On 6 Jul 2012, at 3:02 PM, Charlie Dickman wrote:

> In my view's drawRect method I use a global state variable that defines the 
> next function to perform. When drawRect gets called I do what is necessary 
> for the current state, set up for the next state, set the value for the next 
> state and then return from drawRect. So the primary driving force is the 
> periodic view update requirement (which is guaranteed by actions invoking 
> [self setNeedsDisplay: YES]).
> 
> Within the execution of a particular function I use NSTimers to drive the 
> steps of that function ultimately exiting back to the dispatch stack in 
> drawRect.
> 
> So I am at a loss as how to better allow the system to do a better job of 
> servicing menu clicks or keyboard presses.

Taking my cue from "exiting back to the dispatch stack in drawRect" — I don't 
have the earlier parts of the thread before me, so forgive me if I make the 
wrong guesses about your intention.

AppKit essentially requires that you use -drawRect: for drawing, and for no 
other processing at all. Otherwise you're turning your design inside-out 
("fighting the framework"). Driving updates to state is the business of your 
controller layer (maybe the model), not the view layer.

The controller handles an NSTimer firing.

1) It sets properties in the view to configure how it will be drawn next, and 
calls -setNeedsDisplay:. The view draws. That's it.

OR

2) It updates the model layer. The model informs the controller through a 
notification or key-value observation that it has changed. The controller 
updates the view parameters, and calls -setNeedsDisplay:. The view draws. 
That's it.

OR

3) This is some sort of animation (a throb, for instance) that doesn't 
represent any model or controller state. Then the view might handle the timer, 
or use an NSAnimation, to update its own parameters, and call 
-setNeedsDisplay:. The view draws. That's it. Better: It uses Core Animation to 
do autonomous changes in rendering.

In all cases, the event mechanism coalesces all the needs-display calls into a 
periodic call to -drawRect:. In -drawRect:, the view draws itself and does 
nothing else. The controller and the model do all the processing.

And the event mechanism interleaves user events the whole time.

— 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: Modal event processing

2012-07-06 Thread Richard Altenburg (Brainchild)
Fritz Anderson's comments are very important, in that you do not control the 
state of your animation in the drawRect: but instead handle that from a calling 
method (like the one in your controller which is called from your timer). 
drawRect: is not fully under your control nor should you try to do so.

The documentation for animations states that for very simple work you should 
use the NSTimer, else use NSAnimation. I went for NSTimer first because I got 
so used to them in my previous development environment, but I was not happy 
with the fastest speed at which it would allow me to fire the timer, and they 
way it blocked my user interface. I swapped it for an NSAnimation, and it all 
worked beautifully after that. Mind you, I do not use full blown animation, I 
just abuse the NSAnimation as a timer, just like the NSTimer, but without the 
downsides.

I am very new to Objective-C and Cocoa/Cocoa Touch, so you should listen to 
more advanced people on this list. But, I will tell you what I found to be 
effective and NSAnimation was very effective. And to see how I did this, I 
suggest you watch my small movie about this project:

http://www.youtube.com/watch?v=jKg1Fy-LKVY


[[[Brainchild alloc] initWithName:@"Richard Altenburg"] saysBestRegards];

Op 6 jul. 2012, om 22:02 heeft Charlie Dickman het volgende geschreven:

> I just had a look at the NSAnimation class document and it actually suggests 
> very prominently that, because of the limited capabilities of an NSAnimation, 
> an NSTimer be used.

___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread Kyle Sluder
On Fri, Jul 6, 2012, at 10:00 PM, ecir hana wrote:
> On Fri, Jul 6, 2012 at 8:01 PM, Stephen J. Butler
> wrote:
> 
> >
> > You're positive you're linking against the 10.6 SDK? Even if you're on
> > 10.6 you might be linking against the 10.5 SDK and that would explain
> > your problem perfectly.
> >
> >
> NSAppKitVersionNumber says "1038.36" which is 10.6.

That tells you what version of AppKit you're _running on_, not what
version you've _linked against._ The whole purpose of that variable
(note it's a global variable, not a compile-time constant!) is so that
code linked against earlier frameworks can see if it's running on a
version of the OS older or newer than the SDK it was linked against.

The frameworks can detect when you've linked against a different version
of AppKit than you're running on, and will often change their behavior
accordingly.

--Kyle Sluder
___

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

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

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

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


Re: Modal event processing

2012-07-06 Thread Graham Cox

On 07/07/2012, at 6:02 AM, Charlie Dickman wrote:

> In my view's drawRect method I use a global state variable that defines the 
> next function to perform. When drawRect gets called I do what is necessary 
> for the current state, set up for the next state, set the value for the next 
> state and then return from drawRect. So the primary driving force is the 
> periodic view update requirement (which is guaranteed by actions invoking 
> [self setNeedsDisplay: YES]).


Hmmm, don't do that.

-drawRect: is going to be called for all sorts of reasons, not just because 
your timer refreshed the view. It's quickly going to get out of step if your 
state machine (which is what it is) is advanced on every -drawRect:

Abstract the state machine so its state can be changed by some explicit message 
rather than -drawRect:, then you can control when it changes state according to 
the logic of your game. Again this sounds upside-down, in that you're using the 
drawing to control the state instead of using the state to control the drawing.

A naïve way to implement animation is to try to run a timer at, say 30 fps, 
which refreshes a view. When the view draws, it updates the animation state, 
for example by moving a graphic object some fixed distance. If things run 
smoothly, it "works", in that the speed and position of the object are 
apparently correct. Then sometimes they aren't, because for whatever reason the 
30fps can't be maintained, the motion slows down and the position is less than 
what was predicted. The right way to do this is to model the physics in a 
simple way, remembering that speed is distance / time. So when your timer 
fires, you measure the elapsed time and use that to calculate the correct 
position of the object. You set its position there and you refresh the view. 
Then when it is drawn, it is in the right place. It does not matter how slow or 
fast the view refresh manages to be, it will animate correctly - the object 
speed is now independent of the view update rate. This is a subtle difference 
but crucial to success.

You have to design your game and all its animation as if it were totally 
invisible. In other words, it has a data model that models the game in all its 
states, including transitional animations that has nothing to do with screens 
or views or pixels. Then you get your view to render that data model as a sort 
of 'snapshot' of what it's doing at any particular moment. It should not matter 
how quickly or slowly you take that snapshot - what you see is what the game is 
doing at that moment. If you take snapshots fast enough (30fps) you will see 
the game animated smoothly.

If on the other hand you use the taking of the snapshot to drive the game, it 
will be terrible. Effectively your game is in a static state until someone 
looks at it, at which point you're trying to hurriedly rearrange it into the 
expected state for display. If that were real life, you can see the absurdity 
of it.

You can use a timer to keep the state of the game updated, but at each moment, 
calculate the full state of the game and schedule a view update. Don't schedule 
a view update and use that to update the game state. If the logic is factored 
in a reasonable way, you can see that this amounts to swapping two lines of 
code. It makes all the difference.

--Graham
___

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

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

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

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

Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 12:46 PM, Greg Parker  wrote:

> On Jul 5, 2012, at 7:50 PM, Erik Stainsby  wrote:
>> My project employs a framework which loads several plugins. When the user 
>> interacts with these plugins s/he generates an intermediate abstraction of 
>> the plugin contents which I refer to as a rule. The rule abstraction exists 
>> to facilitate round-tripping back to the plugin of origin or onward to the 
>> rendered product. 
>> 
>> I am currently stuck in the stage of migrating the data from the plugin to a 
>> newly created rule instance.  I hit on the notion of using categories to 
>> shuffle the values from the plugin instance to the rule instance and vice 
>> versa. Two small dedicated categories for each plugin family (I have three 
>> families at the moment). Seems a manageable scheme.  However, I am getting 
>> an   "unrecognized selector sent to instance 0xyaddayadda" when I try to run 
>> this. I know the selector does exist, so I must have a scoping issue (?)
> 
> What exactly is the unrecognized selector message you get?
> 


2012-07-04 20:43:50.180 Trixie[422:303] -[RSLocatorView requestPopover:]- 
[0098] 
2012-07-04 20:44:02.980 Trixie[422:303] 
-[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
plugin.action: addClass
2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
unrecognized selector sent to instance 0x101833fe0
2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
unrecognized selector sent to instance 0x101833fe0
2012-07-04 20:44:02.983 Trixie[422:303] (
0   CoreFoundation  0x7fff90996716 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff8c97c470 
objc_exception_throw + 43
2   CoreFoundation  0x7fff90a2cd5a 
-[NSObject(NSObject) doesNotRecognizeSelector:] + 186
3   CoreFoundation  0x7fff90984c3e 
___forwarding___ + 414
4   CoreFoundation  0x7fff90984a28 
_CF_forwarding_prep_0 + 232
5   Trixie  0x0001cf81 
-[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:] + 177
6   Trixie  0x0001b6d9 
-[RSRuleWindowController addRuleToStore:] + 249
7   AppKit  0x7fff91589599 
-[NSApplication sendAction:to:from:] + 342
8   AppKit  0x7fff915893f7 -[NSControl 
sendAction:to:] + 85
9   AppKit  0x7fff9158932b -[NSCell 
_sendActionFrom:] + 138
10  AppKit  0x7fff91587813 -[NSCell 
trackMouse:inRect:ofView:untilMouseUp:] + 1855
11  AppKit  0x7fff91587061 
-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
12  AppKit  0x7fff915867dc -[NSControl 
mouseDown:] + 820
13  AppKit  0x7fff9157e13e -[NSWindow 
sendEvent:] + 6853
14  AppKit  0x7fff9157a274 
-[NSApplication sendEvent:] + 5761
15  AppKit  0x7fff9148feaa 
-[NSApplication run] + 636
16  AppKit  0x7fff91434886 
NSApplicationMain + 869
17  Trixie  0x00011b12 main + 34
18  libdyld.dylib   0x7fff8f9e27e1 start + 0
)



> Are there any static libraries involved in your build process? Categories 
> compiled into static libraries require special treatment.
> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 

I am only using the home-built loader framework as mentioned.  No other 
external-to-Cocoa libs.

I opted to use categories in this case to avoid having to directly modify my 
framework. But if there is as Graham suggested a load order issue, I might be 
better off implementing the method natively in the framework. I pretty much 
have the code already in the categories. :D

Erik



___

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


Custom NSViews

2012-07-06 Thread William Squires
  Okay, I've got my custom NSView subclass to draw my Shape objects (or 
subclasses thereof). Each Shape inherits or overrides:

-(BOOL)shapeContainsPoint:(CGPoint)thePoint;

  Now, I want to detect clicks within the view and iterate over all the objects 
the view is responsible for, and send them the above message. My Document.h 
declares:

-(IBAction)didClick:(id)sender;

which - for now - just does an NSLog(). How do I get my ShapeView class (the 
custom NSView subclass) to have the necessary code/declarations so that IB can 
see that it can originate an action, just like an NSButton or other control 
(i.e. Ctrl-drag from the control to the action in the delegate).
  Furthermore, what's the recommended way to communicate the X,Y position 
(CGPoint) where the user clicked in the drawable area of the view -> delegate 
that has the action triggered when the user clicks (i.e. see above)? Should the 
view hold on to the X,Y location, then provide these are readonly properties 
which the action code in the delegate can fetch through the (id)sender? Or is 
there a better way?



___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Greg Parker
On Jul 6, 2012, at 4:48 PM, Erik Stainsby  wrote:
> 2012-07-04 20:44:02.980 Trixie[422:303] 
> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
> plugin.action: addClass
> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
> unrecognized selector sent to instance 0x101833fe0

How is -[RSReactionRule setAction:] implemented? It wasn't in your quoted 
categories.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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

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

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

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


rotating NSBezierPath objects

2012-07-06 Thread William Squires
  Okay, I see in the doc set that you can perform an NSAffineTransform on an 
NSBezierPath, but how do I perform a rotation of the NSBezierPath about an 
arbitrary CGPoint and with a specified angle in radians? Is this something deep 
in CoreGraphics, or CoreAnimation? If not, I can do the trigonometry myself if 
I can get the list of points that make up the NSBezierPath, but it seems these 
aren't exposed, only NSBezierPathElement objects. Help!
  Also, what is the formula for calculating the area of an arbitrary triangle 
defined by three non-collinear points in 2D space? (i.e. I can't assume the 
triangle even has a 90 degree angle in it, or any other such shortcuts…)
  Finally, If an NSBezierPath consisting of a closed circuit of points:

…
NSBezierPath *mySquarePath = [NSBezierPath bezierPath];

[mySquarePath setLineWidth:1.0];
[mySquarePath moveToPoint:CGPointMake(0.0, 0.0)];
[mySquarePath lineToPoint:CGPointMake(10.0, 0.0)];
[mySquarePath lineToPoint:CGPointMake(10.0, 10.0)];
[mySquarePath lineToPoint:CGPointMake(0.0, 10.0)];
[mySquarePath closePath];
…

will [mySquarePath containsPoint:CGPointMake(5.0, 5.0)] return YES even before 
I fill or stroke the path, or do I have to fill the path first?


___

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

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

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

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

Re: Is this an incorrect use of categories ?

2012-07-06 Thread Alex Zavatone
OK.  I'm not sure what I ran into is related, but maybe it is.  

I was calling performSegueWithIdentifier on a storyboard action and passing in 
the exact segue name.  Instant SIGABRT.  Checked the wiring up of all outlets 
and such.  Everything was fine.  

I did have two storyboards, one in French, the other in English.  Even though 
everything was wired up properly to the right controller, this still happened 
all the time.

Deleting and readding the segue from VC to VC and naming it properly didn't 
change things.  

Simply duplicating the scene, adding a new segue, naming it properly and wiring 
it exactly as had been done before got the segue working in the English 
storyboard.  

Comparing it and all the outlets and segues to the French, it was exactly the 
same, but the French version still crashed on the segue. Performing the same 
procedure on the French storyboard got it working.

As far as I can tell, what was happening was that Xcode's GUI was indicating 
that everything was legit, but it wasn't and in the case of sending an 
unimplemented method to an object, Xcode simply SIGABRTs without telling you 
which object and which method it thought was being executed.  

So, back to your "unrecognized selector sent to instance whatever".  As far as 
I can tell, we trust that the GUI of our dev tools are being accurate.  It 
appears that is not always the case.  

In my case, I swore and checked that the right message (segue name identifier) 
was being used in performSegueWithIdentifier.  It was.  Xcode thought 
differently.  

Sometimes it pays to doubt the accuracy of what your dev tools tell you.  


If you can isolate the line of code before the crash, can you check and NSLog 
the string value of the selector being sent and see if it matches the selectors 
on the object?

GL.


On Jul 6, 2012, at 7:48 PM, Erik Stainsby wrote:

> 
> 
> On 2012-07-06, at 12:46 PM, Greg Parker  wrote:
> 
>> On Jul 5, 2012, at 7:50 PM, Erik Stainsby  
>> wrote:
>>> My project employs a framework which loads several plugins. When the user 
>>> interacts with these plugins s/he generates an intermediate abstraction of 
>>> the plugin contents which I refer to as a rule. The rule abstraction exists 
>>> to facilitate round-tripping back to the plugin of origin or onward to the 
>>> rendered product. 
>>> 
>>> I am currently stuck in the stage of migrating the data from the plugin to 
>>> a newly created rule instance.  I hit on the notion of using categories to 
>>> shuffle the values from the plugin instance to the rule instance and vice 
>>> versa. Two small dedicated categories for each plugin family (I have three 
>>> families at the moment). Seems a manageable scheme.  However, I am getting 
>>> an   "unrecognized selector sent to instance 0xyaddayadda" when I try to 
>>> run this. I know the selector does exist, so I must have a scoping issue (?)
>> 
>> What exactly is the unrecognized selector message you get?
>> 
> 
> 
> 2012-07-04 20:43:50.180 Trixie[422:303] -[RSLocatorView requestPopover:]- 
> [0098] 
> 2012-07-04 20:44:02.980 Trixie[422:303] 
> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
> plugin.action: addClass
> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
> unrecognized selector sent to instance 0x101833fe0
> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
> unrecognized selector sent to instance 0x101833fe0
> 2012-07-04 20:44:02.983 Trixie[422:303] (
>   0   CoreFoundation  0x7fff90996716 
> __exceptionPreprocess + 198
>   1   libobjc.A.dylib 0x7fff8c97c470 
> objc_exception_throw + 43
>   2   CoreFoundation  0x7fff90a2cd5a 
> -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
>   3   CoreFoundation  0x7fff90984c3e 
> ___forwarding___ + 414
>   4   CoreFoundation  0x7fff90984a28 
> _CF_forwarding_prep_0 + 232
>   5   Trixie  0x0001cf81 
> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:] + 177
>   6   Trixie  0x0001b6d9 
> -[RSRuleWindowController addRuleToStore:] + 249
>   7   AppKit  0x7fff91589599 
> -[NSApplication sendAction:to:from:] + 342
>   8   AppKit  0x7fff915893f7 -[NSControl 
> sendAction:to:] + 85
>   9   AppKit  0x7fff9158932b -[NSCell 
> _sendActionFrom:] + 138
>   10  AppKit  0x7fff91587813 -[NSCell 
> trackMouse:inRect:ofView:untilMouseUp:] + 1855
>   11  AppKit  0x7fff91587061 
> -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
>   12  AppKit  0x7fff915867dc -[NSControl 
> mouseDown:] + 820
>   13  AppKit  0x7fff9157e13e -[

Re: Custom NSViews

2012-07-06 Thread Alex Zavatone
iOS or Mac OS?

On Jul 6, 2012, at 7:55 PM, William Squires wrote:

>  Okay, I've got my custom NSView subclass to draw my Shape objects (or 
> subclasses thereof). Each Shape inherits or overrides:
> 
> -(BOOL)shapeContainsPoint:(CGPoint)thePoint;
> 
>  Now, I want to detect clicks within the view and iterate over all the 
> objects the view is responsible for, and send them the above message. My 
> Document.h declares:
> 
> -(IBAction)didClick:(id)sender;
> 
> which - for now - just does an NSLog(). How do I get my ShapeView class (the 
> custom NSView subclass) to have the necessary code/declarations so that IB 
> can see that it can originate an action, just like an NSButton or other 
> control (i.e. Ctrl-drag from the control to the action in the delegate).
>  Furthermore, what's the recommended way to communicate the X,Y position 
> (CGPoint) where the user clicked in the drawable area of the view -> delegate 
> that has the action triggered when the user clicks (i.e. see above)? Should 
> the view hold on to the X,Y location, then provide these are readonly 
> properties which the action code in the delegate can fetch through the 
> (id)sender? Or is there a better way?
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby
On 2012-07-06, at 5:11 PM, Greg Parker  wrote:

> On Jul 6, 2012, at 4:48 PM, Erik Stainsby  wrote:
>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>> plugin.action: addClass
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
> 
> How is -[RSReactionRule setAction:] implemented? It wasn't in your quoted 
> categories.

Actually it was part of my first post: it is declared 

@property (retain) action; 
@synthesize action=_action; 

~ as implemented in the RSReactionRule.   It is invoked in the category, as:  
[self setAction: plugin.action]; 





> -- 
> Greg Parker gpar...@apple.com Runtime Wrangler
> 
> 


___

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

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

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

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


Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 5:28 PM, Erik Stainsby  wrote:

> On 2012-07-06, at 5:11 PM, Greg Parker  wrote:
> 
>> On Jul 6, 2012, at 4:48 PM, Erik Stainsby  
>> wrote:
>>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>>> plugin.action: addClass
>>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>>> unrecognized selector sent to instance 0x101833fe0
>> 
>> How is -[RSReactionRule setAction:] implemented? It wasn't in your quoted 
>> categories.
> 
> Actually it was part of my first post: it is declared 
> 
> @property (retain) action; 

Check that:  
@property (retain) NSString * action;


> @synthesize action=_action; 
> 
> ~ as implemented in the RSReactionRule.   It is invoked in the category, as:  
> [self setAction: plugin.action]; 
> 
> 
> 
> 
> 
>> -- 
>> Greg Parker gpar...@apple.com Runtime Wrangler
>> 
>> 
> 


___

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

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

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

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


Re: Custom NSViews

2012-07-06 Thread Jens Alfke

On Jul 6, 2012, at 4:55 PM, William Squires wrote:

> How do I get my ShapeView class (the custom NSView subclass) to have the 
> necessary code/declarations so that IB can see that it can originate an 
> action, just like an NSButton or other control (i.e. Ctrl-drag from the 
> control to the action in the delegate).

I think it would have to subclass NSControl; then IB would let you wire up its 
target/action properties. This is a bit of a dead-end, though, as it only lets 
you communicate one thing, i.e. a click on a shape. You're probably going to 
want something richer.

Another way to do it is to create a 'delegate' or 'target' IBOutlet on your 
view class that you wire up to the object that will be called when events 
happen. If you want to be formal about it you can define a protocol in your 
view's header, and then have the document implement it. This way you can extend 
that protocol to add methods that will be called in other circumstances.

—Jens
___

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

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

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

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

Re: Is this an incorrect use of categories ?

2012-07-06 Thread Erik Stainsby


On 2012-07-06, at 5:13 PM, Alex Zavatone  wrote:

> OK.  I'm not sure what I ran into is related, but maybe it is.  
> 
> If you can isolate the line of code before the crash, can you check and NSLog 
> the string value of the selector being sent and see if it matches the 
> selectors on the object?
> 
> GL.

The selector name is reported in the error message, and the method is declared 
as a @property/@synthesize so I have no reason to doubt that they match up.

I have in troubleshooting this hand coded the setter/getter and removed the 
property decl. With nil difference in the result. Still not recognized.   Which 
is why I started to think about scope issues.


> 
> On Jul 6, 2012, at 7:48 PM, Erik Stainsby wrote:
> 
>> 
>> 
>> On 2012-07-06, at 12:46 PM, Greg Parker  wrote:
>> 
>>> On Jul 5, 2012, at 7:50 PM, Erik Stainsby  
>>> wrote:
 My project employs a framework which loads several plugins. When the user 
 interacts with these plugins s/he generates an intermediate abstraction of 
 the plugin contents which I refer to as a rule. The rule abstraction 
 exists to facilitate round-tripping back to the plugin of origin or onward 
 to the rendered product. 
 
 I am currently stuck in the stage of migrating the data from the plugin to 
 a newly created rule instance.  I hit on the notion of using categories to 
 shuffle the values from the plugin instance to the rule instance and vice 
 versa. Two small dedicated categories for each plugin family (I have three 
 families at the moment). Seems a manageable scheme.  However, I am getting 
 an   "unrecognized selector sent to instance 0xyaddayadda" when I try to 
 run this. I know the selector does exist, so I must have a scoping issue 
 (?)
>>> 
>>> What exactly is the unrecognized selector message you get?
>>> 
>> 
>> 
>> 2012-07-04 20:43:50.180 Trixie[422:303] -[RSLocatorView requestPopover:]- 
>> [0098] 
>> 2012-07-04 20:44:02.980 Trixie[422:303] 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:]- [0015] 
>> plugin.action: addClass
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
>> 2012-07-04 20:44:02.981 Trixie[422:303] -[RSReactionRule setAction:]: 
>> unrecognized selector sent to instance 0x101833fe0
>> 2012-07-04 20:44:02.983 Trixie[422:303] (
>>  0   CoreFoundation  0x7fff90996716 
>> __exceptionPreprocess + 198
>>  1   libobjc.A.dylib 0x7fff8c97c470 
>> objc_exception_throw + 43
>>  2   CoreFoundation  0x7fff90a2cd5a 
>> -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
>>  3   CoreFoundation  0x7fff90984c3e 
>> ___forwarding___ + 414
>>  4   CoreFoundation  0x7fff90984a28 
>> _CF_forwarding_prep_0 + 232
>>  5   Trixie  0x0001cf81 
>> -[RSReactionRule(RSReactionRuleFromPlugin) loadFromPlugin:] + 177
>>  6   Trixie  0x0001b6d9 
>> -[RSRuleWindowController addRuleToStore:] + 249
>>  7   AppKit  0x7fff91589599 
>> -[NSApplication sendAction:to:from:] + 342
>>  8   AppKit  0x7fff915893f7 -[NSControl 
>> sendAction:to:] + 85
>>  9   AppKit  0x7fff9158932b -[NSCell 
>> _sendActionFrom:] + 138
>>  10  AppKit  0x7fff91587813 -[NSCell 
>> trackMouse:inRect:ofView:untilMouseUp:] + 1855
>>  11  AppKit  0x7fff91587061 
>> -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
>>  12  AppKit  0x7fff915867dc -[NSControl 
>> mouseDown:] + 820
>>  13  AppKit  0x7fff9157e13e -[NSWindow 
>> sendEvent:] + 6853
>>  14  AppKit  0x7fff9157a274 
>> -[NSApplication sendEvent:] + 5761
>>  15  AppKit  0x7fff9148feaa 
>> -[NSApplication run] + 636
>>  16  AppKit  0x7fff91434886 
>> NSApplicationMain + 869
>>  17  Trixie  0x00011b12 main + 34
>>  18  libdyld.dylib   0x7fff8f9e27e1 start + 0
>> )
>> 
>> 
>> 
>>> Are there any static libraries involved in your build process? Categories 
>>> compiled into static libraries require special treatment.
>>> -- 
>>> Greg Parker gpar...@apple.com Runtime Wrangler
>>> 
>> 
>> I am only using the home-built loader framework as mentioned.  No other 
>> external-to-Cocoa libs.
>> 
>> I opted to use categories in this case to avoid having to directly modify my 
>> framework. But if there is as Graham suggested a load order issue, I might 
>> be better off implementing the method natively in the framework. I pretty 
>> much have the cod

Re: rotating NSBezierPath objects

2012-07-06 Thread Graham Cox

On 07/07/2012, at 10:10 AM, William Squires wrote:

> Okay, I see in the doc set that you can perform an NSAffineTransform on an 
> NSBezierPath, but how do I perform a rotation of the NSBezierPath about an 
> arbitrary CGPoint and with a specified angle in radians?


Exactly that - use [NSAffineTransform transformBezierPath:]

You just have to set up the transform correctly (see below)

> Is this something deep in CoreGraphics, or CoreAnimation? If not, I can do 
> the trigonometry myself if I can get the list of points that make up the 
> NSBezierPath, but it seems these aren't exposed, only NSBezierPathElement 
> objects. Help!
>  Also, what is the formula for calculating the area of an arbitrary triangle 
> defined by three non-collinear points in 2D space? (i.e. I can't assume the 
> triangle even has a 90 degree angle in it, or any other such shortcuts…)

Google it, there are loads of geometry answers out there. One I use which is 
overkill for this is to calculate the area of an arbitrary polygon:

(This is a category on NSBezierPath, but the path must be flattened first - it 
doesn't work if there are curve segments)


- (CGFloat) signedAreaOfFlattenedPath
{
if([self isEmpty])
return 0;

NSInteger   m, i, j;
CGFloat a = 0;
NSPoint ap, np;

m = [self elementCount];

for( i = 0; i < m; ++i )
{
j = (i + 1) % m;

[self elementAtIndex:i associatedPoints:&ap];
[self elementAtIndex:j associatedPoints:&np];

// because we are using a flattened path, we can be sure there 
are no curve elements

a += ((ap.x * np.y) - (np.x * ap.y));
}

return a * 0.5;
}




>  Finally, If an NSBezierPath consisting of a closed circuit of points:
> 
> …
> NSBezierPath *mySquarePath = [NSBezierPath bezierPath];
> 
> [mySquarePath setLineWidth:1.0];
> [mySquarePath moveToPoint:CGPointMake(0.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 10.0)];
> [mySquarePath lineToPoint:CGPointMake(0.0, 10.0)];
> [mySquarePath closePath];
> …
> 
> will [mySquarePath containsPoint:CGPointMake(5.0, 5.0)] return YES even 
> before I fill or stroke the path, or do I have to fill the path first?

Yes. A path is a mathematical definition, it has nothing to do with graphics. 


Rotating a path: (again a category method on NSBezierPath)

- (NSBezierPath*)   rotatedPath:(CGFloat) angle 
aboutPoint:(NSPoint) cp
{
// return a rotated copy of the receiver. The origin is taken as point 
 relative to the original path.
// angle is a value in radians

if( angle == 0.0 )
return self;
else
{
NSBezierPath* copy = [self copy];

NSAffineTransform*  xfm = RotationTransform( angle, cp );
[copy transformUsingAffineTransform:xfm];

return [copy autorelease];
}
}

which uses:

NSAffineTransform*  RotationTransform( const CGFloat angle, const NSPoint 
cp )
{
// return a transform that will cause a rotation about the point given 
at the angle given

NSAffineTransform*  xfm = [NSAffineTransform transform];
[xfm translateXBy:cp.x yBy:cp.y];
[xfm rotateByRadians:angle];
[xfm translateXBy:-cp.x yBy:-cp.y];

return xfm;
}



--Graham




___

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

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

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

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

Re: rotating NSBezierPath objects

2012-07-06 Thread Roland King




On 7 Jul, 2012, at 8:10 AM, William Squires  wrote:

>  Okay, I see in the doc set that you can perform an NSAffineTransform on an 
> NSBezierPath, but how do I perform a rotation of the NSBezierPath about an 
> arbitrary CGPoint and with a specified angle in radians? Is this something 
> deep in CoreGraphics, or CoreAnimation? If not, I can do the trigonometry 
> myself if I can get the list of points that make up the NSBezierPath, but it 
> seems these aren't exposed, only NSBezierPathElement objects. Help!

Make one affine transform which translates the point you want to rotate around 
to the origin, rotates, then translates it back. Just use the NSAffineTransrorm 
functions to concatenate the three operations and apply it. 

>  Also, what is the formula for calculating the area of an arbitrary triangle 
> defined by three non-collinear points in 2D space? (i.e. I can't assume the 
> triangle even has a 90 degree angle in it, or any other such shortcuts…)

Google it, I just did. There's 100s of answers. Pick the one which suits you 
best. 

>  Finally, If an NSBezierPath consisting of a closed circuit of points:
> 
> …
> NSBezierPath *mySquarePath = [NSBezierPath bezierPath];
> 
> [mySquarePath setLineWidth:1.0];
> [mySquarePath moveToPoint:CGPointMake(0.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 0.0)];
> [mySquarePath lineToPoint:CGPointMake(10.0, 10.0)];
> [mySquarePath lineToPoint:CGPointMake(0.0, 10.0)];
> [mySquarePath closePath];
> …
> 
> will [mySquarePath containsPoint:CGPointMake(5.0, 5.0)] return YES even 
> before I fill or stroke the path, or do I have to fill the path first?
> 
> 

Yes it will return YES. Why not just write the code and confirm it for 
yourself. 

> 

___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread Ken Thomases
On Jul 6, 2012, at 1:01 PM, Stephen J. Butler wrote:

> On Fri, Jul 6, 2012 at 4:35 AM, ecir hana  wrote:
>> Sorry I should've said that before: no, I'm on 10.6.
>> 
>> But thanks for the reply!
> 
> You're positive you're linking against the 10.6 SDK? Even if you're on
> 10.6 you might be linking against the 10.5 SDK and that would explain
> your problem perfectly.

It wouldn't matter.  If you have the "class-dump" tool, you can use it on the 
10.6 or 10.7 AppKit framework.  You'll see that most of the Cocoa protocols are 
present, but NSApplicationDelegate isn't.


On Jul 6, 2012, at 5:09 AM, ecir hana wrote:

> On Fri, Jul 6, 2012 at 11:56 AM, Ken Thomases  wrote:
> 
>>> Is there a way to get NSApplicationDelegate protocol besides the
>>> compile-time "@protocol()"?
>> 
>> No.  The run-time information about the protocol is obtained from
>> information that would have to have been baked into the executable at build
>> time.
>> 
>> 
>>> Also, when I do:
>>> 
>>>   Protocol *protocol = objc_getProtocol("NSTextViewDelegate");
>>> 
>>> return the protocol even when I didn't create any textviews...?
>> 
>> You have presumably loaded AppKit, and AppKit does have the protocol
>> details for NSTextViewDelegate baked into it, because it includes classes
>> which adopt it and/or code which uses @protocol(NSTextViewDelegate).
>> 
> 
> Thank you. And please, can you explain to me why is it that case? Is it 
> simply because AppKit includes the definition of NSTextViewDelegate protocol 
> and not includes one for NSApplicationDelegate?

Correct.

> Is it somewhere documented which protocols are not included?

I doubt it.  It's not that anybody made a conscious decision to omit 
NSApplicationDelegate.  It's just a consequence of how the code was written and 
what the compiler and linker do.

> I mean, besides NSApplicationDelegate, what other delegate definitions cannot 
> be obtained at runtime?

Who knows.  It depends entirely on what the AppKit code used and what the 
compiler and linker did with that.

> Or is there anything like AppKit which, after being loaded, provides the 
> definitions?

Anything which referenced them in the described manner (includes a class which 
adopted them or code which references them via @protocol()).

Regards,
Ken


___

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

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

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

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


NSTextView scrolls to top when text storage changes

2012-07-06 Thread Martin Hewitson
Dear List,

I have a document managing app which has a project search feature for searching 
through the project's managed files (see thread "Dynamic modification of text 
search results" earlier this week). 

When I find search matches I add an attribute to the textstorage in which the 
search term was found. For the file/textstorage that is currently displayed in 
the editor (the NSTextView), this has the consequence of scrolling the text 
view to the top. The selection is not changed - just the scrollview jumps to 
the top. 

I assume this must be a bug. I've checked every place in the code where I 
respond to NSTextStorageDidProcessEditingNotification, and none of these is 
responsible for the scrolling.

Has anyone else seen this behaviour? Is this a known issue? If so, is there a 
workaround?

Many thanks,

Martin



___

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: NSTextView scrolls to top when text storage changes

2012-07-06 Thread Martin Hewitson
OK, I found the problem. Turns out I had left the textview associated with more 
than one textstorage. I'm surprised that this was the only symptom. In detail, 
when switching tabs in the editor, I forgot to remove the textview from all 
other text containers before assigning it to the file associated with the new 
tab. Silly. 

Martin

On 7, Jul, 2012, at 06:47 AM, Martin Hewitson wrote:

> Dear List,
> 
> I have a document managing app which has a project search feature for 
> searching through the project's managed files (see thread "Dynamic 
> modification of text search results" earlier this week). 
> 
> When I find search matches I add an attribute to the textstorage in which the 
> search term was found. For the file/textstorage that is currently displayed 
> in the editor (the NSTextView), this has the consequence of scrolling the 
> text view to the top. The selection is not changed - just the scrollview 
> jumps to the top. 
> 
> I assume this must be a bug. I've checked every place in the code where I 
> respond to NSTextStorageDidProcessEditingNotification, and none of these is 
> responsible for the scrolling.
> 
> Has anyone else seen this behaviour? Is this a known issue? If so, is there a 
> workaround?
> 
> Many thanks,
> 
> Martin
> 
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson







___

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: Getting NSApplicationDelegate protocol

2012-07-06 Thread ecir hana
On Sat, Jul 7, 2012 at 6:30 AM, Ken Thomases  wrote:

> >
> > Thank you. And please, can you explain to me why is it that case? Is it
> simply because AppKit includes the definition of NSTextViewDelegate
> protocol and not includes one for NSApplicationDelegate?
>
> Correct.
>
> > Is it somewhere documented which protocols are not included?
>
> I doubt it.  It's not that anybody made a conscious decision to omit
> NSApplicationDelegate.  It's just a consequence of how the code was written
> and what the compiler and linker do.
>
> > I mean, besides NSApplicationDelegate, what other delegate definitions
> cannot be obtained at runtime?
>
> Who knows.  It depends entirely on what the AppKit code used and what the
> compiler and linker did with that.
>
> > Or is there anything like AppKit which, after being loaded, provides the
> definitions?
>
> Anything which referenced them in the described manner (includes a class
> which adopted them or code which references them via @protocol()).
>
>
Thank you so much for the explanation!
___

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