Re: NSSliderCell question

2009-07-24 Thread livinginlosangeles

I'll follow up on that tomorrow. Thanks,

Patrick


Hi,

I am using the following two methods for a scrolling number box which
is essentially a slider in the form of a NSTextField subclass.  I have
yet to implement this for my custom sliders but maybe this is a good
starting point for you?  When I first dabbled with custom sliders all
I did was override the mouseUp, mouseDown, mouseDragged methods etc
now my custom sliders are subclasses of NSControl rather than  
NSSlider.


-(void)mouseUp:(NSEvent*)theEvent
{
if(drag) drag = NO;
}

-(void)mouseDragged:(NSEvent*)theEvent
{
float val = [self floatValue];

if(!drag) {
// float start_x = [self convertPoint: [theEvent 
locationInWindow]
fromView: nil].x;
start_y = [self convertPoint:[theEvent locationInWindow] 
fromView:
nil].y;
prev_y = start_y;
drag = YES;
};

// key modifier key flags
unsigned int flags;
flags = [theEvent modifierFlags];

float next_y = [self convertPoint:[theEvent locationInWindow]
fromView: nil].y;
float deltaY = (next_y - prev_y) / dragSize;
prev_y = next_y;

if(flags  NSAlternateKeyMask) deltaY *= fineGrain;
val += range * deltaY;

[self checkBounds:val];
[self setFloatValue:val];

// continuously send the action
[self sendAction:(SEL)[self action] to:(id)[self target]];
}


___

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

Please do not post 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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Jerry Krinock

On 2009 Jul 23, at 17:44, Ken Thomases wrote:

Do consider NSConditionLock as an alternative, though.  It's likely  
to be much simpler and more straightforward.


Indeed Ken is correct.  I'll post the code tomorrow.
___

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

Please do not post 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


[moderator] Re: Recording phone calls

2009-07-24 Thread Scott Anguish

WAY off topic.

[moderator]

On 2009-07-23, at 8:20 PM, Conrad Taylor wrote:

On Thu, Jul 23, 2009 at 8:53 AM, Scott Ribe scott_r...@killerbytes.com 
wrote:



...most states require the consent of both
parties for one party to record the conversation.


Actually, most states require the consent of only a single party. A  
handful

of states (~10?) require consent of all parties. The point of course
remains, that there are some legal restrictions.



___

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

Please do not post 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 List?

2009-07-24 Thread Scott Anguish


On 2009-07-23, at 3:04 AM, Gustavo Pizano wrote:

Hello, I wish to know if this list works also for iPhone developer,  
I hadn't found one related to iPhone except the govIphone, that its  
for goverment iPhone apps... so.. :S.


If this is the correct list to write then please let me know so I  
can ask few questions related.. Im a mac developer but starting to  
dev for iPhone..





There is no separate list for iPHone development.

the forums at devforums.apple.com are intended as the official source.

public information (not non-disclosure) Cocoa issues are relevant here.
___

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

Please do not post 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 List? - few questions

2009-07-24 Thread Gustavo Pizano

Roland hello.


Thanks for the advises, I think I will stick with the reply SMS- save  
my app status- close my app - (hit the link of the sms if comes with  
url,  or copy the access code and relaunch my app)- complete the  
authentication with the access code.


well, if that;s they way to do things, then so be it, pity I can't  
listen to incoming sms.


Thanks for your help... I will keep you informed with my progress.\

G.

On Jul 24, 2009, at 3:12 AM, Roland King wrote:

Well you can't register to listen to SMSes, that hook just doesn't  
exist. So if you rely on proving who someone is by sending something  
to a specific phone (ie making use of the telephone companys vast  
network ability to locate one device with that particular SIM card  
in it at that point in time anywhere in the world), SMS is kind of  
about the only way to do it.


I took a look to see what happens when you're running an app and an  
SMS comes in, with a URL on it . it's not totally pretty, you get to  
option to 'reply', which closes your app, or 'close' which closes  
the SMS. So the best you could do like that is hit reply, close your  
app, hit the link in the SMS which opens it up again, you'd need a  
quick-start app for that.


The only other way is to have done the SMS thing way in advance and  
cached a token on the phone you use at the time direct to the  
server, but that's not very good security, the token would go with  
the phone, swap SIM cards and someone else is now you.


Gustavo Pizano wrote:

@ Jesse:
Yes the idea is to distribute the App through the AppStore, so I  
guess  I can't go any deeper.
The idea is that in the server there is gonna be a sms application   
that will send the Authorization code to the registered iPhone that  
is  asking for it, then My app should take that access code and  
connect to  the server, its kinda a 2 step Login system. So if  
there is gonna be  an inpediment, then the sms app in the server  
will send the sms with  the Auth Code, then my iPhone will receive  
the sms, and the sms app of  the iPhone will  say Hey you I have a  
new sms, so now that I have  the code, I can just copy-paste it in  
the access code of my app and do  the second part of the  
authentication. (well that is what its on my  mind due that i can't  
get the data of the incoming sms without leaving  my iPhone app ).
I dunno how user friendly is to do such a authentication, as you  
can  see we are  working with very critical data that requires a  
strong  authentication and data encryption , like a bank sort to  
speak.

G.
On Jul 23, 2009, at 4:42 PM, Roland King wrote:
Right, but you can register your own url schemes which will  
launch  your app and let it handle the data. I've assumed that the  
SMS  displaying framework will parse out such URLs, realize they  
are  registered and put the correct hotlink into the message to  
launch  your app.



On Jul 23, 2009, at 9:55 PM, Jesse Armand wrote:


The sms: URL on the iPhone only supports phone number, unless if
you're willing to go deep into the private API, but you couldn't
distribute your app into the App Store.

My advice is, better to install some kind of sms application or
gateway on your server, so your iPhone app could send the text into
the server, and the server will forward the message through sms.

Jesse Armand

