Re: I want my app to crash!

2009-06-17 Thread Andreas Grosam


On Jun 17, 2009, at 3:27 AM, Jim Correia wrote:


On Jun 16, 2009, at 6:58 PM, Andreas Grosam wrote:


On Jun 16, 2009, at 11:33 PM, Jim Correia wrote:

Another example is chained message sends where an inner message  
send may return nil.


MyClass *obj = [[MyClass alloc] init];


You can do this, if you program is error-agnostic - or handles nil  
objects in some seamless fashion so that the existence of nil  
objects is the normal case. In fact, I think this is possible,  
however only in a very limited scope.


Otherwise, you simply ignore the fact that there might be an error  
either intentionally or unknowingly.


Unfortunately, I failed so far to accomplish to create a program  
that is nil-object-agnostic across the whole code - I fear this is  
impossible for a reasonable complex program. So, honestly, it's far  
*easier* to ensure eventually that an object is not nil, or have  
otherwise ensured that your program never takes the error path,  
that is, getting nil objects somewhere. Dealing with objects that  
might validly be nil, can quickly become a pita.


I'm not suggesting you write code that is nil object agnostic across  
the entire code base.


But it stands that a common Cocoa idiom is to write

MyClass *obj = [[MyClass alloc] init];

If messaging nil were suddenly a hard runtime error, millions of  
lines of code which look just like that would be problematic.
They potentially are - no matter if the runtime allows sending to nil  
receivers without issuing diagnostic messages or not.


This statement is only not problematic when
a)  you ensure your init method will always return a valid object or  
otherwise throw an exception or terminate the program.
b)  your init routine cleans up properly on an error and returns nil,  
AND the client code can handle nil objects properly.




Valid code which reads

if ([string length] > 0) { do something }


When reading this code, it implies to me that string may NOT be  
validly nil - AND  it has been ensured that string is never nil at  
this moment.
I think, it is in no way clear for the reader of the code, that this  
statement is also valid for nil receivers. Please, if this is  
intentionally the case, add a comment or write it explicit.



would have to be replaced with the slightly more verbose

if (string != nil && [string length] > 0) { do something }


This code implies to me that string may be validly nil - that is, it  
is no error when string equals nil.
If you have to write this instead of the above code, you have a  
(potentially) bug in your code above - or at least it's a dangerous  
programming style.


The last code statement is also incorrect if you want to check for  
errors where string equals nil:


Instead you have to write:
NSAssert(string);
if ([string length)] > 0) { ... }

or alternatively:

if (string != nil) {
do something
}
else {
   handle the error
}





For all practical purposes this ship has sailed. Sending a msg to  
nil is valid in Obj-C. Rather than wishing it were not :-),
The runtime allows receivers to be nil- and it may be "valid Obj-C".  
But if such a statement is valid according your program logic is  
totally different  ;)


When the runtime silently accepts nil receivers it does not mean that  
your code is correct.


Having examined your example and having said this, it should become  
clear that it would be very helpful when the runtime would send  
diagnostic messages when a receiver is nil - at least if there were a  
environment variable which could control it.
I cannot see from your examples above that there is any fact that  
supports your statement: "Sending a msg to nil is valid in Obj-C.  
Rather than wishing it were not ";)



it is more productive to discuss strategies for finding bugs where  
nil is an unintentional receiver.


True. And my suggestion was to add NSAssert or if (..) where  
appropriate. Preferable testing the code extensively with unit tests.


Once after you suspect the horse has already left the barn, you may  
consult dtrace or follow the excellent suggestions from BB.


However, I would prefer the runtime would optionally send a diagnostic  
message - and let *me* decide whether this is an error or not in my  
program. This would be the most effective strategy.



Regards
Andreas

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
is have this animation block with both Enlarge and Rotate, but only
one work properly (the last one listed).  what is the proper way to
group the two transforms together:

-=-=-=-
//Animation Block
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 / 2);

square.transform = enlarge;
square.transform = rotate;

[UIView commitAnimations];
-=-=-=-
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Desktop client for web application

2009-06-17 Thread Robert Černý
Hello guys,
I'm looking for a recommendation - where to start. I'm in need of
developing a desktop client for web application which (unfortunately)
doesn't have an API. My original idea was to mimics browser - parse
responses and POST commands. Is it the right way to do it or is there
a better method?

Thanks
Robert
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Jean-Daniel Dupas


Le 17 juin 09 à 10:53, Chunk 1978 a écrit :


is have this animation block with both Enlarge and Rotate, but only
one work properly (the last one listed).  what is the proper way to
group the two transforms together:

-=-=-=-
//Animation Block
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 / 2);

square.transform = enlarge;
square.transform = rotate;

[UIView commitAnimations];
-=-=-=-



You should concat your transformations, not make two.

CGAffineTransform trans = CGAffineTransformMakeScale(1.5, 1.5);
trans = CGAffineTransformRotate(trans, 3.14 / 2);

or in your sample above:
square.transform  = CGAffineTransformConcat(enlarge, rotate);

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
thanks!  :)

On Wed, Jun 17, 2009 at 5:05 AM, Jean-Daniel
Dupas wrote:
>
> Le 17 juin 09 à 10:53, Chunk 1978 a écrit :
>
>> is have this animation block with both Enlarge and Rotate, but only
>> one work properly (the last one listed).  what is the proper way to
>> group the two transforms together:
>>
>> -=-=-=-
>>        //Animation Block
>>        [UIView beginAnimations:nil context:NULL];
>>        [UIView setAnimationDuration:1.0];
>>        [UIView setAnimationDelegate:self];
>>        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>>
>>        CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>>        CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 / 2);
>>
>>        square.transform = enlarge;
>>        square.transform = rotate;
>>
>>        [UIView commitAnimations];
>> -=-=-=-
>
>
> You should concat your transformations, not make two.
>
>        CGAffineTransform trans = CGAffineTransformMakeScale(1.5, 1.5);
>        trans = CGAffineTransformRotate(trans, 3.14 / 2);
>
> or in your sample above:
>        square.transform  = CGAffineTransformConcat(enlarge, rotate);
>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
CGAffineTransformConcat() only allow for 2 arguments.  so in the case
where i have 3 transforms, i had to concatenate the first 2 to make
"Group1", and then concatenate that with the final transform:

-=-=-=-
//Animation Block
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14);

CGAffineTransform group1 = CGAffineTransformConcat(enlarge, rotate);
CGAffineTransform move = CGAffineTransformMakeTranslation(100, 50);

square.transform = CGAffineTransformConcat(group1, move);

[UIView commitAnimations];
-=-=-=-

it seems to work find, but is this the most ideal way of doing this?




On Wed, Jun 17, 2009 at 5:21 AM, Chunk 1978 wrote:
> thanks!  :)
>
> On Wed, Jun 17, 2009 at 5:05 AM, Jean-Daniel
> Dupas wrote:
>>
>> Le 17 juin 09 à 10:53, Chunk 1978 a écrit :
>>
>>> is have this animation block with both Enlarge and Rotate, but only
>>> one work properly (the last one listed).  what is the proper way to
>>> group the two transforms together:
>>>
>>> -=-=-=-
>>>        //Animation Block
>>>        [UIView beginAnimations:nil context:NULL];
>>>        [UIView setAnimationDuration:1.0];
>>>        [UIView setAnimationDelegate:self];
>>>        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>>>
>>>        CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>>>        CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 / 2);
>>>
>>>        square.transform = enlarge;
>>>        square.transform = rotate;
>>>
>>>        [UIView commitAnimations];
>>> -=-=-=-
>>
>>
>> You should concat your transformations, not make two.
>>
>>        CGAffineTransform trans = CGAffineTransformMakeScale(1.5, 1.5);
>>        trans = CGAffineTransformRotate(trans, 3.14 / 2);
>>
>> or in your sample above:
>>        square.transform  = CGAffineTransformConcat(enlarge, rotate);
>>
>>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: I want my app to crash!

2009-06-17 Thread Andreas Grosam

Uhps - sent this to the wrong list. I apologize. Please ignore.

On Jun 17, 2009, at 10:33 AM, Andreas Grosam wrote:

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Graham Cox


On 17/06/2009, at 7:37 PM, Chunk 1978 wrote:


it seems to work find, but is this the most ideal way of doing this?



Yes, it's the correct way to do it.

If you read the article that Jean linked on Wikipedia, you would see  
what's going on. A transform is just a matrix, and a concatenation is  
just a matrix multiply, so you are doing an operation like m1 x m2 x  
m3. However, do note that in matrix maths, (m1 x m2) is not the same  
as (m2 x m1) as it is in scalar maths (i.e. it's not commutative), so  
the order of operations matters. If you don't get the outcome you  
expected, this is usually the reason for it.


--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Jean-Daniel Dupas

Concatenation is just a matrix multiplication:

http://developer.apple.com/documentation/graphicsimaging/Conceptual/drawingwithquartz2d/dq_affine/dq_affine.html#/ 
/apple_ref/doc/uid/TP30001066-CH204-CJBECIAD


So yes, you can do that.

It's just a matter of taste, but I would write it like that instead:

CGAffineTransform transform = CGAffineTransformMakeScale(1.5, 1.5);
transform = CGAffineTransformRotate(transform, 3.14);
transform = CGAffineTransformTranslate(transform, 100, 50);

square.transform = transform;


Le 17 juin 09 à 11:37, Chunk 1978 a écrit :


CGAffineTransformConcat() only allow for 2 arguments.  so in the case
where i have 3 transforms, i had to concatenate the first 2 to make
"Group1", and then concatenate that with the final transform:

-=-=-=-
//Animation Block
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14);

CGAffineTransform group1 = CGAffineTransformConcat(enlarge, rotate);
CGAffineTransform move = CGAffineTransformMakeTranslation(100, 50);

square.transform = CGAffineTransformConcat(group1, move);

[UIView commitAnimations];
-=-=-=-

it seems to work find, but is this the most ideal way of doing this?




On Wed, Jun 17, 2009 at 5:21 AM, Chunk 1978  
wrote:

thanks!  :)

On Wed, Jun 17, 2009 at 5:05 AM, Jean-Daniel
Dupas wrote:


Le 17 juin 09 à 10:53, Chunk 1978 a écrit :


is have this animation block with both Enlarge and Rotate, but only
one work properly (the last one listed).  what is the proper way to
group the two transforms together:

-=-=-=-
   //Animation Block
   [UIView beginAnimations:nil context:NULL];
   [UIView setAnimationDuration:1.0];
   [UIView setAnimationDelegate:self];
   [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

   CGAffineTransform enlarge =  
CGAffineTransformMakeScale(1.5, 1.5);
   CGAffineTransform rotate =  
CGAffineTransformMakeRotation(3.14 / 2);


   square.transform = enlarge;
   square.transform = rotate;

   [UIView commitAnimations];
-=-=-=-



You should concat your transformations, not make two.

   CGAffineTransform trans = CGAffineTransformMakeScale(1.5,  
1.5);

   trans = CGAffineTransformRotate(trans, 3.14 / 2);

or in your sample above:
   square.transform  = CGAffineTransformConcat(enlarge, rotate);





___

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:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: I want my app to crash!

2009-06-17 Thread M Pulis


On Jun 17, 2009, at 1:33 AM, Andreas Grosam wrote:



On Jun 17, 2009, at 3:27 AM, Jim Correia wrote:


On Jun 16, 2009, at 6:58 PM, Andreas Grosam wrote:


On Jun 16, 2009, at 11:33 PM, Jim Correia wrote:

Another example is chained message sends where an inner message  
send may return nil.


MyClass *obj = [[MyClass alloc] init];


You can do this, if you program is error-agnostic - or handles  
nil objects in some seamless fashion so that the existence of nil  
objects is the normal case. In fact, I think this is possible,  
however only in a very limited scope.


Otherwise, you simply ignore the fact that there might be an  
error either intentionally or unknowingly.


Unfortunately, I failed so far to accomplish to create a program  
that is nil-object-agnostic across the whole code - I fear this  
is impossible for a reasonable complex program. So, honestly,  
it's far *easier* to ensure eventually that an object is not nil,  
or have otherwise ensured that your program never takes the error  
path, that is, getting nil objects somewhere. Dealing with  
objects that might validly be nil, can quickly become a pita.


I'm not suggesting you write code that is nil object agnostic  
across the entire code base.


But it stands that a common Cocoa idiom is to write

MyClass *obj = [[MyClass alloc] init];

If messaging nil were suddenly a hard runtime error, millions of  
lines of code which look just like that would be problematic.
They potentially are - no matter if the runtime allows sending to  
nil receivers without issuing diagnostic messages or not.





I'm with AG on this... I would add:

Most of us see the alloc init pattern when learning from example code  
for a quick feature demo. For purposes of brevity, example code is  
never meant to demonstrate error handling, much like I don't expect  
to see MyClass in shipping source.


There is no shame in writing verbose, defensive code, simply long  
term stability when insulated from lower level implementation  
details. Particularly in resource limited environments like iPhone.


Just don't program like an idiom. :-)

MP

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[iPhone] Strange behavior with modal view controllers

2009-06-17 Thread WT

Hi there,

I'll ask the question first, then I'll explain why I'm asking it.

Is there any known reason whatsoever why presentModalViewController  
would do absolutely nothing?


In an iPhone game app I'm working on, I have a tab-bar with 5 items, 2  
of which are managed by the SettingsViewController and the  
GameViewController, respectively. The player can freely switch between  
any two views by tapping the appropriate button on the tab-bar,  
*except* that - once the game view has been switched into - the player  
can only switch between the game view and the settings view. This  
allows the player to change settings within the app, but without being  
in a game, as well as while playing a game, and prevents the player  
from accessing other views that are not supposed to be accessible  
during game play.


In order to implement this, I use the tab-bar delegate method - 
tabBarController: shouldSelectViewController: to detect when the  
player is attempting to switch to the game view, make the game view  
controller the active one (directly, not through the tab-bar  
controller), release the tab-bar controller, and then return NO:


- (BOOL) tabBarController: (UITabBarController*) tab_bar_controller
 shouldSelectViewController: (UIViewController*)  
view_controller

{
BaseViewController* curVC = (BaseViewController*)  
tabBarController.selectedViewController;

BaseViewController* newVC = (BaseViewController*) view_controller;

NSUInteger kindOfCurVC = curVC.viewControllerKind;
NSUInteger kindOfNewVC = newVC.viewControllerKind;

if (kindOfNewVC == kindOfCurVC)
{
// Since the tab-bar view responds to taps on an already
// selected tab-bar item, and we don't want to do work that
// has already been done, we should return NO in this case.

return NO;
}
else
if (kindOfNewVC == kViewControllerKindGame)
{
// Switching to the game view. Return NO because
// the active view controller will change directly
// to the game view controller and the tab-bar controller
// will never get a chance to switch to the game view.

[tabBarController.view removeFromSuperview];
[window addSubview: gameViewController.view];

[tabBarController release];
 tabBarController = nil;

return NO;
}
else
{
// Switching to a view other than the game view.

return YES;
}
}

At this point, it's as if I never had a tab-bar controller. Of course,  
I need to have retained both the SettingsViewController and the  
GameViewController, which I did when I grabbed them from the tab-bar  
view controllers array back in the -applicationDidFinishLaunching:  
method.


So, now, when I want to switch between the game and settings views, I  
use a modal view controller scheme, with the SettingsViewController  
being the modal partner of the GameViewController. I also have a  
button on the settings view, that is hidden when the settings view  
controller is being managed by the tab-bar but visible when not. The  
button's action triggers the dismissal of the modal behavior,  
returning to the game view.


Everything works great, except for one thing: the call

[gameViewController presentModalViewController: settingsViewController  
animated: YES];


does absolutely nothing! Moreover, I've verified that, after that  
call, gameViewController.modalViewController is nil. The AppDelegate  
method


- (void) switchFromGameToSettings
{
NSLog(@"AppDelegate: -switchFromGameToSettings");

[gameViewController presentModalViewController:  
settingsViewController animated: YES];


NSLog(@"settingsViewController = %@", settingsViewController);
NSLog(@"gameViewController = %@", gameViewController);
NSLog(@"gameViewController.modalViewController = %@",  
gameViewController.modalViewController);


// Tell the settings view controller that it is now in-game.
settingsViewController.inGame = YES;
}

(triggered by a tap on the appropriate button on the game view, which  
triggers an action method in the game view controller, which calls - 
switchFromGameToSettings on the application delegate)


results in:

AppDelegate: -switchFromGameToSettings
settingsViewController = 
gameViewController = 
gameViewController.modalViewController = (null)

My first thought was that perhaps either one or both of the view  
controllers might still be tied up with the tab-bar controller,  
somehow, even though I've killed the tab-bar by this point. So, I  
tried a little hack where I create a fresh new pair of view  
controllers just prior to the presentModalViewController call, and now  
things do work correctly.


A little more investigation then revealed that I don't need to have a  
fresh new SettingsViewController object, ie, the one I grabbed from  
the tab-bar works just fine. The problem is then with the  
GameViewController object.


Now, since the game view does appear on

Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
i see how you write looks cleaner, is easier to follow.  but i now
have first hand experience with the matrix multiplications with
unexpected results as your code has different results than mine.
CGAffineTransformTranslate lands in a different space.  interesting :)

On Wed, Jun 17, 2009 at 6:26 AM, Jean-Daniel
Dupas wrote:
> Concatenation is just a matrix multiplication:
>
> http://developer.apple.com/documentation/graphicsimaging/Conceptual/drawingwithquartz2d/dq_affine/dq_affine.html#//apple_ref/doc/uid/TP30001066-CH204-CJBECIAD
>
> So yes, you can do that.
>
> It's just a matter of taste, but I would write it like that instead:
>
> CGAffineTransform transform = CGAffineTransformMakeScale(1.5, 1.5);
> transform = CGAffineTransformRotate(transform, 3.14);
> transform = CGAffineTransformTranslate(transform, 100, 50);
>
> square.transform = transform;
>
>
> Le 17 juin 09 à 11:37, Chunk 1978 a écrit :
>
>> CGAffineTransformConcat() only allow for 2 arguments.  so in the case
>> where i have 3 transforms, i had to concatenate the first 2 to make
>> "Group1", and then concatenate that with the final transform:
>>
>> -=-=-=-
>>        //Animation Block
>>        [UIView beginAnimations:nil context:NULL];
>>        [UIView setAnimationDuration:.5];
>>        [UIView setAnimationDelegate:self];
>>        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>>
>>        CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>>        CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14);
>>
>>        CGAffineTransform group1 = CGAffineTransformConcat(enlarge,
>> rotate);
>>        CGAffineTransform move = CGAffineTransformMakeTranslation(100, 50);
>>
>>        square.transform = CGAffineTransformConcat(group1, move);
>>
>>        [UIView commitAnimations];
>> -=-=-=-
>>
>> it seems to work find, but is this the most ideal way of doing this?
>>
>>
>>
>>
>> On Wed, Jun 17, 2009 at 5:21 AM, Chunk 1978 wrote:
>>>
>>> thanks!  :)
>>>
>>> On Wed, Jun 17, 2009 at 5:05 AM, Jean-Daniel
>>> Dupas wrote:

 Le 17 juin 09 à 10:53, Chunk 1978 a écrit :

> is have this animation block with both Enlarge and Rotate, but only
> one work properly (the last one listed).  what is the proper way to
> group the two transforms together:
>
> -=-=-=-
>       //Animation Block
>       [UIView beginAnimations:nil context:NULL];
>       [UIView setAnimationDuration:1.0];
>       [UIView setAnimationDelegate:self];
>       [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>
>       CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>       CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 /
> 2);
>
>       square.transform = enlarge;
>       square.transform = rotate;
>
>       [UIView commitAnimations];
> -=-=-=-


 You should concat your transformations, not make two.

       CGAffineTransform trans = CGAffineTransformMakeScale(1.5, 1.5);
       trans = CGAffineTransformRotate(trans, 3.14 / 2);

 or in your sample above:
       square.transform  = CGAffineTransformConcat(enlarge, rotate);


>>>
>> ___
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
>>
>> This email sent to devli...@shadowlab.org
>>
>
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: I want my app to crash!

2009-06-17 Thread Andy Lee

On Jun 17, 2009, at 6:29 AM, M Pulis wrote:
Most of us see the alloc init pattern when learning from example  
code for a quick feature demo. For purposes of brevity, example code  
is never meant to demonstrate error handling, much like I don't  
expect to see MyClass in shipping source.


The reason for the alloc/init idiom is to avoid this easy-to-make  
mistake:


MyClass *myObject = [MyClass alloc];
[myObject init];

I don't mean this as an answer to the larger question about nil- 
messaging, but to point out that this is an explicitly recommended  
idiom, not just a way for the authors of the examples to save a few  
keystrokes.


--Andy

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: I want my app to crash!

2009-06-17 Thread M Pulis

Thanks, Andy. Excellent point.

Seems to me I remember reading that... now!