(http://jessearmand.com)



On Thu, Jul 23, 2009 at 2:43 PM, Gustavo
Pizanogustavxcodepic...@gmail.com wrote:

Nop you didn\'t miss understood the question, I will have a  
look  at the
docs, because the idea is that once Im in my app, put the first   
credentials,
then the server will send me an authorizaiton code, and the  
idea  is to don't
leave my app to get the data from the sms, but the app fetch  
the  data of the
incoming sms,  but if you tell me that you think its not  
possible  to get
more automated than clicking the  arrow in the Iphone sms  
app  to launch
mine with the data in the url then Im kinda stuck... I will take  
a  look at

the docs and see what I find out.

I will let you know if something as you have been thinking  
about  doing the

same, if find a workaround.

G.


On Jul 23, 2009, at 9:27 AM, Roland King wrote:

If you're trying to use data which has been sms'ed to your  
user,  which is
something I've thought about doing before, the only way which  
I  thought it
could be done is to register your own url for the application  
and  then have
the sms you send include the data in a URL format, eg if your  
app  registered
URL is foobar you might have foobar://yourdatahere in the SMS.  
I  believe
that you'll then have the opportunity in the SMS screen to  
click  the 
arrow at the side of the screen and your app will launch with   
that URL as

data and you can process it.

I don't think you can get any more automated than that. It  
also  relies on

you sending the data in a compatible format.

Not totally sure this is related to the   

Re: memory allocation different in simulator and on the iPhone

2009-07-24 Thread Jonathan del Strother
UIImage* image = [UIImage imageNamed:fileName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[image release];

You're overreleasing the image there.  You sure the phone is dying
because it's out of memory, rather than because of that?

On Fri, Jul 24, 2009 at 3:07 AM, Dragos Ioneldragosio...@gmail.com wrote:
 Hi,
 I am working on a animal encyclopedia on iPhone. One of the pages displays
 one photo of an animal. When the user swipes the screen the image is
 replaced with another one.

 This works fine and when tested in the simulator with the Instrument for
 Object Allocation, all looks cool.

 When I tested on the real iPhone with Instrument, the memory used increases
 slowly but constantly so that eventually the application dies.

 Here is the method that is doing the image changing (direction means if the
 new image should come from left or from right). The class is a
 UIViewController


 -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{

  crtIndex = animaIndex;

  NSString* animalName = [[animalList objectAtIndex:animaIndex] objectForKey:
 @name];

 NSString* fileName   = [[animalList objectAtIndex:animaIndex] objectForKey:
 @file];

  self.title = animalName;

  //remove all the subviews

 for (UIView *view in self.view.subviews) {

 [view removeFromSuperview];

 }

  UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,
 480)];

 backgroundView.backgroundColor = [UIColor blackColor];

 [self.view addSubview:backgroundView];

 [backgroundView release];

  UIImage* image = [UIImage imageNamed:fileName];

 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

 [image release];

  CGRect imageFrame = imageView.frame;

 imageFrame.origin = CGPointMake(320*direction,0);

 imageView.frame = imageFrame;

  [self.view addSubview:imageView];


  [UIView beginAnimations: nil context: @identifier];

 [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];

 [UIView setAnimationDuration:0.5];

  imageFrame.origin = CGPointMake(0,0);

 imageView.frame = imageFrame;

  [UIView commitAnimations];

 [imageView release];

 }

 Can you see anything that is not right? Why is the memory allocation showing
 different in simulator and on the iPhone?

 Thanks a lot,
 Dragos
 ___

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

 Please do not post 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/maillist%40steelskies.com

 This email sent to maill...@steelskies.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] Zero opacity causes UIView to go numb (solved)

2009-07-24 Thread Sebastian Morsch




Completely transparent views (opacity 0.0) don't receive touch events


Thanks Hank, good to know! :-)




you're not missing anything there


Actually, I did. I was thinking to complicated by animating 'opacity'  
for hiding/revealing a CALayer. That's exactly what's its 'hidden'  
property is for.





Am 24.07.2009 um 02:41 schrieb Hank Heijink (Mailinglists):

Completely transparent views (opacity 0.0) don't receive touch  
events - you're not missing anything there. As you have found, a  
little opacity is enough to catch them again. Depending on what's in  
your view, you might be able to set the background color to [UIColor  
clearColor] to get the same effect. Or, maybe you can replace the  
view you're hiding with another (empty) one that has a transparent  
background color.


I'm not sure what will work for you without knowing more, but there  
are ways to accomplish what you're trying to do.


Good luck,
Hank

On Jul 23, 2009, at 10:49 AM, Sebastian Morsch wrote:


Hi,

I *KNOW* this must be something absolutely stupid I'm missing, but  
I'm stuck with this:


I have an UIView that's supposed to display an explanatory overlay  
image whenever it's touched. When the user lifts the finger, the  
overlay should fade away. To accomplish this I do the following  
Inside my OverlayView's init method:


self.layer.contents = (id)[UIImage imageNamed:@overlay.png]  
CGImage];

self.layer.opacity = 0.0;

and then, inside the touchBegan: and touchEnded: methods I set the  
opacity to 1.0 and 0.0 respectively.


Now, this doesn't work at all, the view doesn't receive the  
touchBegan: and touchEnded: methods. But everything works fine if I  
set the opacity to 0.1 instead of 0.0!! And for instance, when I do  
this:


1. set opacity to 0.1 in the init call...
2. set opacity to 1.0 in the touchBegan call...
3. set opacity to 0.0 (!!!) in the touchEnded call...

all subsequent touches are ignored, touchBegan:, touchEnded:, etc.  
are never called again.



Any help on this is very very much appreciated!
Thanks, Sebastian

___

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

Please do not post 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/hank.list%40runbox.com

This email sent to hank.l...@runbox.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: Model index and Array Controller index

2009-07-24 Thread I. Savant

On Jul 23, 2009, at 11:46 PM, Ben Lachman wrote:

So when do you actually do this, in the drop methods or somewhere  
more central?


  On accept drop. It's typically the only place I manually order  
items, so that kind of *is* the central location. :-) Everything else  
is handled by sort descriptors.


--
I.S.




___

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

Please do not post 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 List? - few questions

2009-07-24 Thread Jesse Armand
I suppose mobile banking is less secure than regular internet banking ?

I'm not sure what is the weakness in mobile banking, compared to
regular internet banking, where both of them have a secure device to
generate code for transactions ?