After always checking for nil allocation and error codes on various  
systems (my style since '78) and reinforced by MacOS toolbox  
procedural programming from '83, it is hard to write what looks like  
trusting code.


It is easier to write, however, so I'll get there!

Apologies for the noise.

MP
(learning to chill out)

On Jun 17, 2009, at 4:37 AM, Andy Lee wrote:


On Jun 17, 2009, at 6:29 AM, M Pulis wrote:
Most of us see the alloc init pattern when learning from example  
code for a quick feature demo. For purposes of brevity, example  
code is never meant to demonstrate error handling, much like I  
don't expect to see MyClass in shipping source.


The reason for the alloc/init idiom is to avoid this easy-to-make  
mistake:


MyClass *myObject = [MyClass alloc];
[myObject init];

I don't mean this as an answer to the larger question about nil- 
messaging, but to point out that this is an explicitly recommended  
idiom, not just a way for the authors of the examples to save a few  
keystrokes.


--Andy


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: get ref to instance from IB

2009-06-17 Thread Paul M

On 17/06/2009, at 12:36 PM, Andy Lee wrote:

On Tuesday, June 16, 2009, at 08:10PM, "Paul M"  
wrote:

Thanks for all the good information here. It's helping a lot.
My data is largely static, if it does change it all changes, so if I
save references to all my wrappers, I can just dump the lot and start
over if there are changes.
I'll probably create them on an 'as required' basis to prevent a bump
at startup.
I think this should all be pretty simple, as you indicated with your
'cheap lunch' comment.

I'm still not clear on the first point thgough.


What is "File's Owner"? Whatever object that is, add IBOutlets to it
and wire them to the objects of interest in the nib. The outlets are
just ordinary ivars to the object that is "File's Owner".


'File's Owner' seems to be an instance of NSApplication. I cant add an
IBOutlet to this class, and when I subclass it, I find I cant
instatiate(sp) the subclass. I'm stumbling in the dark a bit here.


You don't want to instantiate the application class.  The application 
object will have been created for you before the main nib file is 
loaded.  What you do is, you tell IB to that object should be an 
instance of your application subclass instead of the default class.  
Select the File's Owner in the main nib file, and in the "Identity" 
tab of the Inspector (it's indicated with an "i" icon), type the name 
of your subclass.


Unlike most of the other objects in a nib (First Responder being the 
other exception), "File's Owner" is not an actual object "in" the nib. 
 It is a *placeholder* for an object that will be specified at runtime 
-- in this case, the application object.  At runtime, when a nib is 
loaded, a "file's owner" (some existing object in your program) is 
specified, and all the connections in the nib that went to "File's 
Owner" are connected to *that* object.


When you create your own nib files, you will decide what the File's 
Owner will be.  For the main nib file, it must be the application 
object.


BTW, you mention NSApplication but also UIController.  Is that a typo? 
 The default application class is UIApplication on the iPhone -- it's 
NSApplication on the Mac.


The UIController class is my own class which connects to all my UI 
elements. I added 2 IBOutlets to this class, then wired these to the 2 
instances of my DataSource class, so now I have references to these 
instances, which is just what I wanted. Just what Graham suggested at 
the beginning, except I'm using my own class instead of 'File's Owner'. 
After more testing it's working fine.

Now that I know what to do, it all seems reasonably simple.

Thanks again.




I just tried adding these outlets to my UIController class (this class
just needs to be visible where nesesary right?), made the nesesary 
code

changes ... and it seems to be working. It's late so I'll thrash on
this more tomorrow and make sure it's not some silly mistake ... but
here's hoping.


Big thanks to all who chipped in, I hope I dont have to bother you
again tomorrow.

paulm


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[iPhone] (follow-up) Strange behavior with modal view controllers

2009-06-17 Thread WT

Hello again,

I've since created a small project that shows exactly the problem I  
described. It's a 32 Kb download, found here:


http://www.restlessbrain.com/ModalVCTrouble.zip

For this small project, I stripped off all animations and any  
irrelevant code, so it's the smallest project I can come up with that  
presents the problem I described.


I'd greatly appreciate if someone could take a look at it and help me  
figure out what's wrong. Incidentally, you'll also notice a problem  
with the settings view resizing incorrectly, but that's irrelevant for  
the purpose at hand and it's a matter of setting the correct  
autoresizing masks anyway.


Thanks in advance.
Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: advice on background process

2009-06-17 Thread Rick C.
hello again,

i've had some time to work on this and just to follow up with a couple things.  
first the launchd task can tell me if there was a change but it seems there's 
no way to find out what that change was right?  it seems i could use this to 
launch my app but then if i have no way to screen what the changes might be 
then i would have to launch my app every time there's a change to see what it 
is.  as for the transformProcessType it seems to work actually but is there a 
way to transform back to the "hidden" state?

thanks again for the input,

rick






From: Jerry Krinock 
To: cocoa-dev 
Sent: Monday, June 15, 2009 9:01:06 AM
Subject: Re: advice on background process


On 2009 Jun 14, at 09:48, Michael Ash wrote:

> On Sun, Jun 14, 2009 at 7:19 AM, Rick C. wrote:

>> my project is fairly small and it monitors via notification certain 
>> directories for changes.
> 
> The most obvious way to do this would be to just have two
> applications. One is an LSUIElement which does the monitoring and any
> UI type stuff that's done during that, and the other is a regular
> application which talks to it.

Yes, split it into two as Mike recommends, but if that monitoring app's sole 
function is to watch certain directories for changes and you're requiring Mac 
OS 10.4 or later, you're in luck.  "Monitoring ... certain directories for 
changes" can be performed by installing a launchd task.  So you only need one 
app.  Read:

http://developer.apple.com/MacOsX/launchd.html

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/jo_phls%40yahoo.com

This email sent to jo_p...@yahoo.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Arranging NSStrings in a Table column

2009-06-17 Thread Arun
Hi All,

I have 3 NSStrings
How can i arrange mutiple strings with proper allignment in a table column
as below. Any ideas?


| 
|
|

|

|   |
|

|

| 
|
|

|
-


Thanks
Arun KA
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Arranging NSStrings in a Table column

2009-06-17 Thread WT
Use 3 labels or text-fields, align them in your table view cell using  
Interface Builder, set the appropriate justification (left, right, or  
center), and then use a couple of lines of code to set their text  
values with the actual strings you have.


Wagner

On Jun 17, 2009, at 3:13 PM, Arun wrote:


Hi All,

I have 3 NSStrings
How can i arrange mutiple strings with proper allignment in a table  
column

as below. Any ideas?


|  


|
|

|

|   
 |

|

|

|  


|
|

|
-


Thanks
Arun KA

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
alright... so i've been "playing" with this for a while now, and it's
quite baffling... with grouping CAAffineTransform, i can't seem to
understand the matrix math, and therefore have no real control over
the transforming object, namely the translation point.

premiss:  a red cube, 50 width x 50 height, located at {0,0}.  i want
to scale the cute 2 times it's width and height, move it to the center
of the screen, and rotate it 90º

-=-=-=-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGRect screen = [[UIScreen mainScreen] bounds];
CGPoint centerPoint = {CGRectGetMidX(screen), CGRectGetMidY(screen)};

CGAffineTransform transform = CGAffineTransformMakeScale(2, 2);
transform = CGAffineTransformTranslate(transform, centerPoint.x,
centerPoint.y);
transform = CGAffineTransformRotate(transform, kDegreesToRadian(90));

square.transform = transform;

[UIView commitAnimations];
-=-=-=-

so, because of this matrix multiplication (that is way over my head,
i'm not a math person), the above code moves the cube all the way the
the bottom right of the screen (but not to the very bottom right,
which confuses me).  however, if i don't scale the cube, leaving it at
CGAffineTransformMakeScale(1, 1), the translation works and the cube
goes to the center of the screen (but of course not i have no
scale)...

if the above code moved the cube to the very bottom right, i would
just assume that the Translate is being multiplied by the Scale, and
go with that, but it's not that simple, and it's kinda making me
crazy... is there a formula i can use?  or does multiplying
CGAffineTransform matrices generally warrant no control?



On Wed, Jun 17, 2009 at 6:45 AM, Chunk 1978 wrote:
> i see how you write looks cleaner, is easier to follow.  but i now
> have first hand experience with the matrix multiplications with
> unexpected results as your code has different results than mine.
> CGAffineTransformTranslate lands in a different space.  interesting :)
>
> On Wed, Jun 17, 2009 at 6:26 AM, Jean-Daniel
> Dupas wrote:
>> Concatenation is just a matrix multiplication:
>>
>> http://developer.apple.com/documentation/graphicsimaging/Conceptual/drawingwithquartz2d/dq_affine/dq_affine.html#//apple_ref/doc/uid/TP30001066-CH204-CJBECIAD
>>
>> So yes, you can do that.
>>
>> It's just a matter of taste, but I would write it like that instead:
>>
>> CGAffineTransform transform = CGAffineTransformMakeScale(1.5, 1.5);
>> transform = CGAffineTransformRotate(transform, 3.14);
>> transform = CGAffineTransformTranslate(transform, 100, 50);
>>
>> square.transform = transform;
>>
>>
>> Le 17 juin 09 à 11:37, Chunk 1978 a écrit :
>>
>>> CGAffineTransformConcat() only allow for 2 arguments.  so in the case
>>> where i have 3 transforms, i had to concatenate the first 2 to make
>>> "Group1", and then concatenate that with the final transform:
>>>
>>> -=-=-=-
>>>        //Animation Block
>>>        [UIView beginAnimations:nil context:NULL];
>>>        [UIView setAnimationDuration:.5];
>>>        [UIView setAnimationDelegate:self];
>>>        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>>>
>>>        CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>>>        CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14);
>>>
>>>        CGAffineTransform group1 = CGAffineTransformConcat(enlarge,
>>> rotate);
>>>        CGAffineTransform move = CGAffineTransformMakeTranslation(100, 50);
>>>
>>>        square.transform = CGAffineTransformConcat(group1, move);
>>>
>>>        [UIView commitAnimations];
>>> -=-=-=-
>>>
>>> it seems to work find, but is this the most ideal way of doing this?
>>>
>>>
>>>
>>>
>>> On Wed, Jun 17, 2009 at 5:21 AM, Chunk 1978 wrote:

 thanks!  :)

 On Wed, Jun 17, 2009 at 5:05 AM, Jean-Daniel
 Dupas wrote:
>
> Le 17 juin 09 à 10:53, Chunk 1978 a écrit :
>
>> is have this animation block with both Enlarge and Rotate, but only
>> one work properly (the last one listed).  what is the proper way to
>> group the two transforms together:
>>
>> -=-=-=-
>>       //Animation Block
>>       [UIView beginAnimations:nil context:NULL];
>>       [UIView setAnimationDuration:1.0];
>>       [UIView setAnimationDelegate:self];
>>       [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
>>
>>       CGAffineTransform enlarge = CGAffineTransformMakeScale(1.5, 1.5);
>>       CGAffineTransform rotate = CGAffineTransformMakeRotation(3.14 /
>> 2);
>>
>>       square.transform = enlarge;
>>       square.transform = rotate;
>>
>>       [UIView commitAnimations];
>> -=-=-=-
>
>
> You should concat your transformations, not make two.
>
>       CGAffineTransform trans 

Re: [iPhone] Strange behavior with modal view controllers

2009-06-17 Thread Michael Babin

On Jun 17, 2009, at 5:43 AM, WT wrote:

Is there any known reason whatsoever why presentModalViewController  
would do absolutely nothing?


Possibly, depending on the meaning of "known". In any case, let's  
investigate further using the sample project you put together  
(referenced in a follow-up message).


In an iPhone game app I'm working on, I have a tab-bar with 5 items,  
2 of which are managed by the SettingsViewController and the  
GameViewController, respectively. The player can freely switch  
between any two views by tapping the appropriate button on the tab- 
bar, *except* that - once the game view has been switched into - the  
player can only switch between the game view and the settings view.  
This allows the player to change settings within the app, but  
without being in a game, as well as while playing a game, and  
prevents the player from accessing other views that are not supposed  
to be accessible during game play.


In order to implement this, I use the tab-bar delegate method - 
tabBarController: shouldSelectViewController: to detect when the  
player is attempting to switch to the game view, make the game view  
controller the active one (directly, not through the tab-bar  
controller), release the tab-bar controller, and then return NO:


I'm not 100% certain, but I believe this delegate method is new in  
iPhone OS 3.0 (couldn't find it in the 2.2.1 docs). The project you  
put together also specifies the iPhone 3.0 SDK. I don't believe it is  
kosher to speak of these things on the list at this point, but we can  
easily switch to using the iPhone OS 2.2.1 SDK and substitute the - 
tabBarController:didSelectViewController: delegate method in their  
place.



- (BOOL) tabBarController: (UITabBarController*) tab_bar_controller
shouldSelectViewController: (UIViewController*)  
view_controller

{
   BaseViewController* curVC = (BaseViewController*)  
tabBarController.selectedViewController;

   BaseViewController* newVC = (BaseViewController*) view_controller;

   NSUInteger kindOfCurVC = curVC.viewControllerKind;
   NSUInteger kindOfNewVC = newVC.viewControllerKind;

   if (kindOfNewVC == kindOfCurVC)
   {
   // Since the tab-bar view responds to taps on an already
   // selected tab-bar item, and we don't want to do work that
   // has already been done, we should return NO in this case.

   return NO;
   }
   else
   if (kindOfNewVC == kViewControllerKindGame)
   {
   // Switching to the game view. Return NO because
   // the active view controller will change directly
   // to the game view controller and the tab-bar controller
   // will never get a chance to switch to the game view.

   [tabBarController.view removeFromSuperview];
   [window addSubview: gameViewController.view];

   [tabBarController release];
tabBarController = nil;

   return NO;
   }
   else
   {
   // Switching to a view other than the game view.

   return YES;
   }
}

At this point, it's as if I never had a tab-bar controller. Of  
course, I need to have retained both the SettingsViewController and  
the GameViewController, which I did when I grabbed them from the tab- 
bar view controllers array back in the - 
applicationDidFinishLaunching: method.


So, now, when I want to switch between the game and settings views,  
I use a modal view controller scheme, with the  
SettingsViewController being the modal partner of the  
GameViewController. I also have a button on the settings view, that  
is hidden when the settings view controller is being managed by the  
tab-bar but visible when not. The button's action triggers the  
dismissal of the modal behavior, returning to the game view.


Everything works great, except for one thing: the call

[gameViewController presentModalViewController:  
settingsViewController animated: YES];


does absolutely nothing! Moreover, I've verified that, after that  
call, gameViewController.modalViewController is nil. The AppDelegate  
method


- (void) switchFromGameToSettings
{
   NSLog(@"AppDelegate: -switchFromGameToSettings");

   [gameViewController presentModalViewController:  
settingsViewController animated: YES];


   NSLog(@"settingsViewController = %@", settingsViewController);
   NSLog(@"gameViewController = %@", gameViewController);
   NSLog(@"gameViewController.modalViewController = %@",  
gameViewController.modalViewController);


   // Tell the settings view controller that it is now in-game.
   settingsViewController.inGame = YES;
}

(triggered by a tap on the appropriate button on the game view,  
which triggers an action method in the game view controller, which  
calls -switchFromGameToSettings on the application delegate)


results in:

AppDelegate: -switchFromGameToSettings
settingsViewController = 
gameViewController = 
gameViewController.modalViewController = (null)

My first thought was that perhaps either one or both of the view  
controllers might still be tied up with 

repeatable random numbers in an object

2009-06-17 Thread Roland King
I need to generate repeatable sequences of random numbers for a game.  
For each level I give it the seed and want the level to unfold the  
same way it did before. I can guarantee that the calls to any random  
function will be in exactly the same order, so provided I get the same  
sequence out of the random generator, I'm good.


First thought was to use srand() [ yes it's a bad random number  
generator but it's good enough for what want ] however it's global and  
it's quite possible I'll have more than one 'level' running at the  
same time. So I need an object which I can give a seed to and will  
generate random numbers from that seed, and I need it to interoperate  
independently of any other object of the same type being queried for  
numbers.


I was thinking of wrapping the random(3) stuff [ initstate, random,  
setstate .. etc ] in a cocoa class and using them, just using  
setstate() each time before calling random(). I can guarantee this all  
on one thread so I will not have the issue that setstate() is called  
in one thread and random in another, thus totally messing up someone  
else's generator.


I had a hunt for an objective-C class which already did this but  
didn't find one. Anyone know of one or a better solution to this  
before I go write it? The sort of methods I'd expect are ..


MyRandom *myRandom = [ [ MyRandom alloc ] initWithSeed:seed ];
int nextRandom = [ myRandom nextRandom ];

where the sequence produced by myRandom is predictable and not  
affected by any other MyRandom objects out there.





___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Graham Cox


On 18/06/2009, at 12:21 AM, Chunk 1978 wrote:


premiss:  a red cube, 50 width x 50 height, located at {0,0}.  i want
to scale the cute 2 times it's width and height, move it to the center
of the screen, and rotate it 90º

-=-=-=-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

CGRect screen = [[UIScreen mainScreen] bounds];
CGPoint centerPoint = {CGRectGetMidX(screen), CGRectGetMidY(screen)};

CGAffineTransform transform = CGAffineTransformMakeScale(2, 2);
transform = CGAffineTransformTranslate(transform, centerPoint.x,
centerPoint.y);
transform = CGAffineTransformRotate(transform, kDegreesToRadian(90));

square.transform = transform;

[UIView commitAnimations];
-=-=-=-

so, because of this matrix multiplication (that is way over my head,
i'm not a math person), the above code moves the cube all the way the
the bottom right of the screen (but not to the very bottom right,
which confuses me).  however, if i don't scale the cube, leaving it at
CGAffineTransformMakeScale(1, 1), the translation works and the cube
goes to the center of the screen (but of course not i have no
scale)...

if the above code moved the cube to the very bottom right, i would
just assume that the Translate is being multiplied by the Scale, and
go with that, but it's not that simple, and it's kinda making me
crazy... is there a formula i can use?  or does multiplying
CGAffineTransform matrices generally warrant no control?


Of course you have complete control. The problem is that operations  
have to be performed in the right order.


It's fair to say that transforms can be a bit unintuitive - you expect  
them to perform the operations in the order you set. In fact, the  
reverse order is what it will actually do. (The explanation for this  
lies in the maths, but it sounds like you're not interested in that,  
in which case this might be a struggle).


Because all transformations take place relative to the origin (0,0),  
you generally need to ensure that the translation step, which moves it  
away from the origin, is performed last. This means it should be the  
FIRST operation listed in your code. The order of rotations and  
scaling is less critical.


So try starting with the translation, then scale, then rotate and see  
if it works. I find it helps to just read the list of operations in  
reverse, then I can "see" what it will do. In your case it will first  
rotate the shape (OK), then translate it to the centre of the screen,  
then scale it *relative to the origin*, which is now a long way away,  
so the object will end up scale * distance away, which is not where  
you wanted it.


--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: repeatable random numbers in an object

2009-06-17 Thread Roland King
Not a horrible idea, but the 'levels' could be pretty open-ended if  
you're good at the game (eg think the numbers were choosing what piece  
is next in tetris, if you are the kind of person who can play level 1  
for 3 hours you need a lot of numbers) so I'd prefer to generate them  
from a seed if practical.



It's not Tetris by the way, really, honestly, I am not writing another  
version of Tetris.


On Jun 17, 2009, at 10:37 PM, Brian Dittmer wrote:


Why not generate random numbers the first time each level is run and
then just store those numbers (fs if you want them across app loads,
in-memory otherwise) somewhere for all subsequent runs?

Regards,
Brian Dittmer

On Wed, Jun 17, 2009 at 10:33 AM, Roland King wrote:
I need to generate repeatable sequences of random numbers for a  
game. For
each level I give it the seed and want the level to unfold the same  
way it
did before. I can guarantee that the calls to any random function  
will be in
exactly the same order, so provided I get the same sequence out of  
the

random generator, I'm good.

First thought was to use srand() [ yes it's a bad random number  
generator
but it's good enough for what want ] however it's global and it's  
quite
possible I'll have more than one 'level' running at the same time.  
So I need
an object which I can give a seed to and will generate random  
numbers from
that seed, and I need it to interoperate independently of any other  
object

of the same type being queried for numbers.

I was thinking of wrapping the random(3) stuff [ initstate, random,  
setstate
.. etc ] in a cocoa class and using them, just using setstate()  
each time
before calling random(). I can guarantee this all on one thread so  
I will
not have the issue that setstate() is called in one thread and  
random in

another, thus totally messing up someone else's generator.

I had a hunt for an objective-C class which already did this but  
didn't find
one. Anyone know of one or a better solution to this before I go  
write it?

The sort of methods I'd expect are ..

MyRandom *myRandom = [ [ MyRandom alloc ] initWithSeed:seed ];
int nextRandom = [ myRandom nextRandom ];

where the sequence produced by myRandom is predictable and not  
affected by

any other MyRandom objects out there.




___

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:
http://lists.apple.com/mailman/options/cocoa-dev/brian.t.dittmer%40gmail.com

This email sent to brian.t.ditt...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: [iPhone] (SOLVED) Strange behavior with modal view controllers

2009-06-17 Thread WT

Hi Michael,

thanks for replying to my message.

I'm not 100% certain, but I believe this delegate method is new in  
iPhone OS 3.0 (couldn't find it in the 2.2.1 docs). The project you  
put together also specifies the iPhone 3.0 SDK. I don't believe it  
is kosher to speak of these things on the list at this point, but we  
can easily switch to using the iPhone OS 2.2.1 SDK and substitute  
the -tabBarController:didSelectViewController: delegate method in  
their place.


Oops... indeed. My apologies. I'll remove the 3.0 sample project as  
soon as I finish this message.


I suspect that the problem is that your view controllers (Game and  
Settings) are left in a "confused" state, with their parent view  
controller still referring to the removed and released  
UITabBarController. Since the parentViewController and  
tabBarController properties of the UIViewController are read-only,  
you can attack this from the other end by removing them from the  
UITabBarController's list of viewControllers before releasing it.  
Like so:


- (void)tabBarController:(UITabBarController *)tab_bar_controller
didSelectViewController:(UIViewController *)newVC
{
   if (newVC == gameViewController)
   {
   [tabBarController.view removeFromSuperview];
   [window addSubview: gameViewController.view];

	NSMutableArray *tabViewCtlrs = [[tabBarController viewControllers]  
mutableCopy];

[tabViewCtlrs removeObject:gameViewController];
[tabViewCtlrs removeObject:settingsViewController];
[tabBarController setViewControllers:tabViewCtlrs];
[tabViewCtlrs release];
tabViewCtlrs = nil;

   [tabBarController release];
tabBarController = nil;
   }
}

In my modified copy of your sample project, this change seems to do  
the trick.


Yes, on further investigation, I noticed that the settings view  
controller had its parentViewController set to the tab-bar controller  
instance, which was still alive and well. Clearly, an UIViewController  
instance retains its parent controller. Oddly enough, there doesn't  
seem to be a direct way to detach a former modal view controller from  
its parent. I assumed that calling -presentModalViewControler would  
reset the properties accordingly, but obviously that's not the case.  
If only parentController was writable...


Anyway, there's a simpler solution than yours, though along the same  
lines. Since I'm going to kill the tab-bar controller anyway, I can  
simply set its viewControllers property to nil before releasing the  
tab-bar controller.


Thanks again for your help.

Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Graham Cox


On 18/06/2009, at 12:37 AM, Graham Cox wrote:


On 18/06/2009, at 12:21 AM, Chunk 1978 wrote:


premiss:  a red cube, 50 width x 50 height, located at {0,0}.  i want
to scale the cute 2 times it's width and height, move it to the  
center

of the screen, and rotate it 90º





Incidentally there's a good introduction to Cocoa transforms here: http://cocoadevcentral.com/articles/45.php 
 which is easy to follow.


--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 4:37 PM, Graham Cox wrote:

It's fair to say that transforms can be a bit unintuitive - you  
expect them to perform the operations in the order you set. In fact,  
the reverse order is what it will actually do. (The explanation for  
this lies in the maths, but it sounds like you're not interested in  
that, in which case this might be a struggle).


For people with a background closer to programming and farther from  
math, it might be easier to think of matrix multiplication as a stack  
(the LIFO kind of data structure). What you write last is what gets  
done first when it comes to using matrices as operations on  
geometrical objects. So, the result of applying ABC to an object o  
(where A, B, and C are matrices) is that first C is applied to o, then  
B is applied to the result of that, then A is applied to the result of  
*that*. In reality, behind the curtains, it may be and often is the  
case that A, B, and C get multiplied together first and then the  
result of that is applied to o, but conceptually you can think of it  
as I described.


Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


re: repeatable random numbers in an object

2009-06-17 Thread Mr. George Warner

On Wed, 17 Jun 2009 22:33:50 +0800, Roland King  wrote:
> I need to generate repeatable sequences of random numbers for a game.
> For each level I give it the seed and want the level to unfold the
> same way it did before. I can guarantee that the calls to any random
> function will be in exactly the same order, so provided I get the  
same

> sequence out of the random generator, I'm good.

> First thought was to use srand() [ yes it's a bad random number
> generator but it's good enough for what want ] however it's global  
and

> it's quite possible I'll have more than one 'level' running at the
> same time. So I need an object which I can give a seed to and will
> generate random numbers from that seed, and I need it to interoperate
> independently of any other object of the same type being queried for
> numbers.

term> man rand_r
 ...
 The rand_r() function provides the same functionality as  
rand().  A pointer to the context value seed must be

 supplied by the caller.

The "pointer to the context value seed" can be a per-thread variable  
so that different contexts don't interfere with each other. ;-)


--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: advice on background process

2009-06-17 Thread Jerry Krinock


On 2009 Jun 17, at 05:58, Rick C. wrote:

the launchd task can tell me if there was a change but it seems  
there's no way to find out what that change was right?


Yes.

it seems i could use this to launch my app but then if i have no way  
to screen what the changes might be then i would have to launch my  
app every time there's a change to see what it is.


Well, maybe you still want two executables then.  But you could launch  
a small tool to "screen changes".  Simpler than one that must watch  
for changes and run 24/7.


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Gordon Apple
IMHO, matrix operations are one of the most confusing and cumbersome
aspects of Cocoa.  Every time I use them, I end up trying most combinations
until I get the desired result.  C++ doesn't have this problem.  You can
simply write the matrix equations and be done with it. I love Objective C,
but operator overloading (and ctors/dtors) are the things I miss most.
Multiple inheritance -- not so much.

> alright... so i've been "playing" with this for a while now, and it's
> quite baffling... with grouping CAAffineTransform, i can't seem to
> understand the matrix math, and therefore have no real control over
> the transforming object, namely the translation point.



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 9:14 AM, Gordon Apple wrote:
>    IMHO, matrix operations are one of the most confusing and cumbersome
> aspects of Cocoa.  Every time I use them, I end up trying most combinations
> until I get the desired result.  C++ doesn't have this problem.  You can
> simply write the matrix equations and be done with it. I love Objective C,
> but operator overloading (and ctors/dtors) are the things I miss most.
> Multiple inheritance -- not so much.

This isn't a C++/ObjC issue.  Whatever matrix library you were using
under C++ happened to define matrix multiplication in such a way that
it performed the operations in reverse order.  XNA, on the other hand,
follows the same pattern as Cocoa, even though it's written in C# and
therefore has operator overloading.

The AppKit team could very easily have implemented NSAffineTransform
to transparently define a stack.  But they didn't.  Neither did the
OpenGL people, or the XNA people.  But it's not a language issue.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: get ref to instance from IB

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 5:44 AM, Paul M wrote:
> The UIController class is my own class which connects to all my UI elements.
> I added 2 IBOutlets to this class, then wired these to the 2 instances of my
> DataSource class, so now I have references to these instances, which is just
> what I wanted. Just what Graham suggested at the beginning, except I'm using
> my own class instead of 'File's Owner'. After more testing it's working
> fine.

Just a note: File's Owner isn't a class; it's a stand-in for an object
that isn't stored in the nib but provided to it at run-time.  Though I
guess you knew that/figured that out because the one you were looking
at was declared to be an instance of UIApplication.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Desktop client for web application

2009-06-17 Thread Kyle Sluder
2009/6/17 Robert Černý :
> I'm looking for a recommendation - where to start. I'm in need of
> developing a desktop client for web application which (unfortunately)
> doesn't have an API. My original idea was to mimics browser - parse
> responses and POST commands. Is it the right way to do it or is there
> a better method?

If there's no API, this is probably what you're going to have to do.
Screen-scrape the site and mimic a browser using NSURLRequest.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Arranging NSStrings in a Table column

2009-06-17 Thread Kyle Sluder
Use three columns.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: repeatable random numbers in an object

2009-06-17 Thread Kirk Kerekes



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: repeatable random numbers in an object

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 9:54 AM, Kirk Kerekes wrote:
> 

Not to knock on Don Knuth, but I wouldn't recommend using that code in
your app.  There's a perfectly good RNG facility in the system as Mr.
George Warner pointed out, and Knuth's code is designed for a 32-bit
system.  While it will work on OS X (because we use LP64), it will be
wrong on Win64 (which uses ILP64) and will cause problems if you
upcast to NSUInteger on OS X.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: CFAttributedStringGetMutableString returning null value

2009-06-17 Thread Ali Ozer
This function has not been implemented for the pure-CoreFoundation  
case. This is mentioned in the header comments:


> (Note: This function is not yet implemented and will return NULL  
except for toll-free bridged instances.)


But it is not in the docs; should be.

As the comment implies, you can make this work by you calling - 
mutableString on the CFMutableAttributedString:


   CFMutableStringRef str = (CFStringRef) [(id)a mutableString];

Or you can access the string immutably through  
CFAttributedStringGetString(), or mutate the attributed string through  
CFAttributedStringReplaceString().


Ali




Begin forwarded message:



From: Travis Kirton 
Date: June 15, 2009 8:29:57 PM PDT
To: cocoa-dev@lists.apple.com
Subject: CFAttributedStringGetMutableString returning null value


I have a method, where I need to append to a MutableAttributedString
Here is the method...

- (void)appendStringFromSelf:(CFMutableAttributedStringRef)theString  
with:(

CFIndex)numberOfGlyphs

{

CFMutableStringRef mutableString = CFAttributedStringGetMutableString
(theString);

CFAttributedStringRef appendableString =
CFAttributedStringCreateWithSubstring(...);

CFStringAppend(mutableString,CFAttributedStringGetString 
(appendableString));


return;

}


What is strange is that the first line in this method:


CFMutableStringRef mutableString = CFAttributedStringGetMutableString
(theString);


mutableString is NULL even though variable-> theString is a non-null
MutableAttributedString


Does anyone know why this might be happening?


Cheers,

Travis


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
still having issues.  i've changed the order of transforms:

-=-=-=-
CGAffineTransform transform =
CGAffineTransformMakeTranslation(centerPoint.x, centerPoint.y);
transform = CGAffineTransformScale(transform, 2, 2);
transform = CGAffineTransformRotate(transform, 
kDegreesToRadian(90));
square.transform = transform;
-=-=-=-

although this code supposedly scales the Square before translating it
to it's new origin, it maintains the Squares original origin based on
it's original size.  so eventhough the Square is now twice as big, it
is translated to the center of the screen minus it's new scale.  i can
remedy it by adding this:

-=-=-=-
 CGRect squareFrame = [square frame];
CGAffineTransform transform =
CGAffineTransformMakeTranslation(centerPoint.x +
squareFrame.size.width / 2, centerPoint.y + squareFrame.size.height /
2);
-=-=-=-

but that seems like a hack...

any ideas?


On Wed, Jun 17, 2009 at 12:31 PM, Kyle Sluder wrote:
> On Wed, Jun 17, 2009 at 9:14 AM, Gordon Apple wrote:
>>    IMHO, matrix operations are one of the most confusing and cumbersome
>> aspects of Cocoa.  Every time I use them, I end up trying most combinations
>> until I get the desired result.  C++ doesn't have this problem.  You can
>> simply write the matrix equations and be done with it. I love Objective C,
>> but operator overloading (and ctors/dtors) are the things I miss most.
>> Multiple inheritance -- not so much.
>
> This isn't a C++/ObjC issue.  Whatever matrix library you were using
> under C++ happened to define matrix multiplication in such a way that
> it performed the operations in reverse order.  XNA, on the other hand,
> follows the same pattern as Cocoa, even though it's written in C# and
> therefore has operator overloading.
>
> The AppKit team could very easily have implemented NSAffineTransform
> to transparently define a stack.  But they didn't.  Neither did the
> OpenGL people, or the XNA people.  But it's not a language issue.
>
> --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:
> http://lists.apple.com/mailman/options/cocoa-dev/chunk1978%40gmail.com
>
> This email sent to chunk1...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Chunk 1978
... perhaps there's a way to set the transforming object's origin to
it's center some how?  i could work with that...

On Wed, Jun 17, 2009 at 2:37 PM, Chunk 1978 wrote:
> still having issues.  i've changed the order of transforms:
>
> -=-=-=-
>                CGAffineTransform transform =
> CGAffineTransformMakeTranslation(centerPoint.x, centerPoint.y);
>                transform = CGAffineTransformScale(transform, 2, 2);
>                transform = CGAffineTransformRotate(transform, 
> kDegreesToRadian(90));
>                square.transform = transform;
> -=-=-=-
>
> although this code supposedly scales the Square before translating it
> to it's new origin, it maintains the Squares original origin based on
> it's original size.  so eventhough the Square is now twice as big, it
> is translated to the center of the screen minus it's new scale.  i can
> remedy it by adding this:
>
> -=-=-=-
>             CGRect squareFrame = [square frame];
>                CGAffineTransform transform =
> CGAffineTransformMakeTranslation(centerPoint.x +
> squareFrame.size.width / 2, centerPoint.y + squareFrame.size.height /
> 2);
> -=-=-=-
>
> but that seems like a hack...
>
> any ideas?
>
>
> On Wed, Jun 17, 2009 at 12:31 PM, Kyle Sluder wrote:
>> On Wed, Jun 17, 2009 at 9:14 AM, Gordon Apple wrote:
>>>    IMHO, matrix operations are one of the most confusing and cumbersome
>>> aspects of Cocoa.  Every time I use them, I end up trying most combinations
>>> until I get the desired result.  C++ doesn't have this problem.  You can
>>> simply write the matrix equations and be done with it. I love Objective C,
>>> but operator overloading (and ctors/dtors) are the things I miss most.
>>> Multiple inheritance -- not so much.
>>
>> This isn't a C++/ObjC issue.  Whatever matrix library you were using
>> under C++ happened to define matrix multiplication in such a way that
>> it performed the operations in reverse order.  XNA, on the other hand,
>> follows the same pattern as Cocoa, even though it's written in C# and
>> therefore has operator overloading.
>>
>> The AppKit team could very easily have implemented NSAffineTransform
>> to transparently define a stack.  But they didn't.  Neither did the
>> OpenGL people, or the XNA people.  But it's not a language issue.
>>
>> --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:
>> http://lists.apple.com/mailman/options/cocoa-dev/chunk1978%40gmail.com
>>
>> This email sent to chunk1...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: repeatable random numbers in an object

2009-06-17 Thread Michael Ash
On Wed, Jun 17, 2009 at 1:05 PM, Kyle Sluder wrote:
> On Wed, Jun 17, 2009 at 9:54 AM, Kirk Kerekes wrote:
>> 
>
> Not to knock on Don Knuth, but I wouldn't recommend using that code in
> your app.  There's a perfectly good RNG facility in the system as Mr.
> George Warner pointed out, and Knuth's code is designed for a 32-bit
> system.  While it will work on OS X (because we use LP64), it will be
> wrong on Win64 (which uses ILP64) and will cause problems if you
> upcast to NSUInteger on OS X.

Nitpick: Windows is actually LLP64 (int and long are 32, long long and
pointers are 64) and so it will work fine there.

This is not to detract from your overall point in any way. If your
code needs precise sizes, use a data type which specifies the size
explicitly, like the standard int32_t and friends in stdint.h.

Mike
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 9:10 PM, Chunk 1978 wrote:


... perhaps there's a way to set the transforming object's origin to
it's center some how?  i could work with that...


The problem is a more subtle one than simply a question of what order  
in which to perform the transforms. What's happening is that as your  
cube scales in size, its origin changes and that screws up the  
translation.


I created a sample project that moves a small image from (0,0) to the  
center of the screen, while rotating it by 90 degrees and scaling it  
by a factor of 2 in each direction. You can download it from here:


http://www.restlessbrain.com/AffineTs.zip

Or you can simply look at the code below. The key lines are:

CGAffineTransform transform;

transform = CGAffineTransformMakeScale(kScaleX, kScaleY);
transform = CGAffineTransformTranslate(transform,
targetCenter.x / kScaleX, targetCenter.y / kScaleY);
transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90));

Note how you have to divide the target position coordinates by the  
same scale factor you're changing the size of the object you're  
applying the transform to.


The constants and macro are simply:

#define kAnimDuration   2.0

#define kScaleX 2.0
#define kScaleY 2.0

#define DEGS_TO_RADS(DEGS)  (DEGS * M_PI / 180.0)

- (IBAction) actionApplyTransform: (id) sender
{
// NSLog(@"ViewController: -actionApplyTransform:");

CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGPoint screenCenter = { CGRectGetMidX(screenBounds),
 CGRectGetMidY(screenBounds) };

CGRect imgBounds = imgView.bounds;
CGPoint imgCenter = { CGRectGetMidX(imgBounds),
  CGRectGetMidY(imgBounds) };

// The image's origin is not at its center, so when
// targetting a destination point, we must account
// for that.
CGPoint targetCenter;
targetCenter.x = screenCenter.x - imgCenter.x;
targetCenter.y = screenCenter.y - imgCenter.y;

[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDuration: kAnimDuration];
[UIView setAnimationDelegate: self];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];

CGAffineTransform transform;

transform = CGAffineTransformMakeScale(kScaleX, kScaleY);

// As the image scales in size, its origin changes.
// Thus, we have to scale the destination point by
// same scale factor, but "in reverse".
transform = CGAffineTransformTranslate(transform,
targetCenter.x / kScaleX, targetCenter.y / kScaleY);

transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90));

imgView.transform = transform;

[UIView commitAnimations];
}

// Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Erik Buck
Only a little bit of math is neccessary to use affine transforms.  A lot of 
math is needed for general 3D programming, but let's ignore that for now.
 
My third grader was tought about associative and communitive math operstions.  
Some matrix operations are associative and some are communitive.  That's why 
the order of operations matters.
 
To scale and rotate a square without moving the center of the square, do the 
following:
A) translate to the center of the square making that position the new origin 
for scaling and rotation.
B) Scale the coordinate system.
C) Rotate the coordinate system
D) Translate back to the original origin
F) Draw the square
 