Let's say somebody stole your phone, what can he/she do without the
secure device that's registered to your bank account ?

Jesse Armand

(http://jessearmand.com)



On Fri, Jul 24, 2009 at 8:12 AM, Roland Kingr...@rols.org wrote:
 Well you can't register to listen to SMSes, that hook just doesn't exist. So
 if you rely on proving who someone is by sending something to a specific
 phone (ie making use of the telephone companys vast network ability to
 locate one device with that particular SIM card in it at that point in time
 anywhere in the world), SMS is kind of about the only way to do it.

 I took a look to see what happens when you're running an app and an SMS
 comes in, with a URL on it . it's not totally pretty, you get to option to
 'reply', which closes your app, or 'close' which closes the SMS. So the best
 you could do like that is hit reply, close your app, hit the link in the SMS
 which opens it up again, you'd need a quick-start app for that.

 The only other way is to have done the SMS thing way in advance and cached a
 token on the phone you use at the time direct to the server, but that's not
 very good security, the token would go with the phone, swap SIM cards and
 someone else is now you.

___

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

Please do not post 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: memory allocation different in simulator and on the iPhone

2009-07-24 Thread Dragos Ionel
You are right, I was over releasing and maybe that was crashing the app.
But still, even without [image release] the memory used by the app on iPhone
is slowly increasing (like 3K for each image display). Maybe that is
supposed to happen , maybe something is cached somewhere.

But the good thing is it did not crash anymore after 200-300 images
displayed.

Thanks a lot,
Dragos


On Fri, Jul 24, 2009 at 3:14 AM, Jonathan del Strother 
maill...@steelskies.com wrote:

 UIImage* image = [UIImage imageNamed:fileName];
 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
 [image release];

 You're overreleasing the image there.  You sure the phone is dying
 because it's out of memory, rather than because of that?

 On Fri, Jul 24, 2009 at 3:07 AM, Dragos Ioneldragosio...@gmail.com
 wrote:
  Hi,
  I am working on a animal encyclopedia on iPhone. One of the pages
 displays
  one photo of an animal. When the user swipes the screen the image is
  replaced with another one.
 
  This works fine and when tested in the simulator with the Instrument for
  Object Allocation, all looks cool.
 
  When I tested on the real iPhone with Instrument, the memory used
 increases
  slowly but constantly so that eventually the application dies.
 
  Here is the method that is doing the image changing (direction means if
 the
  new image should come from left or from right). The class is a
  UIViewController
 
 
  -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{
 
   crtIndex = animaIndex;
 
   NSString* animalName = [[animalList objectAtIndex:animaIndex]
 objectForKey:
  @name];
 
  NSString* fileName   = [[animalList objectAtIndex:animaIndex]
 objectForKey:
  @file];
 
   self.title = animalName;
 
   //remove all the subviews
 
  for (UIView *view in self.view.subviews) {
 
  [view removeFromSuperview];
 
  }
 
   UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,
 320,
  480)];
 
  backgroundView.backgroundColor = [UIColor blackColor];
 
  [self.view addSubview:backgroundView];
 
  [backgroundView release];
 
   UIImage* image = [UIImage imageNamed:fileName];
 
  UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
 
  [image release];
 
   CGRect imageFrame = imageView.frame;
 
  imageFrame.origin = CGPointMake(320*direction,0);
 
  imageView.frame = imageFrame;
 
   [self.view addSubview:imageView];
 
 
   [UIView beginAnimations: nil context: @identifier];
 
  [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
 
  [UIView setAnimationDuration:0.5];
 
   imageFrame.origin = CGPointMake(0,0);
 
  imageView.frame = imageFrame;
 
   [UIView commitAnimations];
 
  [imageView release];
 
  }
 
  Can you see anything that is not right? Why is the memory allocation
 showing
  different in simulator and on the iPhone?
 
  Thanks a lot,
  Dragos
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post 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/maillist%40steelskies.com
 
  This email sent to maill...@steelskies.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


[OT] Re: iPhone List? - few questions

2009-07-24 Thread Alastair Houghton

On 24 Jul 2009, at 12:36, Jesse Armand wrote:

I suppose mobile banking is less secure than regular internet  
banking ?


I'm not sure what is the weakness in mobile banking, compared to
regular internet banking, where both of them have a secure device to
generate code for transactions ?

Let's say somebody stole your phone, what can he/she do without the
secure device that's registered to your bank account ?


This doesn't seem relevant to Cocoa.  Please can we *try* to keep the  
list on-topic?  It's a very high traffic list and it's hard to follow  
as it is, without discussions on the finer points of mobile versus  
Internet banking or the recent one about recording phone calls.


If you want to discuss the pros and cons of Internet versus mobile  
banking, you can always e-mail the person/people you're talking with  
directly rather than copying the list.


Obviously Scott Anguish, the moderator, has the last word, but perhaps  
we could make an effort not to require his input *every* single time?


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


[Modderato]Re: iPhone List? - few questions

2009-07-24 Thread Scott Anguish

None of this is Cocoa related

take it off the list immediately


On 2009-07-24, at 7:36 AM, Jesse Armand wrote:

I suppose mobile banking is less secure than regular internet  
banking ?


I'm not sure what is the weakness in mobile banking, compared to
regular internet banking, where both of them have a secure device to
generate code for transactions ?

Let's say somebody stole your phone, what can he/she do without the
secure device that's registered to your bank account ?

Jesse Armand

(http://jessearmand.com)



On Fri, Jul 24, 2009 at 8:12 AM, Roland Kingr...@rols.org wrote:
Well you can't register to listen to SMSes, that hook just doesn't  
exist. So
if you rely on proving who someone is by sending something to a  
specific
phone (ie making use of the telephone companys vast network ability  
to
locate one device with that particular SIM card in it at that point  
in time

anywhere in the world), SMS is kind of about the only way to do it.

I took a look to see what happens when you're running an app and an  
SMS
comes in, with a URL on it . it's not totally pretty, you get to  
option to
'reply', which closes your app, or 'close' which closes the SMS. So  
the best
you could do like that is hit reply, close your app, hit the link  
in the SMS

which opens it up again, you'd need a quick-start app for that.

The only other way is to have done the SMS thing way in advance and  
cached a
token on the phone you use at the time direct to the server, but  
that's not
very good security, the token would go with the phone, swap SIM  
cards and

someone else is now you.


___

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

Please do not post 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/scott%40cocoadoc.com

This email sent to sc...@cocoadoc.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: mouse entered/exited in nscollectionviewitem's view

2009-07-24 Thread Keith Duncan
the setup code only gets called once and then none of the actually  
displayed views in the collection handle any of my intended mouse  
tracking.


That's probably because your subclass of NSCollectionViewItem isn't  
getting created for each item. You can override -copyWithZone: to  
confirm this and fix it if need be.


It's also prudent to ask for the mouse moved events to be sent too.

Could anyone please point me into the right direction where to go on  
from here?

Any help is appreciated.


Yes, you'll also run into a problem when the user uses the scroll  
wheel to move around the collection view. The fix for this one is  
slightly more in depth.


Your view under the mouse will first be send -scrollWheel: and it will  
work it's way up the responder chain to the scroll view from there. I  
inserted my NSCollectionViewItem subclass into the responder chain  
between the item view and it's superview so that the controller was  
sent -scrollWheel: before the scroll view.


In that method I tracked the position of the mouse converting from  
window coordinates to collection view coordinates and determined which  
view the mouse was hovering over. Once you've done that it's a simple  
matter of posting a notification internal to the collection view item  
subclass to coordinate the hovering state between controllers so that  
only one is showing the hovering state at a given time.


Keith

___

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

Please do not post 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: memory allocation different in simulator and on the iPhone

2009-07-24 Thread Jonathan del Strother
I believe +[UIImage imageNamed] caches the image, so you would see
memory increasing.  I'm guessing that you eventually triggered a
memory warning, so UIImage dropped its caches, resulting in the crash
due to your over-release.

On Fri, Jul 24, 2009 at 1:04 PM, Dragos Ioneldragosio...@gmail.com wrote:
 You are right, I was over releasing and maybe that was crashing the app.
 But still, even without [image release] the memory used by the app on iPhone
 is slowly increasing (like 3K for each image display). Maybe that is
 supposed to happen , maybe something is cached somewhere.
 But the good thing is it did not crash anymore after 200-300 images
 displayed.
 Thanks a lot,
 Dragos


 On Fri, Jul 24, 2009 at 3:14 AM, Jonathan del Strother
 maill...@steelskies.com wrote:

 UIImage* image = [UIImage imageNamed:fileName];
 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
 [image release];

 You're overreleasing the image there.  You sure the phone is dying
 because it's out of memory, rather than because of that?

 On Fri, Jul 24, 2009 at 3:07 AM, Dragos Ioneldragosio...@gmail.com
 wrote:
  Hi,
  I am working on a animal encyclopedia on iPhone. One of the pages
  displays
  one photo of an animal. When the user swipes the screen the image is
  replaced with another one.
 
  This works fine and when tested in the simulator with the Instrument for
  Object Allocation, all looks cool.
 
  When I tested on the real iPhone with Instrument, the memory used
  increases
  slowly but constantly so that eventually the application dies.
 
  Here is the method that is doing the image changing (direction means if
  the
  new image should come from left or from right). The class is a
  UIViewController
 
 
  -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{
 
   crtIndex = animaIndex;
 
   NSString* animalName = [[animalList objectAtIndex:animaIndex]
  objectForKey:
  @name];
 
  NSString* fileName   = [[animalList objectAtIndex:animaIndex]
  objectForKey:
  @file];
 
   self.title = animalName;
 
   //remove all the subviews
 
  for (UIView *view in self.view.subviews) {
 
  [view removeFromSuperview];
 
  }
 
   UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,
  320,
  480)];
 
  backgroundView.backgroundColor = [UIColor blackColor];
 
  [self.view addSubview:backgroundView];
 
  [backgroundView release];
 
   UIImage* image = [UIImage imageNamed:fileName];
 
  UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
 
  [image release];
 
   CGRect imageFrame = imageView.frame;
 
  imageFrame.origin = CGPointMake(320*direction,0);
 
  imageView.frame = imageFrame;
 
   [self.view addSubview:imageView];
 
 
   [UIView beginAnimations: nil context: @identifier];
 
  [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
 
  [UIView setAnimationDuration:0.5];
 
   imageFrame.origin = CGPointMake(0,0);
 
  imageView.frame = imageFrame;
 
   [UIView commitAnimations];
 
  [imageView release];
 
  }
 
  Can you see anything that is not right? Why is the memory allocation
  showing
  different in simulator and on the iPhone?
 
  Thanks a lot,
  Dragos
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post 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/maillist%40steelskies.com
 
  This email sent to maill...@steelskies.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: memory allocation different in simulator and on the iPhone

2009-07-24 Thread Jesse Armand
Try to use image allocation methods besides imageNamed

Jesse Armand

(http://jessearmand.com)



On Fri, Jul 24, 2009 at 9:07 AM, Dragos Ioneldragosio...@gmail.com wrote:
 Hi,
 I am working on a animal encyclopedia on iPhone. One of the pages displays
 one photo of an animal. When the user swipes the screen the image is
 replaced with another one.

 This works fine and when tested in the simulator with the Instrument for
 Object Allocation, all looks cool.

 When I tested on the real iPhone with Instrument, the memory used increases
 slowly but constantly so that eventually the application dies.

 Here is the method that is doing the image changing (direction means if the
 new image should come from left or from right). The class is a
 UIViewController


 -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{

  crtIndex = animaIndex;

  NSString* animalName = [[animalList objectAtIndex:animaIndex] objectForKey:
 @name];

 NSString* fileName   = [[animalList objectAtIndex:animaIndex] objectForKey:
 @file];

  self.title = animalName;

  //remove all the subviews

 for (UIView *view in self.view.subviews) {

 [view removeFromSuperview];

 }

  UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320,
 480)];

 backgroundView.backgroundColor = [UIColor blackColor];

 [self.view addSubview:backgroundView];

 [backgroundView release];

  UIImage* image = [UIImage imageNamed:fileName];

 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

 [image release];

  CGRect imageFrame = imageView.frame;

 imageFrame.origin = CGPointMake(320*direction,0);

 imageView.frame = imageFrame;

  [self.view addSubview:imageView];


  [UIView beginAnimations: nil context: @identifier];

 [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];

 [UIView setAnimationDuration:0.5];

  imageFrame.origin = CGPointMake(0,0);

 imageView.frame = imageFrame;

  [UIView commitAnimations];

 [imageView release];

 }

 Can you see anything that is not right? Why is the memory allocation showing
 different in simulator and on the iPhone?

 Thanks a lot,
 Dragos
 ___

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

 Please do not post 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/mnemonic.fx%40gmail.com

 This email sent to mnemonic...@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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Dave Camp