It's not so hard typed in web-mail:
 
CGAffineTransform 
TransformToScaleAndRotateAboutCenterOfSquare(NSRect  someSquare)
{
   CGAffineTransform transform = CGAffineTransformMakeTranslation(
  NSMidX(someSquare), NSMidY(someSquare));
   transform = CGAffineTransformScale (transform, 2.0f, 2.0f);
   transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90));
   transform = CGAffineTransformTranslate(transform, -NSMidX(someSquare), 
-NSMidY(someSquare));
 
   return transform;
}
 
 
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread David Duncan

On Jun 17, 2009, at 7:21 AM, Chunk 1978 wrote:

premiss:  a red cube, 50 width x 50 height, located at {0,0}.  i  
want to scale the cute 2 times it's width and height, move it to the  
center of the screen, and rotate it 90º



In general you will have a better understanding of what is going on in  
your application if you stick to using transforms to scale & rotate  
your views, rather than to move your views (i.e. translation). It is  
fully supported to use translation, and necessary for certain types of  
animation, but if your goal is to move a view to the center of the  
screen (for example) then setting the view's center to the center of  
the screen is a saner approach than using the transform matrix to do it.

--
David Duncan
Apple DTS Animation and Printing

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


MDSchemaCopyAllAttributes() returning nil