On Jul 23, 2009, at 4:44 PM, Jerry Krinock wrote:

I'd often like to block the main thread while another thread or  
process performs a little task, but subject to a short timeout.  A  
few weeks ago, I was able to achieve this by running the main  
thread's run loop while an NSTask completed.  But I did this after  
hours of experimenting and still don't understand how it works.   
Today, when I tried to generalize the code, waiting for a little  
worker thread instead of an NSTask, my run loop just gets stuck.



The point of using a worker thread is to not block the main thread. If  
you are just going to block the main thread you might as well actually  
do the work on the main thread.


If you could post what you are trying to do here, there might be  
another way to achieve you goals without blocking the main thread.


Dave
___

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

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

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

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


Re: When saving the managed object context

2009-07-24 Thread Mike Abdullah


On 22 Jul 2009, at 15:22, Squ Aire wrote:



How can I do some custom stuff before my NSManagedObjectContext  
saves? (I want to cleanup some garbage that might get created  
while my app is running). In my case this would be faster to do than  
override my NSManagedObject didTurnIntoFault.


So, to do this, is it safe for me to subclass NSManagedObjectContext  
and override save:? Or is this one of those methods I should not  
override? Any better ways?


As you long as you call super's implementation (obviously!), then yes  
it's safe. But watch out for the fact that during a store migration,  
Core Data may well internally use a different MOC and save it,  
ignoring your subclass.


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: Comparing NSImages

2009-07-24 Thread Benjamin Rister

On Jul 23, 2009, at 5:19 PM, Nick Zitzmann wrote:
Considering that there are several different variations on the TIFF  
file format (e.g. big-endian vs. little-endian, 0 is black vs. 1 is  
black, and then there's metadata), this would not surprise me.


Yeah, that's what I expected, thanks.


On Jul 23, 2009, at 5:39 PM, Greg Guerin wrote:
Subtract the test's output image from the reference image, pixel by  
pixel, and look for any non-zero differences.  This assumes  
compatible representations and no differences introduced by any  
other image-handling steps (e.g. device-RGB is device-dependent, so  
can't be assumed to be unvarying).


Even so, you might encounter small non-zero differences that  
originate from outside your code-under-test.  If these are larger  
than +/-1 they could be significant; +/-1 I'd probably accept as  
within the margin-of-error for rounding.


Thanks, I didn't know if there was a cleaner way than doing it pixel- 
by-pixel myself; the info on reasonable tolerances is also quite  
helpful.



I've tracked down the problem using this method (unfortunately, can't  
yet write about the issue here for the archives); thanks to everybody  
for their help.


Benjamin Rister
___

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

Please do not post 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: Text is flipped vertically

2009-07-24 Thread Agha Khan

I was able to fix that problem by

CGContextTranslateCTM(context, 0.0, rect.size.height);
CGContextScaleCTM(context,1.0, -1.0);

It works fine now. Thank you for reply.

Best regards
Agha
On Jul 23, 2009, at 8:18 PM, Kyle Sluder wrote:


On Jul 23, 2009, at 6:03 PM, Agha Khan agha.k...@me.com wrote:


I was unable to find where I have flipped the CGContextRef and
for some strange reason my text is flipped vertically. Any idea how  
to reset CGContextRef?


Maybe it's a better idea to figure out where you're flipping the  
context.


How are you drawing the text? The text system is extremely sensitive  
about the flippedness of the views it draws into.


--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: Comparing NSImages

2009-07-24 Thread Greg Guerin

Benjamin Rister wrote:

Thanks, I didn't know if there was a cleaner way than doing it  
pixel- by-pixel myself; the info on reasonable tolerances is also  
quite helpful.



Image subtraction or differencing is an image-processing operation.   
Consider looking in that domain.  E.g. look for an Obj-C library that  
performs generalized image-processing on NSImage types.


Also, some image-processing can be synthesized from image-compositing  
operations and judicious use of constant (e.g. all-white, all-black,  
etc.) images.  Look at the formulas for the NSCompositeXX values and  
apply some algebra.


  -- GG

___

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

Please do not post 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


Search Item in the Application menu missing in Other languages

2009-07-24 Thread Arun
Hi All,

I have a cocoa application which is localized in multiple languages.
My application uses default Menu's like File, Edit, View, etc.,
When the language is set to English in the System Preferences -
International - languages, Under the Help menu there is an item called
Search.
But if the language is changed to french, German or Japanese and application
is launched, the same Search item under Help menu is missing.
Is there anything that is missing or not configured in my application for
which my application is behaving like this?

Thanks
Arun
___

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

Please do not post 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


errSecDuplicateItem keychain error

2009-07-24 Thread Alejandro Rodriguez

Hello all,

	I'm having a very odd problem. I'm trying to add a keychain item  
using SecKeychainItemCreateFromContent from the security framework. Of  
course before trying to add a new item I check if it exists with:  
SecKeychainSearchCreateFromAttributes.That's when the odd part comes  
in, I get that the item doesn't exist, which I confirm with the  
'keychain Access' application and yet I get a –25299  
(errSecDuplicateItem) error when I try to create the item. In fact I  
tried modifying the item assuming that it exists even though I can't  
find it and (as expected) the program crashes because it tries to  
modify a key that doesn't exist. Has anyone had a similar error? can  
anyone shed some light on me?


Thanks in advance!
best regards,

Alejandro Rodríguez___

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

Please do not post 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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Jerry Krinock


On 2009 Jul 23, at 17:44, Ken Thomases wrote:


On Jul 23, 2009, at 6:44 PM, Jerry Krinock wrote:


I'd often like to block the main thread


First question is: why?  Blocking the main thread is usually bad and  
to be avoided.  What are you actually trying to achieve?  Can you  
give an example of when that would be desirable?


This happens any time that a user action absolutely requires some  
little job be done in a low-leve method before proceeding, but this  
job fails on rare occasions.


For example, say a user action requires that data be read in from a  
file known by a file alias which must be resolved.  It can't continue  
without the resolved path, but if it's on a remote volume that was not  
properly dismounted, Alias Manager will beachball my app for 150  
seconds before giving up.


The notifications don't cross threads; they are delivered in the  
thread where they are posted.



Yes, I understand that.  There must be some quirk that allows it to  
work when doing an NSTask


If you really want to use a run loop in this manner, you could use a  
port.  The SSYThreadBlocker would be the port's delegate to handle  
messages it receives; it would run the run loop to allow messages to  
be received and processed; the worker thread would send them.  You  
might consider using a private run-loop mode, though, so the run  
loop is only processing your input source.


Yes, when I read the documentation, I thought the same thing.  Oh,  
OK, I just need to add a port. After writing a bunch of code that  
didn't work, I gave up on it.


Do consider NSConditionLock as an alternative, though.  It's likely  
to be much simpler and more straightforward.


Yes, I've been using NSOperation for so long now that I forgot about  
old NSConditionLock.  Although used more commonly to protect access  
across threads, it is in fact exactly what I need -- to block a thread  
until some condition.


Thanks, Ken!

The final, working code is probably a little too long to post in here,  
because I also ended up #importing my NSInvocation-maker category.  So  
I'm just pasting in the @interface.  One of these days I'll get this  
stuff up on a version control server somewhere.  If anyone wants it in  
the meantime, just let me know privately.


@interface SSYThreadPauser : NSObject {
}

/*!
 @briefRuns a job on another thread and blocks the current
 thread until the method is complete, or until a timeout, whichever
 happens first.

 @details  If timeout occurs, the workerThread will be sent
 a -cancel message, so that if your worker periodically sends - 
isCancelled

 to its current thread, it can abort the work in order to stop wasting
 cpu cycles.nbsp;  See -[NSThread isCancelled] documentation.
 @paramworker  The target which will perform the job.
 @paramselector  The selector of the job to be run.  This
 method need not create nor drain an autorelease pool if garbage  
collection

 is not being used, because SSYThreadPauser takes care of that.
 @paramobject  A parameter which will be passed to selector
 @paramworkerThread  The thread on which the job will be performed.
 If you pass nil, a temporary thread will be created.
 @paramtimeout  The timeout before the job is aborted.
 @result   YES if the job completed, NO if it timed out.
 */
+ (BOOL)blockUntilWorker:(id)worker
selector:(SEL)selector
  object:(id)object
  thread:(NSThread*)workerThread
 timeout:(NSTimeInterval)timeout ;

@end


___

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

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

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

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


Re: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Dave Keck
 The notifications don't cross threads; they are delivered in the thread
 where they are posted.

 Yes, I understand that.  There must be some quirk that allows it to work
 when doing an NSTask

Just a tidbit - I don't think there's any quirks involved. The general
idea is this: NSTask creates a run loop source on the main thread, and
spawns a second thread to watch the process for termination. When the
process terminates, the secondary thread signals the main thread's run
loop (via CFRunLoopSourceSignal()), and the run loop source's callback
then executes on the main thread, which issues the notification. On
10.5+, this can be done trivially using kqueue and CFFileDescriptor.

David
___

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

Please do not post 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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Charles Srstka

On Jul 24, 2009, at 5:10 PM, Dave Keck wrote:

The notifications don't cross threads; they are delivered in the  
thread

where they are posted.


Yes, I understand that.  There must be some quirk that allows it to  
work

when doing an NSTask


Just a tidbit - I don't think there's any quirks involved. The general
idea is this: NSTask creates a run loop source on the main thread, and
spawns a second thread to watch the process for termination. When the
process terminates, the secondary thread signals the main thread's run
loop (via CFRunLoopSourceSignal()), and the run loop source's callback
then executes on the main thread, which issues the notification. On
10.5+, this can be done trivially using kqueue and CFFileDescriptor.


You could probably also notify the main thread by using - 
performSelectorOnMainThread:withObject:waitUntilDone: to execute  
NSNotificationCenter's postNotification: method.


Charles
___

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

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

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

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


Re: memory allocation different in simulator and on the iPhone [solved]

2009-07-24 Thread Dragos Ionel
Dear all,
Thank you all for the feedback. With that help and few hours of digging I
was able to solve the problem.

Just for reference here is what I was doing wrong;

1.

UIImage* image = [UIImage imageNamed:fileName];

UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

*[image **release**];*

If an image is created using imageNamed, then it is released automatically
so [image release] is incorrect;

2. At one point I was doing [titleLabel dealloc] for a UILabel instead of
[titleLabel release];


*How I discover where it was crashing*? I added NSLog in different part of
the code, run the application in simulator, and selected Hardware -
Simulate Memory Warning.


*How I got tricked?* I looked at memory allocation and after each
imagedNamed there was a huge increase. That made me think that I have to
release the image which is not correct. The imageNamed is caching the image,
but it is clearing the cache when need be.

Your help was much appreciated!

Dragos


On Thu, Jul 23, 2009 at 10:07 PM, Dragos Ionel dragosio...@gmail.comwrote:

 Hi,
 I am working on a animal encyclopedia on iPhone. One of the pages displays
 one photo of an animal. When the user swipes the screen the image is
 replaced with another one.

 This works fine and when tested in the simulator with the Instrument for
 Object Allocation, all looks cool.

 When I tested on the real iPhone with Instrument, the memory used increases
 slowly but constantly so that eventually the application dies.

 Here is the method that is doing the image changing (direction means if the
 new image should come from left or from right). The class is a
 UIViewController


 -(void) displayAnimal: (int) animaIndex fromDirection:(int)direction{

  crtIndex = animaIndex;

  NSString* animalName = [[animalList objectAtIndex:animaIndex]
 objectForKey:@name];

 NSString* fileName   = [[animalList objectAtIndex:animaIndex] objectForKey
 :@file];

  self.title = animalName;

  //remove all the subviews

 for (UIView *view in self.view.subviews) {

 [view removeFromSuperview];

 }

  UIView* backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,
 320, 480)];

 backgroundView.backgroundColor = [UIColor blackColor];

 [self.view addSubview:backgroundView];

 [backgroundView release];

  UIImage* image = [UIImage imageNamed:fileName];

 UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

 [image release];

  CGRect imageFrame = imageView.frame;

 imageFrame.origin = CGPointMake(320*direction,0);

 imageView.frame = imageFrame;

  [self.view addSubview:imageView];


  [UIView beginAnimations: nil context: @identifier];

 [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];

 [UIView setAnimationDuration:0.5];

  imageFrame.origin = CGPointMake(0,0);

 imageView.frame = imageFrame;

  [UIView commitAnimations];

 [imageView release];

 }

 Can you see anything that is not right? Why is the memory allocation
 showing different in simulator and on the iPhone?

 Thanks a lot,
 Dragos