2009-06-17 Thread Dave DeLong

Hey everyone,

I'm working on a project that works a lot with Spotlight, and we're  
trying to get a list of all the attributes that Spotlight knows  
about.  We found a really nice function called  
MDSchemaCopyAllAttributes that returns a CFArrayRef of CFStringRefs,  
each one corresponding to a spotlight attribute in the schema.


The problem is that when we run this program as root (which we have  
to), MDSchemaCopyAllAttributes seems to consistently be returning  
nil.  Is this normal behavior?  If so, how can we get a list of all  
Spotlight attributes across an entire machine (and not just the user  
domain)?


Thanks,

Dave DeLong
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 10:50 PM, David Duncan wrote:


On Jun 17, 2009, at 7:21 AM, Chunk 1978 wrote:

premiss:  a red cube, 50 width x 50 height, located at {0,0}.  i  
want to scale the cute 2 times it's width and height, move it to  
the center of the screen, and rotate it 90º


In general you will have a better understanding of what is going on  
in your application if you stick to using transforms to scale &  
rotate your views, rather than to move your views (i.e.  
translation). It is fully supported to use translation, and  
necessary for certain types of animation, but if your goal is to  
move a view to the center of the screen (for example) then setting  
the view's center to the center of the screen is a saner approach  
than using the transform matrix to do it.


Hi David,

my understanding was that the OP wanted to do all three operations  
concurrently. Of course, if he wants simply to move, then scale, and  
then rotate, there are easier ways to accomplish that than to use  
transforms.


Wagner___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 10:40 PM, Erik Buck wrote:

Only a little bit of math is neccessary to use affine transforms.  A  
lot of math is needed for general 3D programming, but let's ignore  
that for now.


My third grader was tought about associative and communitive math  
operstions.  Some matrix operations are associative and some are  
communitive.  That's why the order of operations matters.


To scale and rotate a square without moving the center of the  
square, do the following:
A) translate to the center of the square making that position the  
new origin for scaling and rotation.

B) Scale the coordinate system.
C) Rotate the coordinate system
D) Translate back to the original origin
F) Draw the square

It's not so hard typed in web-mail:

CGAffineTransform  
TransformToScaleAndRotateAboutCenterOfSquare(NSRect  someSquare)

{
   CGAffineTransform transform = CGAffineTransformMakeTranslation(
  NSMidX(someSquare), NSMidY(someSquare));
   transform = CGAffineTransformScale (transform, 2.0f, 2.0f);
   transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90));
   transform = CGAffineTransformTranslate(transform, - 
NSMidX(someSquare), -NSMidY(someSquare));


   return transform;
}


You're absolutely correct in general, but - if I'm not mistaken -  
CGAffineTransform rotations and scalings already do their thing with  
respect to the center of the view they're being applied to. In fact, I  
tested that before writing my solution to the OP's problem. And that  
is indeed the source of the problem. Rotations and scalings, as  
implemented by CGAffineTransform, are with respect to the view's  
center but translations are with respect to the view's origin.  
Therefore, if you scale while you translate, the view's origin changes  
and the translation is no longer being applied with the correct offset.


To be honest, I'm a bit surprised that CGAffineTransform rotations and  
scalings are already defined with respect to the center of the view.  
There's still a part of my brain that thinks that that isn't true, but  
my tests indicated otherwise.


Wagner

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to fill rectangle under vertical scroller?

2009-06-17 Thread Scott Andrew
Have you looked at a couple of frameworks that already do this? The  
two i can think of fare.  BWToolkit and HMBlkAppKit. Source is  
available for both.


Scott

On Jun 16, 2009, at 9:40 PM, Sumin Kim wrote:






That's not part of the scroller. Assuming you're working with  
NSTableView,

this is the cornerView, which you can set up separately.




Yes, you are right. I am working with table. Of course I tried to use
cornerView. But as far as I understood with my experience dealing with
cornerView, it was not I want to handle. I think the cornerView is  
the upper
right corner of the tableView -I mean, above of the vertical  
scroller- but
what I want to fill with my color is right bottom corner, under the  
vertical

scroller.

Am I understanding 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:
http://lists.apple.com/mailman/options/cocoa-dev/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread David Duncan

On Jun 17, 2009, at 1:58 PM, WT wrote:

my understanding was that the OP wanted to do all three operations  
concurrently. Of course, if he wants simply to move, then scale, and  
then rotate, there are easier ways to accomplish that than to use  
transforms.



You can set the center & transform of a view within the same animation  
block and both animations will occur concurrently.

--
David Duncan
Apple DTS Animation and Printing

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 11:28 PM, David Duncan wrote:


On Jun 17, 2009, at 1:58 PM, WT wrote:

my understanding was that the OP wanted to do all three operations  
concurrently. Of course, if he wants simply to move, then scale,  
and then rotate, there are easier ways to accomplish that than to  
use transforms.


You can set the center & transform of a view within the same  
animation block and both animations will occur concurrently.


Yes, of course! Duh... in my haste to answer, I misunderstood what you  
said in your previous post. Your comment provides the clearest and  
cleanest solution:


CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGPoint screenCenter = { CGRectGetMidX(screenBounds),
 CGRectGetMidY(screenBounds) };

[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDuration: kAnimDuration];
[UIView setAnimationDelegate: self];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];

CGAffineTransform transform;
transform = CGAffineTransformMakeScale(kScaleX, kScaleY);
transform = CGAffineTransformRotate(transform,  
DEGS_TO_RADS(kAngleInDegrees));

imgView.transform = transform;

imgView.center = screenCenter;

[UIView commitAnimations];

For future reference and for the benefit of the OP, I've now updated  
my sample project.


Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Erik Buck



> My third grader was taught about associative and commutative math 
> operations.  Some matrix operations are associative and some are 
> commutative.  That's why the order of operations matters.
 
Just in case: I didn't mean to imply that even third graders should understand 
matrix math.  It was just a stream of consciousness statement intended to 
express that my son actually caused me to remember the terms "associative" and 
"commutative".  I was reminded by a third grader :)
 


You're absolutely correct in general, but - if I'm not mistaken - 
CGAffineTransform rotations and scalings already do their thing with respect to 
the center of the view they're being applied to. In fact, I tested that before 
writing my solution to the OP's problem. And that is indeed the source of the 
problem. Rotations and scalings, as implemented by CGAffineTransform, are with 
respect to the view's center but translations are with respect to the view's 
origin. Therefore, if you scale while you translate, the view's origin changes 
and the translation is no longer being applied with the correct offset.

To be honest, I'm a bit surprised that CGAffineTransform rotations and scalings 
are already defined with respect to the center of the view. There's still a 
part of my brain that thinks that that isn't true, but my tests indicated 
otherwise.

Wagner

 
OK.  I will have to try this at home. If you create a CGAffineTransform as I 
did and then use [myUIView setTransform:myTransform], how can a UIView know 
that part of my transform matrix applies one way and another part applies 
another way ?  I think it is mathematically impossible unless the view is 
pulling components out of the transform matrix rather than just concatenating 
the matrix I supply with whatever matrix it's superview uses.  If it pulls 
components out of the transform matrix, it is not a proper affine transform 
(because shear and skew and some degenerate cases will not work) and all of the 
functions are misnamed.
 
 
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 11:53 PM, Erik Buck wrote:

My third grader was taught about associative and commutative math  
operations.  Some matrix operations are associative and some are  
commutative.  That's why the order of operations matters.


Just in case: I didn't mean to imply that even third graders should  
understand matrix math.


They do in Star Trek The Next Generation. Or maybe it was calculus.

You're absolutely correct in general, but - if I'm not mistaken -  
CGAffineTransform rotations and scalings already do their thing with  
respect to the center of the view they're being applied to. In fact,  
I tested that before writing my solution to the OP's problem. And  
that is indeed the source of the problem. Rotations and scalings, as  
implemented by CGAffineTransform, are with respect to the view's  
center but translations are with respect to the view's origin.  
Therefore, if you scale while you translate, the view's origin  
changes and the translation is no longer being applied with the  
correct offset.


To be honest, I'm a bit surprised that CGAffineTransform rotations  
and scalings are already defined with respect to the center of the  
view. There's still a part of my brain that thinks that that isn't  
true, but my tests indicated otherwise.


Wagner


OK.  I will have to try this at home. If you create a  
CGAffineTransform as I did and then use [myUIView  
setTransform:myTransform], how can a UIView know that part of my  
transform matrix applies one way and another part applies another  
way ?  I think it is mathematically impossible unless the view is  
pulling components out of the transform matrix rather than just  
concatenating the matrix I supply with whatever matrix it's  
superview uses.  If it pulls components out of the transform matrix,  
it is not a proper affine transform (because shear and skew and some  
degenerate cases will not work) and all of the functions are misnamed.


Your objections are precisely the reasons why some part of my brain is  
screaming at the rest of it for publicly making a statement which it  
believes to be incorrect. It may sound strange, but I'll be happy to  
be proven wrong on this one.


Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread Andy Lee
On Wednesday, June 17, 2009, at 06:07PM, "WT"  wrote:
>On Jun 17, 2009, at 11:53 PM, Erik Buck wrote:
>> Just in case: I didn't mean to imply that even third graders should  
>> understand matrix math.
>
>They do in Star Trek The Next Generation. Or maybe it was calculus.

And yet in the latest Star Trek movie they quiz Vulcan kids on the volume of a 
sphere.  Duh, you might as well ask them 1+1!

--Andy


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

On Jun 17, 2009, at 11:11 PM, WT wrote:

You're absolutely correct in general, but - if I'm not mistaken -  
CGAffineTransform rotations and scalings already do their thing with  
respect to the center of the view they're being applied to. In fact,  
I tested that before writing my solution to the OP's problem. And  
that is indeed the source of the problem. Rotations and scalings, as  
implemented by CGAffineTransform, are with respect to the view's  
center but translations are with respect to the view's origin.  
Therefore, if you scale while you translate, the view's origin  
changes and the translation is no longer being applied with the  
correct offset.


To be honest, I'm a bit surprised that CGAffineTransform rotations  
and scalings are already defined with respect to the center of the  
view. There's still a part of my brain that thinks that that isn't  
true, but my tests indicated otherwise.


Wagner


I must be really tired...

I don't often make absurd statements, but the more I think about what  
I said above, the more embarrassed I feel because, despite of what my  
tests indicated, what I said above doesn't make much sense. A  
translation is a rigid operation and, as such, is not defined with  
respect to any anchor point or axis. So, at the very least, the  
sentence "translations are with respect to the view's origin" is  
completely wrong.


I hope that tomorrow, with a fresh mind, I'll be able to understand  
why my solution worked. It clearly did, but not for the reasons I  
claimed above.


Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread David Duncan

On Jun 17, 2009, at 2:11 PM, WT wrote:

You're absolutely correct in general, but - if I'm not mistaken -  
CGAffineTransform rotations and scalings already do their thing with  
respect to the center of the view they're being applied to. In fact,  
I tested that before writing my solution to the OP's problem. And  
that is indeed the source of the problem. Rotations and scalings, as  
implemented by CGAffineTransform, are with respect to the view's  
center but translations are with respect to the view's origin.  
Therefore, if you scale while you translate, the view's origin  
changes and the translation is no longer being applied with the  
correct offset.


To be honest, I'm a bit surprised that CGAffineTransform rotations  
and scalings are already defined with respect to the center of the  
view. There's still a part of my brain that thinks that that isn't  
true, but my tests indicated otherwise.



All transforms are with respect to the view's center. The view's frame  
is an artifact of the view's center, and the frame is calculated based  
on a number of parameters of the view, part of which is why the  
documentation says not to rely on the frame of a view if you've set a  
transform on the view.


The issue with a translation is that it starts to confuse your  
expectations of the relationship between a view's center and the  
view's frame, because the center isn't altered by the transform, only  
the frame is. This is also why I recommend not using translations as  
part of your transform if they are not necessary, because then you  
look at the center of the view and you discover that it hasn't  
actually moved, yet your view is clearly not where it was before you  
set the transform.


Of note at this point is that the view's center is in its super view's  
coordinate system, while the view's bounds is in its own coordinate  
system (and thus the origin is usually, but need not be, CGPointZero).  
Your solution works because you've scaled the coordinate system, so  
the translation needs to be scaled too (to get the change specified by  
the translation). Effectively, you've changed the coordinate system  
for defining the frame without changing the coordinate system of the  
view's center (because that coordinate system is defined by the super  
view).


At the Core Animation level (where this all really lives) the frame of  
a layer is calculated based on the layer's position, bounds.size,  
anchorPoint and transform. The position determines its location in the  
superlayer, the bounds.size determines the extent of the layer, the  
anchorPoint determines how the extent is positioned relative to the  
position, and the transform is applied to that final rectangle to  
determine the actual position on screen. The frame rectangle is then  
extracted from that in a process that while meaningful tends to be  
useless to developers.

--
David Duncan
Apple DTS Animation and Printing

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: UTI not identified correctly for some users.

2009-06-17 Thread Sean McBride
On 6/15/09 12:36 AM, Mitchell Livingston said:

>Thanks for that. I am dealing with .torrent extensions. I have the UTI
>defined as "org.bittorrent.torrent". Both apps are using the same file
>format, so there shouldn't be a problem with a single UTI.

OK, you're in a not-so-bad situation then.  The best you can do is
contact as many authors of torrent apps as you can, and agree upon a
common declaration.  Or maybe there already is one, did you search?

>It would be
>great if Apple included this in the OS, although is there a chance
>considering their stance on torrent files? It is a legitimate file
>format, regardless.

I wasn't aware they had a stance on this format.  Do you have a
reference?  I think you should file a bug regardless.

>I'm not sure how to use the rdar links - am I missing something
>obvious? I will file a bug on Apple Bug Reporter.

You can't see my bugs, but you can reference them in your own bugs.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Enter Key Behavior in NSTableView

2009-06-17 Thread Chris Tracewell
I have a subclass of NSTableView which I have implemented keyDown to  
pick up delete and enter key presses. When the TV is bound to an array  
controller it works perfectly, I can detect keyDowns for the above  
mentioned and as a bonus when the user presses "Enter" or "Return" the  
field editor ends editing. Thats what I want.


The problem is that as soon as I hook up my File's Owner as the  
delegate for the TV the Field Editor no longer detects the Return and  
Enter key strokes. Is this normal? If so where do I look in docs to re- 
establish this behavior?

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: UTI not identified correctly for some users.

2009-06-17 Thread Mitchell Livingston


On Jun 16, 2009, at 6:20 PM, Sean McBride wrote:


On 6/15/09 12:36 AM, Mitchell Livingston said:

Thanks for that. I am dealing with .torrent extensions. I have the  
UTI
defined as "org.bittorrent.torrent". Both apps are using the same  
file

format, so there shouldn't be a problem with a single UTI.


OK, you're in a not-so-bad situation then.  The best you can do is
contact as many authors of torrent apps as you can, and agree upon a
common declaration.  Or maybe there already is one, did you search?


None of the apps I found have it set up in the Info.plist. From users  
with the problem I've discovered they have it set up as  
"com.bittorrent.torrent". Perhaps I should just change it to that, but  
that's not future-proof enough incase another program decides to  
define a different UTI for it. No matter who I contact, if one app  
sets it to something different, this functionally breaks. Since the  
torrent file format is standard, Apple declaring it would be by far  
the safest thing, and pretty much the only thing that would make me  
remove the extension check (instead of just checking UTI).





It would be
great if Apple included this in the OS, although is there a chance
considering their stance on torrent files? It is a legitimate file
format, regardless.


I wasn't aware they had a stance on this format.  Do you have a
reference?  I think you should file a bug regardless.


I have reported the bug already. I assume they have a stance because  
an iPhone front-end for torrents was rejected, and they won't place  
our app on the Mac OS X software download page.





I'm not sure how to use the rdar links - am I missing something
obvious? I will file a bug on Apple Bug Reporter.


You can't see my bugs, but you can reference them in your own bugs.



Will do.


--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada




___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: UTI not identified correctly for some users.

2009-06-17 Thread Sean McBride
On 6/17/09 7:07 PM, Mitchell Livingston said:

>None of the apps I found have it set up in the Info.plist. From users
>with the problem I've discovered they have it set up as
>"com.bittorrent.torrent". Perhaps I should just change it to that, but
>that's not future-proof enough incase another program decides to
>define a different UTI for it. No matter who I contact, if one app
>sets it to something different, this functionally breaks.

Correct.  A malicious app could even do this deliberately.

>Since the
>torrent file format is standard, Apple declaring it would be by far
>the safest thing, and pretty much the only thing that would make me
>remove the extension check (instead of just checking UTI).

Correct.  And LS seems to always prefer Apple-provided UTIs.

>I have reported the bug already. I assume they have a stance because
>an iPhone front-end for torrents was rejected, and they won't place
>our app on the Mac OS X software download page.

Interesting.  I'll refrain from an OT rant now. :)

BTW: the Carbon list would probably be better for UTI questions, at
least one LS guy hangs out there.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Safari-4-like Pulldown List

2009-06-17 Thread Dong Feng
Hi Sean,

It is a superb answer to my initial question that ease my decision to
the next step work.

Thank you for the answer and for sharing your project. A great work!

Dong.




2009/6/16 Sean Murphy :
> On Jun 14, 2009, at 5:01 AM, Dong Feng wrote:
>
> I want to implement a pulldown list like what FireFox does with its
> address bar (or its Google search bar). I think it involves to open a
> borderless window and draw items through Cocoa drawing APIs.
>
> But when I saw Safari 4, its pulldown list's appearance just like a
> context-menu, I began thinking if implement a Safari-4-like pulldown
> list can save drawing the whole borderless window by writing code
> myself. Does Safari 4 rely on Cocoa API of menu to implement its
> pulldown list, or does it still implement a borderless window itself
> whose appearance happen to simulate a context menu?
>
> Hi Dong,
> As for Safari, it's the latter approach you mentioned.  Using F-Script
> Anywhere, what Safari is doing is displaying a CompletionsWindow, probably
> as a child window of the browser window, and then using a RoundedRect view
> to simulate the context menu
> appearance.  The completion list is a subclass of NSTableView.
> In Camino, we're currently working on a more Mac-like autocompletion bar
> that actually has an appearance similar to Safari's coincidentally.  Our
> project is open source, so you can feel free to take a look at the code
> we're using.  This would server as a better example than having to reverse
> engineer Safari's implementation to learn from.  This is our Google Summer
> of Code project for this year.  Check out
> , and you can
> view the current patch (still a work in progress, but it is working)
> implementing this at .
> Hope that helps,
> Sean.
>
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Add same object/key to NSMapTable

2009-06-17 Thread Nathan Vander Wilt
The following (simplified test case) code will crash with  
NSZombieEnabled:


NSMapTable* testTable = [NSMapTable mapTableWithStrongToStrongObjects];
NSString* o = [@"test_object" mutableCopy];
NSString* k = @"test_key";
[testTable setObject:o forKey:k];
[o release];
[testTable setObject:o forKey:k];   // crash