___

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

Please do not post 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: Search Item in the Application menu missing in Other languages

2009-07-24 Thread Peter Ammon


On Jul 24, 2009, at 11:22 AM, Arun wrote:


Hi All,

I have a cocoa application which is localized in multiple languages.
My application uses default Menu's like File, Edit, View, etc.,
When the language is set to English in the System Preferences -
International - languages, Under the Help menu there is an item  
called

Search.
But if the language is changed to french, German or Japanese and  
application

is launched, the same Search item under Help menu is missing.
Is there anything that is missing or not configured in my  
application for

which my application is behaving like this?

Thanks
Arun


Hi Arun,

Leopard has some heuristics for determining which menu is the Help  
menu.  The simplest way to make sure it gets identified correctly in  
all languages is to include a menu item with the default Help action,  
which is @selector(showHelp:).


Hope this, well, helps,
-Peter
___

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

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

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

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


Display csv in a tableView with bindings

2009-07-24 Thread gumboots

I need some direction please.

I would like to load a csv file and display the contents in an  
NSTableView. What is the best way to achieve this with bindings?


Should the model store the data in an array of arrays (rows and  
columns) or a dictionary of arrays (keyed columns and rows)?


___

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

Please do not post 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


Crash when MyDocument becomes the delegate of NSApplication

2009-07-24 Thread Jochen Moeller

Hello List,

Suddenly my Doc-based Cocoa App began to crash always when I closed a  
window.
In a long run I tracked it down when myDocument is made the delegate  
of NSApplication.


I did the following few steps to reproduce the crash with an empty  
App. in Xcode 3.1.3:


New Document-based Cocoa Application without GC.
Doubleclick MyDocument.xib, select the Application-Icon and make the  
File's Owner the delegate of it.

Back in Xcode I wrote two NSLogs in -init:

- (id)init {
  NSLog(@%@ - %@, [self className], NSStringFromSelector(_cmd));
  self = [super init];
  if (self) {
NSLog(@  self: %p, self);
  }
  return self;
}

Then I enabled Zombies:
ExecutableApp / Info / Arguments / Vars for environment /  
NSZombieEnabled YES.


When running the App and closing the window, or repeated New and  
Closing again,

the App crashes reproducible with the following output:

[Session started at 2009-07-25 01:52:21 +0200.]
2009-07-25 01:52:21.278 NewDocApp[49373:10b] MyDocument - init
2009-07-25 01:52:21.280 NewDocApp[49373:10b]   self: 0x175d70

[Session started at 2009-07-25 01:52:25 +0200.]
2009-07-25 01:52:25.724 NewDocApp[49373:10b] *** -[MyDocument  
respondsToSelector:]:

 message sent to deallocated instance 0x175d70
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:43:13  
UTC 2009)

...snip...
This GDB was configured as i386-apple-darwin.sharedlibrary apply- 
load-rules all

Attaching to process 49373.
kill

The Debugger Debugger is attaching to process(gdb)

So the MyDocument class seems to be overreleased by NSApplication.

Is that a known issue?
Never use an NSDocument subclass for delegates?

Thanks for comments,
Jochen Moeller

___

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

Please do not post 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: Crash when MyDocument becomes the delegate of NSApplication

2009-07-24 Thread Kyle Sluder
On Fri, Jul 24, 2009 at 6:01 PM, Jochen Moellerjo.moel...@online.de wrote:
 In a long run I tracked it down when myDocument is made the delegate of
 NSApplication.

Why would your document be an NSApplication delegate?  What happens
when you have two documents open -- you can't have two NSApplication
delegates.  So your short solution is: stop making your documents the
delegate of your application.

The reason why you were getting a crash:

NSApplication lives for the duration of your application (duh.)  It
does not retain its delegate, because delegates are not retained
according to Cocoa memory management rules (this is because they often
retain the thing they're a delegate of).  So when you create a
document and set it to be the app's delegate, and then close the
document, the application is still going to send its delegate messages
to whatever pointer it remembers as its delegate.  Unless you
explicitly say [NSApp setDelegate:nil] in your document's -dealloc
implementation, NSApplication is going to have a weak pointer to
nowhere, and will crash when sending a message to it.

--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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Graham Cox


On 25/07/2009, at 7:50 AM, Jerry Krinock wrote:

First question is: why?  Blocking the main thread is usually bad  
and to be avoided.  What are you actually trying to achieve?  Can  
you give an example of when that would be desirable?


This happens any time that a user action absolutely requires some  
little job be done in a low-leve method before proceeding, but this  
job fails on rare occasions.


For example, say a user action requires that data be read in from a  
file known by a file alias which must be resolved.  It can't  
continue without the resolved path, but if it's on a remote volume  
that was not properly dismounted, Alias Manager will beachball my  
app for 150 seconds before giving up.



The right approach here isn't to block the main thread but harness it  
to your (and the user's) advantage.


Display a modal progress window which tells the user's what's going  
on, show an indeterminate progress bar and include a Stop button.  
The worker code can wait on the alias being resolved and the main  
thread can keep the user informed. By using a modal progress window  
you've effectively blocked the user from doing anything but if they  
are not prepared to wait they have a way to abort the operation (which  
you have to implement of course). Just blocking without telling the  
user what's going on is worse than just beachballing - the beachball  
is after all a feedback mechanism that tells the user *something*.


It's straightforward to write a generic progress controller class that  
can automatically wait a few seconds before displaying itself, so if  
the operation does complete quickly, the progress dialog isn't shown  
but there's no need on the part of the worker code to special-case for  
that - just start progress at the beginning and end progress at the  
end. The dialog will run the main thread in a modal loop.


--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: Crash when MyDocument becomes the delegate of NSApplication

2009-07-24 Thread Jochen Moeller

Hi Kyle,

You are right, I did not consider that.
Because NSDocument is a controller object I used it similar to a self- 
made AppController.


Thanks for your explanation.

Jochen Moeller

Am 25.07.2009 um 03:26 schrieb Kyle Sluder:

Why would your document be an NSApplication delegate?  What happens
when you have two documents open -- you can't have two NSApplication
delegates.  So your short solution is: stop making your documents the
delegate of your application.

The reason why you were getting a crash:

NSApplication lives for the duration of your application (duh.)  It
does not retain its delegate, because delegates are not retained
according to Cocoa memory management rules (this is because they often
retain the thing they're a delegate of).  So when you create a
document and set it to be the app's delegate, and then close the
document, the application is still going to send its delegate messages
to whatever pointer it remembers as its delegate.  Unless you
explicitly say [NSApp setDelegate:nil] in your document's -dealloc
implementation, NSApplication is going to have a weak pointer to
nowhere, and will crash when sending a message to it.

--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: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Ken Thomases

On Jul 24, 2009, at 5:10 PM, Dave Keck wrote:

The notifications don't cross threads; they are delivered in the  
thread

where they are posted.


Yes, I understand that.  There must be some quirk that allows it to  
work

when doing an NSTask


Just a tidbit - I don't think there's any quirks involved. The general
idea is this: NSTask creates a run loop source on the main thread, and
spawns a second thread to watch the process for termination. When the
process terminates, the secondary thread signals the main thread's run
loop (via CFRunLoopSourceSignal()), and the run loop source's callback
then executes on the main thread, which issues the notification. On
10.5+, this can be done trivially using kqueue and CFFileDescriptor.


First, I believe that NSTask installs a run loop source in the thread  
which launches the task, not necessarily the main thread.  This often  
bytes people who launch an NSTask from a secondary thread, but never  
let that thread's run loop run, so they never receive notification  
that is has terminated.  Also, there are reports that some NSTask  
resources don't get cleaned up if the thread it was launched from is  
allowed to exit before termination, again presumably because the run  
loop wasn't run to handle the event of the termination.


Second, there's no need for NSTask to spawn a second thread to monitor  
the process for termination.  The innards of NSTask are of course an  
implementation detail.  That said, if it's using kqueue to monitor the  
process or using low-level Mach mechanisms (there are notifications  
that a Mach port has been destroyed/orphaned which can be used to  
learn when the owning process has terminated), that can be done with  
the run loop and the source that's installed.  The whole point of run  
loops is to be able to monitor various things _without_ spawning a  
thread for each.


Regards,
Ken

___

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

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

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

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


Re: Challenge: Block Main Thread while Work is done, with Timeout

2009-07-24 Thread Ken Thomases

On Jul 24, 2009, at 4:50 PM, Jerry Krinock wrote:


On 2009 Jul 23, at 17:44, Ken Thomases wrote:


On Jul 23, 2009, at 6:44 PM, Jerry Krinock wrote:


I'd often like to block the main thread


First question is: why?  Blocking the main thread is usually bad  
and to be avoided.  What are you actually trying to achieve?  Can  
you give an example of when that would be desirable?


This happens any time that a user action absolutely requires some  
little job be done in a low-leve method before proceeding, but this  
job fails on rare occasions.


For example, say a user action requires that data be read in from a  
file known by a file alias which must be resolved.  It can't  
continue without the resolved path, but if it's on a remote volume  
that was not properly dismounted, Alias Manager will beachball my  
app for 150 seconds before giving up.


You've presumably already moved the work to a background thread.  So,  
why not just set a timer on the main thread to inform the user that  
the work is taking a long time (or whatever user interaction is  
appropriate)?  When the background thread completes, have it perform a  
selector on the main thread which, among other things, can cancel the  
timer if it's still outstanding.  Thus, if the work completes quickly,  
the timer never fires.  This is completely asynchronous on the main  
thread.


If there's more to be done on the main thread after the background  
thread has completed, that can be initiated by the completion  
selector.  However, it might be simplest to just have the background  
thread do all of the work for the task at hand, if that can be arranged.



Do consider NSConditionLock as an alternative, though.  It's likely  
to be much simpler and more straightforward.


Yes, I've been using NSOperation for so long now that I forgot about  
old NSConditionLock.  Although used more commonly to protect access  
across threads, it is in fact exactly what I need -- to block a  
thread until some condition.


Thanks, Ken!


You're welcome.  I'm glad it helped.

Cheers,
Ken

___

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

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

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

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


Unit testing question

2009-07-24 Thread lorenzo7620
I'd like to add unit testing to my app, but I'ma little bit unclear on the  
concept. I've looked at Apple's docs on the Sentest framework and had no  
trouble getting the sample project working, but I lose it when translating  
the concepts to my particular application. I've seen some sample projects  
around the net that use the Sentest framework, but the the unit tests are  
trivially simple, asserting that 1+1 = 2, for example. What I really need  
is a sample project of some complexity that uses real unit tests against  
the project. Can anyone help me out here? My app is an NSStatusItem that  
retrieves data from the internet, and displays it in the NSStatusItem's  
menu. The only real user interface besides that is the preferences window.  
Should my unit test manually invoke the IBAction that displays the window  
and then fill its fields with values I need to test?

TIA
___

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

Please do not post 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