What seems to be happening is that -[NSMapTable setObject:forKey:]  
does a plain release on the key's "old" object before retaining the  
"new" object. This can result in the situation above, where the retain  
of the "new" object is performed on a zombie created by the release of  
the (identical) "old".


I could find no documentation to the effect that re-assigning an  
object is not allowed, so can I assume this is indeed unintentional?  
If so, I've got this test case in project form and would be happy to  
file a bug.


thanks,
-natevw
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Notification/callback of successful CGEventPost?

2009-06-17 Thread Peter N Lewis

On 17/06/2009, at 9:22 , Dave DeLong wrote:
I have this mostly working, but it's not a satisfactory solution.   
My problem is with posting the CGEvents for a command-v operation.   
I've found that if I do everything inline (snapshot, replace, paste,  
restore snapshot), then the restore operation executes before the  
CGEvent gets processed.  It posts just fine, but it seems like the  
execution of the event is asynchronous.


My unsatisfactory solution is to put "sleep(2);" in between the  
paste and restore phase.  This works, but I'm not happy with it.   
What I'd really like is some sort of notification that my event has  
actually posted so that I don't have to use the sleep command.  Is  
there a way to do this?  I know that I could also use a CGEventTap  
and watch for my event to pass by myself, but is there a better  
alternative?



Unfortunately, there is no good solution to this.  The keyboard event  
gets posted to the event queue, but there is no guarantee as to when  
the key will be read by the target application, nor how long after  
that the event might be processed.


So you are stuck doing a delay, and if the delay is too short then the  
old clipboard is restored before the paste.  If the delay is too long,  
the user has a chance to select something else and copy it, and then  
their copy is overwritten, resulting in potential data loss.


A further complication is that the time delay required is dependent on  
system speed which varies over time.


On 17/06/2009, at 9:49 , Ken Thomases wrote:

What if you only put a promise on the pasteboard?  When the  
pasteboard server asks you to fulfill the promise, you can be  
reasonably certain that it was because the paste operation in the  
other app is underway.  You can fulfill the promise and then  
schedule the restoration of the original pasteboard contents with a  
0 delay (or maybe 0.2, or something).


This is very clever, but it will definitely fail if there are any  
clipboard history programs running (of which, there are over a dozen  
different variants on the Mac).  Then both the clipboard history  
program and your target app will read the clipboard, and whichever  
reads first will "win".


This problem is actually the reason I implemented clipboard history in  
Keyboard Maestro, so I could remove the "restore the snap shot" part  
of the action while still preserving the old clipboard and allowing  
the user to control the delay if they needed the clipboard restored.   
It was also a driving force for allowing the option of inserting text  
by typing instead of pasting, which might be an option for you  
depending on what you want to "paste".


Enjoy,
   Peter.

--
 Clipboard Switching and Macros with Keyboard Maestro

Keyboard Maestro  Macros for your Mac
   



___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 6:33 PM, Nathan Vander
Wilt wrote:
> I could find no documentation to the effect that re-assigning an object is
> not allowed, so can I assume this is indeed unintentional? If so, I've got
> this test case in project form and would be happy to file a bug.

Please do file a bug.

In the meantime, the explicit case you present is always going to be
fraught with peril, because after you release o, you have relinquished
all rights to it.  It's now a weak reference.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Nathan Vander Wilt


On Jun 17, 2009, at 6:44 PM, Kyle Sluder wrote:


On Wed, Jun 17, 2009 at 6:33 PM, Nathan Vander
Wilt wrote:
I could find no documentation to the effect that re-assigning an  
object is
not allowed, so can I assume this is indeed unintentional? If so,  
I've got

this test case in project form and would be happy to file a bug.


Please do file a bug.


Filed as rdar://problem/6982962. Workaround is to refactor so you're  
not doing this, [[o retain] autorelease], or check if the object is  
already in the map table.




In the meantime, the explicit case you present is always going to be
fraught with peril, because after you release o, you have relinquished
all rights to it.  It's now a weak reference.



Isn't it acceptable practice to let a container object I hold to  
maintain its objects on my behalf?


thanks,
-natevw
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Bill Bumgarner

On Jun 17, 2009, at 8:48 PM, Nathan Vander Wilt wrote:

In the meantime, the explicit case you present is always going to be
fraught with peril, because after you release o, you have  
relinquished

all rights to it.  It's now a weak reference.


Isn't it acceptable practice to let a container object I hold to  
maintain its objects on my behalf?


(Thanks for the bug -- it might end up as "behaves correctly", but the  
documentation should be refined)


You can't assume that the container didn't make a copy or do something  
else.


If you need the object, you should hold a retain.

b.bum

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Kyle Sluder
On Wed, Jun 17, 2009 at 6:48 PM, Nathan Vander
Wilt wrote:
> Isn't it acceptable practice to let a container object I hold to maintain
> its objects on my behalf?

Not explicitly, no.  Take -[NSWindowController delegate], for example.
 Because delegates are a weak reference, the contract is explicit that
your delegate must always be valid from the time you set it to be so
to the time the NSWindowController instance is deallocated *or* you
call -setDelegate: with a different object.  It's this explicit
contract which lets NSWindowController not have to wrap all accesses
to its delegate with -retain/-release calls.

In the specific context you illustrate, you're violating the
rule-of-thumb that once you release an object for good you don't
message it again.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Jim Correia
On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner  wrote:

> You can't assume that the container didn't make a copy or do something else.
>
> If you need the object, you should hold a retain.

In general, I agree. However, the following code is also problematic:

[o release];
[testTable setObject:[testTable objectForKey:k] forKey:k];

NSDictionary does not have the same failure mode. Bug in NSMapTable
(for the edge case of replacing the current value)?

- Jim
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to fill rectangle under vertical scroller?

2009-06-17 Thread Andrew Farmer

On 16 Jun 2009, at 21:40, Sumin Kim wrote:





That's not part of the scroller. Assuming you're working with  
NSTableView,

this is the cornerView, which you can set up separately.




Yes, you are right. I am working with table. Of course I tried to use
cornerView. But as far as I understood with my experience dealing with
cornerView, it was not I want to handle. I think the cornerView is  
the upper
right corner of the tableView -I mean, above of the vertical  
scroller- but
what I want to fill with my color is right bottom corner, under the  
vertical

scroller.

Am I understanding wrong?


No, you're correct - I was mistaken about the purpose of cornerView.  
Carry on.

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Michael Ash
On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner wrote:
> On Jun 17, 2009, at 8:48 PM, Nathan Vander Wilt wrote:
>>>
>>> In the meantime, the explicit case you present is always going to be
>>> fraught with peril, because after you release o, you have relinquished
>>> all rights to it.  It's now a weak reference.
>
>> Isn't it acceptable practice to let a container object I hold to maintain
>> its objects on my behalf?
>
> (Thanks for the bug -- it might end up as "behaves correctly", but the
> documentation should be refined)
>
> You can't assume that the container didn't make a copy or do something else.

I think you can, in this case, because NSMapTable isn't documented as
requiring a copyable object.

Mike
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Add same object/key to NSMapTable

2009-06-17 Thread Michael Ash
On Wed, Jun 17, 2009 at 10:10 PM, Jim Correia wrote:
> On Wed, Jun 17, 2009 at 9:51 PM, Bill Bumgarner  wrote:
>
>> You can't assume that the container didn't make a copy or do something else.
>>
>> If you need the object, you should hold a retain.
>
> In general, I agree. However, the following code is also problematic:
>
> [o release];
> [testTable setObject:[testTable objectForKey:k] forKey:k];
>
> NSDictionary does not have the same failure mode. Bug in NSMapTable
> (for the edge case of replacing the current value)?

IMO this is a bug in your code, which is being hidden by NSDictionary
and exposed by NSMapTable. That's not to say that Apple shouldn't make
it better, but this kind of behavior is wrong. Collection classes are
documented as retaining their contents, and of course releasing them
when appropriate. It explicitly warns against removing an object from
a container and then trying to use it. For this code to work, you're
relying on NSMapTable (or NSDictionary) to retain the new content
object before releasing the old one, even though there is no such
guarantee in the API contract.

Mike
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Group CGAffineTransform Animations?

2009-06-17 Thread WT

Hi David,

On Jun 18, 2009, at 12:42 AM, David Duncan wrote:

Your solution works because you've scaled the coordinate system, so  
the translation needs to be scaled too (to get the change specified  
by the translation).


Yes, that was the point I was trying to make on earlier posts, though  
in a confusing way. My intuition was correct but I was too tired to  
understand why. It's actually rather simple. A scaling is like  
changing the size of your ruler or meter-stick (a smaller ruler  
produces larger lengths, so the object you're measuring appears  
bigger, and vice-versa). The problem is, though, that changing your  
ruler also changes how far you travel when you apply a translation  
(changing your ruler *is* changing the scale of your entire coordinate  
system). Thus, if you scale up, you also travel more, and if you scale  
down, you travel less, and always by the same factor. So, in order to  
travel the correct distance *and* make your object have a different  
size, you need to divide the translation offset by the scale of your  
scaling. The translation offset, of course, has to be the correct one,  
and that was a vector from the object's center to the center of the  
screen.


I am a bit confused now by something you said, though.

The issue with a translation is that it starts to confuse your  
expectations of the relationship between a view's center and the  
view's frame, because the center isn't altered by the transform,  
only the frame is. This is also why I recommend not using  
translations as part of your transform if they are not necessary,  
because then you look at the center of the view and you discover  
that it hasn't actually moved, yet your view is clearly not where it  
was before you set the transform.


Of note at this point is that the view's center is in its super  
view's coordinate system, while the view's bounds is in its own  
coordinate system (and thus the origin is usually, but need not be,  
CGPointZero).


If the center is in the superview's coordinate system, how can it not  
be changed by a translation? In the view's own coordinate system, yes,  
I can see that that's true, because then the center is half-way the  
bounds' width and height, and those don't change under a translation.


Wagner
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Problem with capturing active state of the application

2009-06-17 Thread Srinivasa Prabhu

Hi All,

In our application we want to capture a selected area similar to  
Apple's Cmd+Shift+4 i.e
during selection capture, the active state of another application has  
to be captured.


This is what we are doing currently.

When the user enters the selection capture mode, we hide the  
application's
main window and put up a transparent window that covers the entire  
screen.
The selection area is drawn on this window and we capture the image  
from the selected area.


However we are not able to capture the active state of the close,  
minimize, zoom, scroll

buttons of the application currently on the screen.
These are in the disabled state because our application is currently  
active.


We have tried the following.

1. Capturing the screen using CGDisplayCapture and then displaying a  
transparent window

and drawing over the window.

See here for the documentation:
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/AdvancedDrawing/AdvancedDrawing.html#/ 
/apple_ref/doc/uid/TP40003290-CH207-SW16


However this solution freezes the screen.
For eg: If a movie is being played and we enter the selection mode, it  
is not possible to receive screen updates.

But this is not the case with Apple's Cmd+Shift+4.

What are we doing wrong here?

Is there any workaround to capture the active state of the applications?

Thanks in advance
Srinivas

---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Problem with capturing active state of the application

2009-06-17 Thread Andrew Farmer

On 17 Jun 2009, at 22:49, Srinivasa Prabhu wrote:
In our application we want to capture a selected area similar to  
Apple's Cmd+Shift+4 i.e
during selection capture, the active state of another application  
has to be captured.

...
Is there any workaround to capture the active state of the  
applications?


Yes: CGWindow.

http://developer.apple.com/documentation/Carbon/reference/CGWindow_Reference/Reference/Functions.html#/ 
/apple_ref/doc/uid/TP40008073-CH2-DontLinkElementID_53

___

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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