Re: URLWithString fails to fails with bad string

2009-11-25 Thread Kyle Sluder
On Tue, Nov 24, 2009 at 10:14 PM,  lorenzo7...@gmail.com wrote:
 This returns a non-nil value:
 NSURL * url = [NSURL URLWithString:@sdsds];

 The docs say this should fail. RFC 1758 looks for the string to begin with a
 scheme, eg http:

While sdsds is indeed a valid relative URL according to RFC 2396,
don't let NSURL's declaration of RFC-conformance fool you.  I have a
pretty severe bug (rdar://problem/7096953) logged against NSURL's
incorrect handling of IDNs.  Despite pointing to the spec, copying it
into the bug report, and walking step by step through NSURL's
violation thereof, I was told that it behaves according to the spec
and as designed.  I no longer trust NSURL's assertions of conformance.

--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: Cant Access Properties of NSManagedObject from a NSArrayController...

2009-11-25 Thread Laurent Demaret
Hi Gustavo,

Gustavo Pizano gustavxcodepic...@gmail.com wrote:

 I needed to use not the proxy but the selected element. .. grrr.. 

Then I may advise you to use the lastObject selector il you expect only
one selectedObject. Using objectAtIndex:0 will give a BAD_EXEC (as long
I recall) Error (anyway) each time you have an empty array.

hth

Laurent
___

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

Please do not post 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: Best approach to write an uninstaller for osx

2009-11-25 Thread Parimal Das
Okay

How i will perform these two operations in my uninstall.app
1. Removal of app icon from dock if Keep in dock is selected
2. Removal of app from user launch services if Open at login is selected


On Tue, Nov 24, 2009 at 10:02 PM, Jens Alfke j...@mooseyard.com wrote:


 On Nov 24, 2009, at 6:30 AM, Parimal Das wrote:

  4. This script copies DeleteAll.app to /private/tmp/  AND then runs
 DeleteAll.app from Temp location.

 Why do you need two different apps? Just have Uninstall.app delete itself
 when it finishes.

  do shell script sudo cp -R '  ourPath  ' '  tempPath  '
 with administrator privileges

 Remember how I said to be careful about quoting? The command above will
 fail if ourPath contains any single quotes.

 Also, this task really shouldn't require admin privileges. You're making it
 impossible for a non-admin to uninstall the app (even from their own home
 directory), and greatly increasing the potential danger of your quoting
 error, since that cp command is capable of copying anything anywhere.

 —Jens




-- 
--
Warm Regards,

Parimal Das
Webyog Softworks
___

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

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


GC, variable optimized away wrongly?

2009-11-25 Thread Nick Rogers
Hi,
In my app running on snow leopard, in a particular situation I'm getting an 
undesired behavior.
Debugging a for loop shows a still in scope variable being optimized away.

code: (problem occurs after the loop has been iterated thousands (may be more) 
of time.

for loop statement here()
{
NSDate *currentDate = [NSDate date];// ok value here
NSTimeInterval interval = [currentDate 
timeIntervalSinceDate:startDate];// ok value here
NSTimeInterval etaDouble = interval  * ((totalBlocks - blockCount) / 
blockCount);   // * debugger doesn't list this variable, mouse shows a pop 
up saying variable optimized away by compiler
int eta = (int)etaDouble;   // value is 0 here instead of something
int seconds = eta % 60; // value is 0 here instead of something
int minutes = (eta / 60) % 60;  // value is 0 here instead of something
int hours = ((eta / 60) / 60) % 24; // value is 0 here instead of 
something
int days = ((eta / 60) / 60) / 24;  // value is 0 here instead of 
something


}

Why the certain variables are not listed in debugger window (only in GC-only 
projects)?
Why is etaDouble is being optimized away?
Any suggestions?


Wishes,
Nick

___

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

Please do not post 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: GC, variable optimized away wrongly?

2009-11-25 Thread Kyle Sluder
On Wed, Nov 25, 2009 at 4:50 AM, Nick Rogers roger...@mac.com wrote:
 In my app running on snow leopard, in a particular situation I'm getting an 
 undesired behavior.
 Debugging a for loop shows a still in scope variable being optimized away.

Barring a *serious* bug in the compiler, optimization does not
introduce such behavior.  So the bug is yours, the optimization is
just interfering with your ability to fix it.

        NSTimeInterval etaDouble = interval  * ((totalBlocks - blockCount) / 
 blockCount);       // * debugger doesn't list this variable, mouse shows a 
 pop up saying variable optimized away by compiler
int eta = (int)etaDouble;   // value is 0 here instead of something

The compiler's data flow analysis can prove that etaDouble is only
ever used to initialize eta, so it is simply skipping emitting code
for an etaDouble variable altogether.  This is not why your value is
0.

 Why the certain variables are not listed in debugger window (only in GC-only 
 projects)?

Data flow analysis will be subject to the garbage collection rules,
just like anything else.

 Why is etaDouble is being optimized away?

Because it is unused.

 Any suggestions?

Disable optimizations on your debug builds (-O0).

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


Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Florian Soenens
Hi list,

i'm trying to override an IKImageBrowserView to do some custom drawing but i'm 
stuck.
What i try to accomplish is that when the view contains zero items, some custom 
drawing happens like drawing an NSAttributedString that says Drop items 
here...
Problem is that my drawing code gets never called.

Here's the drawRect method of my IKImageBrowserView:

- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];

NSUInteger numItems = [[self dataSource] 
numberOfItemsInImageBrowser:self];

if(numItems = 0)
{
NSLog(@No items in me); // This gets called, so i'm sure the 
above code works

NSRect bounds = [self bounds];
bounds.size.width = 200;
bounds.size.height = 200;
bounds.origin.x += 200;
bounds.origin.y += 200;

//[NSGraphicsContext saveGraphicsState];

[[NSColor yellowColor] set]; // Just for testing purposes
NSRectFill(bounds);

//[NSGraphicsContext restoreGraphicsState];
}
}

Uncommenting the NSGrahicsContext doesn't help either.

Anyone has any ideas or workarounds for this?
Thanks in advance,
Florian
___

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

Please do not post 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: Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Thomas Goossens
Hi Florian,

You can't do custom drawing this way (because the IKImageBrowserView renders 
into an openGL surface, so AppKit or CoreGraphics calls won't do anything).
So to do what you want you can either:
- make the view layer backed and add a sub-layer
- add an overlay transparent window on top of the image browser view
- add an overlay layer with setForegroundLayer: (that's the easiest solution 
but it is SnowLeopard only).

-- Thomas


On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote:

 Hi list,
 
 i'm trying to override an IKImageBrowserView to do some custom drawing but 
 i'm stuck.
 What i try to accomplish is that when the view contains zero items, some 
 custom drawing happens like drawing an NSAttributedString that says Drop 
 items here...
 Problem is that my drawing code gets never called.
 
 Here's the drawRect method of my IKImageBrowserView:
 
 - (void)drawRect:(NSRect)rect
 {
   [super drawRect:rect];
   
   NSUInteger numItems = [[self dataSource] 
 numberOfItemsInImageBrowser:self];
   
   if(numItems = 0)
   {
   NSLog(@No items in me); // This gets called, so i'm sure the 
 above code works
   
   NSRect bounds = [self bounds];
   bounds.size.width = 200;
   bounds.size.height = 200;
   bounds.origin.x += 200;
   bounds.origin.y += 200;
   
   //[NSGraphicsContext saveGraphicsState];
   
   [[NSColor yellowColor] set]; // Just for testing purposes
   NSRectFill(bounds);
   
   //[NSGraphicsContext restoreGraphicsState];
   }
 }
 
 Uncommenting the NSGrahicsContext doesn't help either.
 
 Anyone has any ideas or workarounds for this?
 Thanks in advance,
 Florian
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/tgoossens%40mac.com
 
 This email sent to tgooss...@mac.com

___

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

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

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

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


NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer

Hello to all on the list.

I have a little question so if anyone could help me.
I'm have an outline view that has one (for now) object in root array  
that acts as a root from which all other objects derives.


\/ Root Array
 |\/ Root object
|- Child 1
|- Child 2
|--- \/ Child 3
   |--- Child 3.1
   |--- Child 3.2
|- Child 4

My question is:
How to hide the disclosure triangle in front of the Root object and  
remove indentation for it, and just that object (and later if there is  
more Root objects for them too) ?


\/ Root Array
 | Root object
|- Child 1
|- Child 2
|--- \/ Child 3
   |--- Child 3.1
   |--- Child 3.2
|- Child 4

I would like it too look like source list in Apple's Mail application  
- where it says - MAILBOXES.


I found the delegate method which is used for drawing outlineCell
- (void)outlineView:(NSOutlineView *)outlineView  
willDisplayOutlineCell:(id)cell forTableColumn: 
(NSTableColumn*)tableColumn item:(id)item


but that method does not get called if Root object is empty.

There is a method that is also used for drawing outlineCell
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row

but it is not a delegate method which means that I should subclass  
NSOutlineView to implement that behavior.


I'm trying to make it work with the delegate method (that would be my  
preferred way) but I can't make it work.

Any suggestions what to do ? And how ?

There is a zip archive of my project at http://www.box.net/crowebster-public 
 so anyone interested can download it to review my work.


P.S. additional question:

If there is number of object that are identical (just added to the  
array but not yet modified), when one item is selected and removeItem  
method is called upon it,

all identical objects are removed instead just selected object.

How to avoid that behavior (the simplest possible way) ?

Notice: All objects are instances of NSMutableDictionary.

That problem is also in the same project.

Any suggestions are appreciated.
Thanks in advance. Bye.


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

Please do not post 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: Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Mike Abdullah
Also, you could try swapping out the image browser (or making it hidden) when 
it is empty, and display an alternative placeholder view in its place.

Also, file a bug report requesting the ability to do this built-in.

On 25 Nov 2009, at 13:44, Thomas Goossens wrote:

 Hi Florian,
 
 You can't do custom drawing this way (because the IKImageBrowserView renders 
 into an openGL surface, so AppKit or CoreGraphics calls won't do anything).
 So to do what you want you can either:
 - make the view layer backed and add a sub-layer
 - add an overlay transparent window on top of the image browser view
 - add an overlay layer with setForegroundLayer: (that's the easiest solution 
 but it is SnowLeopard only).
 
 -- Thomas
 
 
 On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote:
 
 Hi list,
 
 i'm trying to override an IKImageBrowserView to do some custom drawing but 
 i'm stuck.
 What i try to accomplish is that when the view contains zero items, some 
 custom drawing happens like drawing an NSAttributedString that says Drop 
 items here...
 Problem is that my drawing code gets never called.
 
 Here's the drawRect method of my IKImageBrowserView:
 
 - (void)drawRect:(NSRect)rect
 {
  [super drawRect:rect];
  
  NSUInteger numItems = [[self dataSource] 
 numberOfItemsInImageBrowser:self];
  
  if(numItems = 0)
  {
  NSLog(@No items in me); // This gets called, so i'm sure the 
 above code works
  
  NSRect bounds = [self bounds];
  bounds.size.width = 200;
  bounds.size.height = 200;
  bounds.origin.x += 200;
  bounds.origin.y += 200;
  
  //[NSGraphicsContext saveGraphicsState];
  
  [[NSColor yellowColor] set]; // Just for testing purposes
  NSRectFill(bounds);
  
  //[NSGraphicsContext restoreGraphicsState];
  }
 }
 
 Uncommenting the NSGrahicsContext doesn't help either.
 
 Anyone has any ideas or workarounds for this?
 Thanks in advance,
 Florian
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/tgoossens%40mac.com
 
 This email sent to tgooss...@mac.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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


Re: Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Florian Soenens

Hi Thomas,

thanks for the reply, i did try the first method you suggest with  
adding a layer but it didn't work either.
I also tought of the second method but how would i make sure that my  
IKImageBrowserView still receives drop event?


I ned to be compatible with 10.5 so method 3 is out of the question.

Thanks anyway!

Florian.

On 25 Nov 2009, at 14:44, Thomas Goossens wrote:


Hi Florian,

You can't do custom drawing this way (because the IKImageBrowserView  
renders into an openGL surface, so AppKit or CoreGraphics calls  
won't do anything).

So to do what you want you can either:
- make the view layer backed and add a sub-layer
- add an overlay transparent window on top of the image browser view
- add an overlay layer with setForegroundLayer: (that's the easiest  
solution but it is SnowLeopard only).


-- Thomas


On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote:


Hi list,

i'm trying to override an IKImageBrowserView to do some custom  
drawing but i'm stuck.
What i try to accomplish is that when the view contains zero items,  
some custom drawing happens like drawing an NSAttributedString that  
says Drop items here...

Problem is that my drawing code gets never called.

Here's the drawRect method of my IKImageBrowserView:

- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];

	NSUInteger numItems = [[self dataSource]  
numberOfItemsInImageBrowser:self];


if(numItems = 0)
{
		NSLog(@No items in me); // This gets called, so i'm sure the  
above code works


NSRect bounds = [self bounds];
bounds.size.width = 200;
bounds.size.height = 200;
bounds.origin.x += 200;
bounds.origin.y += 200;

//[NSGraphicsContext saveGraphicsState];

[[NSColor yellowColor] set]; // Just for testing purposes
NSRectFill(bounds);

//[NSGraphicsContext restoreGraphicsState];
}
}

Uncommenting the NSGrahicsContext doesn't help either.

Anyone has any ideas or workarounds for this?
Thanks in advance,
Florian
___

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

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

This email sent to tgooss...@mac.com


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be

This email sent to florian.soen...@nss.be




Looking for Web-to-Print Solutions?
Visit our website :   http://www.vit2print.com


This e-mail, and any attachments thereto, is intended only for use by the 
addressee(s) named herein and may contain legally privileged and/or 
confidential information and/or information protected by intellectual property 
rights.
If you are not the intended recipient, please note that any review, 
dissemination, disclosure, alteration, printing, copying or transmission of 
this e-mail and/or any file transmitted with it, is strictly prohibited and may 
be unlawful.
If you have received this e-mail by mistake, please immediately notify the 
sender and permanently delete the original as well as any copy of any e-mail 
and any printout thereof.
We may monitor e-mail to and from our network.

NSS nv Tieltstraat 167 8740 Pittem Belgium 
___


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

Please do not post 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: Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Mike Abdullah

On 25 Nov 2009, at 14:06, Florian Soenens wrote:

 Hi Thomas,
 
 thanks for the reply, i did try the first method you suggest with adding a 
 layer but it didn't work either.
 I also tought of the second method but how would i make sure that my 
 IKImageBrowserView still receives drop event?

You should be able to set the overlay to be invisible to mouse events etc. 
quite easily.
 
 I ned to be compatible with 10.5 so method 3 is out of the question.
 
 Thanks anyway!
 
 Florian.
 
 On 25 Nov 2009, at 14:44, Thomas Goossens wrote:
 
 Hi Florian,
 
 You can't do custom drawing this way (because the IKImageBrowserView renders 
 into an openGL surface, so AppKit or CoreGraphics calls won't do anything).
 So to do what you want you can either:
 - make the view layer backed and add a sub-layer
 - add an overlay transparent window on top of the image browser view
 - add an overlay layer with setForegroundLayer: (that's the easiest solution 
 but it is SnowLeopard only).
 
 -- Thomas
 
 
 On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote:
 
 Hi list,
 
 i'm trying to override an IKImageBrowserView to do some custom drawing but 
 i'm stuck.
 What i try to accomplish is that when the view contains zero items, some 
 custom drawing happens like drawing an NSAttributedString that says Drop 
 items here...
 Problem is that my drawing code gets never called.
 
 Here's the drawRect method of my IKImageBrowserView:
 
 - (void)drawRect:(NSRect)rect
 {
 [super drawRect:rect];
 
 NSUInteger numItems = [[self dataSource] 
 numberOfItemsInImageBrowser:self];
 
 if(numItems = 0)
 {
 NSLog(@No items in me); // This gets called, so i'm sure the 
 above code works
 
 NSRect bounds = [self bounds];
 bounds.size.width = 200;
 bounds.size.height = 200;
 bounds.origin.x += 200;
 bounds.origin.y += 200;
 
 //[NSGraphicsContext saveGraphicsState];
 
 [[NSColor yellowColor] set]; // Just for testing purposes
 NSRectFill(bounds);
 
 //[NSGraphicsContext restoreGraphicsState];
 }
 }
 
 Uncommenting the NSGrahicsContext doesn't help either.
 
 Anyone has any ideas or workarounds for this?
 Thanks in advance,
 Florian
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/tgoossens%40mac.com
 
 This email sent to tgooss...@mac.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be
 
 This email sent to florian.soen...@nss.be
 
 
 
 Looking for Web-to-Print Solutions?
 Visit our website :   http://www.vit2print.com
 
 
 This e-mail, and any attachments thereto, is intended only for use by the 
 addressee(s) named herein and may contain legally privileged and/or 
 confidential information and/or information protected by intellectual 
 property rights.
 If you are not the intended recipient, please note that any review, 
 dissemination, disclosure, alteration, printing, copying or transmission of 
 this e-mail and/or any file transmitted with it, is strictly prohibited and 
 may be unlawful.
 If you have received this e-mail by mistake, please immediately notify the 
 sender and permanently delete the original as well as any copy of any e-mail 
 and any printout thereof.
 We may monitor e-mail to and from our network.
 
 NSS nv Tieltstraat 167 8740 Pittem 
 Belgium___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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


Re: Custom drawing in IKImageBrowserView fails

2009-11-25 Thread Florian Soenens
 Thanks to all for the help.

i went with Mike's solution of swapping view.
I wrapped the IKImageBrowserView into a Tabless NSTabview with in the second 
tab my dropview.

I will also file the bug report as Mike suggested.

Thanks!

On Wednesday, November 25, 2009, at 03:34PM, Mike Abdullah 
cocoa...@mikeabdullah.net wrote:

On 25 Nov 2009, at 14:06, Florian Soenens wrote:

 Hi Thomas,
 
 thanks for the reply, i did try the first method you suggest with adding a 
 layer but it didn't work either.
 I also tought of the second method but how would i make sure that my 
 IKImageBrowserView still receives drop event?

You should be able to set the overlay to be invisible to mouse events etc. 
quite easily.
 
 I ned to be compatible with 10.5 so method 3 is out of the question.
 
 Thanks anyway!
 
 Florian.
 
 On 25 Nov 2009, at 14:44, Thomas Goossens wrote:
 
 Hi Florian,
 
 You can't do custom drawing this way (because the IKImageBrowserView 
 renders into an openGL surface, so AppKit or CoreGraphics calls won't do 
 anything).
 So to do what you want you can either:
 - make the view layer backed and add a sub-layer
 - add an overlay transparent window on top of the image browser view
 - add an overlay layer with setForegroundLayer: (that's the easiest 
 solution but it is SnowLeopard only).
 
 -- Thomas
 
 
 On Nov 25, 2009, at 2:34 PM, Florian Soenens wrote:
 
 Hi list,
 
 i'm trying to override an IKImageBrowserView to do some custom drawing but 
 i'm stuck.
 What i try to accomplish is that when the view contains zero items, some 
 custom drawing happens like drawing an NSAttributedString that says Drop 
 items here...
 Problem is that my drawing code gets never called.
 
 Here's the drawRect method of my IKImageBrowserView:
 
 - (void)drawRect:(NSRect)rect
 {
[super drawRect:rect];

NSUInteger numItems = [[self dataSource] 
 numberOfItemsInImageBrowser:self];

if(numItems = 0)
{
NSLog(@No items in me); // This gets called, so i'm sure the 
 above code works

NSRect bounds = [self bounds];
bounds.size.width = 200;
bounds.size.height = 200;
bounds.origin.x += 200;
bounds.origin.y += 200;

//[NSGraphicsContext saveGraphicsState];

[[NSColor yellowColor] set]; // Just for testing purposes
NSRectFill(bounds);

//[NSGraphicsContext restoreGraphicsState];
}
 }
 
 Uncommenting the NSGrahicsContext doesn't help either.
 
 Anyone has any ideas or workarounds for this?
 Thanks in advance,
 Florian
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/tgoossens%40mac.com
 
 This email sent to tgooss...@mac.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/florian.soenens%40nss.be
 
 This email sent to florian.soen...@nss.be
 
 
 
 Looking for Web-to-Print Solutions?
 Visit our website :   http://www.vit2print.com
 
 
 This e-mail, and any attachments thereto, is intended only for use by the 
 addressee(s) named herein and may contain legally privileged and/or 
 confidential information and/or information protected by intellectual 
 property rights.
 If you are not the intended recipient, please note that any review, 
 dissemination, disclosure, alteration, printing, copying or transmission of 
 this e-mail and/or any file transmitted with it, is strictly prohibited and 
 may be unlawful.
 If you have received this e-mail by mistake, please immediately notify the 
 sender and permanently delete the original as well as any copy of any e-mail 
 and any printout thereof.
 We may monitor e-mail to and from our network.
 
 NSS nv Tieltstraat 167 8740 Pittem 
 Belgium___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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:

Drawing: The Right place to keep bounds

2009-11-25 Thread Paul Bruneau
I'm really trying to do things correctly with my app but I'm at a  
place where I can't figure out what correct is, and all my best  
examples do it wrong (I think).


I am working on the drawing parts of my app. In my last app I most  
definitely did things Wrong but they work fine and there's just one  
user and it was my first Cocoa app so I didn't beat myself up too much.


It's document-based, non-core-data, and aimed at 10.5.

For reference, I am using Sketch, and Cocoa Design Patterns by Buck  
and Yacktman. I also am referring to my memory of several helpful  
posts to this list by Buck over the past couple years that I have been  
watching for them.


I think I recognize, and I am pretty sure I have read that Sketch does  
things Wrong. I see that the shape objects keep their own bounds (and  
frame?) information. It seems clear to me that this is Wrong. What  
does Sketch do if it ever can have two views of the same objects?


I am also pretty sure that Cocoa Design Patterns does it wrong because  
it admits such:


The model in this example is deliberately kept simple to preserve  
the focus on the Controller
subsystem. In most applications, properties like rectangles and  
colors are user interface concerns that
don’t belong in the Model subsystem. However, in this case,  
MYShapeDraw is a drawing program.


This seems like a common problem that I have had with various Cocoa  
information over the years. Everything is kept simple for the sake of  
the example, and I am left clueless about the correct way to do it (or  
I am too dumb to see it). In the quote above, I have learned that the  
rectangles don't belong in the Model subsystem. OK that's a good  
start! Now, where do they belong?


I have a window controller, which is the file's owner of a nib that  
contains the window. In the window is my custom view. My custom view  
contains the skeletal beginning of a category for the drawing code of  
the model objects that are displayed in it (as explained by Buck,  
around page 257). This part I feel I understand pretty well and it  
works.


But where to put the rectangle and other data that each object needs  
in order to be kept track of (for clicking on, etc) and drawn?


Thank you for any insight!___

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

Please do not post 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: different width in fastenumeration

2009-11-25 Thread Clark S. Cox III

You have the -Wconversion flag on.

Sent from my iPhone

On Nov 24, 2009, at 6:47, Hans van der Meer h.vanderm...@uva.nl wrote:


Doing NSDictionary *objects enumerate over its keys thus:
 for ( id key in [objects allKeys] ) {}

According to the documentation allKeys returns a NSArray and  
NSArray's conform to NSFastEnumeration. However on building this  
code generates the following warning:
 Passing argument 3 of 'countByEnumeratingWithState:objects:count'  
with different width due to prototype. [XCode 3.2.1 64-bit on 10.6.2]


What is happening? Am I doing something wrong here?

Hans van der Meer




___

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

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

This email sent to clarkc...@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: Drawing: The Right place to keep bounds

2009-11-25 Thread David Hirsch
I think you are missing the point of the quote, which is that drawing  
programs are an exception to the typical rule that view data must be  
strictly separated from the model (However, in this case).  When the  
model data is all about visual information (drawing), then you have no  
choice but to violate the rule.


On Nov 25, 2009, at 7:27 AM, Paul Bruneau wrote:

I am also pretty sure that Cocoa Design Patterns does it wrong  
because it admits such:


The model in this example is deliberately kept simple to preserve  
the focus on the Controller
subsystem. In most applications, properties like rectangles and  
colors are user interface concerns that
don’t belong in the Model subsystem. However, in this case,  
MYShapeDraw is a drawing program.


This seems like a common problem that I have had with various Cocoa  
information over the years. Everything is kept simple for the sake  
of the example, and I am left clueless about the correct way to do  
it (or I am too dumb to see it). In the quote above, I have learned  
that the rectangles don't belong in the Model subsystem. OK that's a  
good start! Now, where do they belong?




___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 5:49 AM, Mario Kušnjer wrote:

 How to hide the disclosure triangle in front of the Root object and remove 
 indentation for it, and just that object (and later if there is more Root 
 objects for them too) ?

I think what you're looking for is the delegate method
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item;

—Jens___

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

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

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

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


Re: Drawing: The Right place to keep bounds

2009-11-25 Thread Paul Bruneau
OK, I see what you are saying, and to that I respond, why does every  
example that I have ever found of how to draw objects in a custom view  
happen to be a drawing program? :)


And I'm not sure I buy what you are saying, because, just like I  
mentioned for the Sketch example, what does his program do when the  
user makes a new window with the same view in it and that view has a  
different zoom factor, or is scrolled to a different position?


My question remains: where should I keep this information? Surely  
people draw objects in apps other than drawing programs that are  
limited to a single view.


I do thank you for your response!

On Nov 25, 2009, at 11:00 AM, David Hirsch wrote:

I think you are missing the point of the quote, which is that  
drawing programs are an exception to the typical rule that view data  
must be strictly separated from the model (However, in this  
case).  When the model data is all about visual information  
(drawing), then you have no choice but to violate the rule.


On Nov 25, 2009, at 7:27 AM, Paul Bruneau wrote:

I am also pretty sure that Cocoa Design Patterns does it wrong  
because it admits such:


The model in this example is deliberately kept simple to preserve  
the focus on the Controller
subsystem. In most applications, properties like rectangles and  
colors are user interface concerns that
don’t belong in the Model subsystem. However, in this case,  
MYShapeDraw is a drawing program.


This seems like a common problem that I have had with various Cocoa  
information over the years. Everything is kept simple for the sake  
of the example, and I am left clueless about the correct way to do  
it (or I am too dumb to see it). In the quote above, I have learned  
that the rectangles don't belong in the Model subsystem. OK that's  
a good start! Now, where do they belong?

___

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

Please do not post 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: Drawing: The Right place to keep bounds

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 7:27 AM, Paul Bruneau wrote:

 I think I recognize, and I am pretty sure I have read that Sketch does things 
 Wrong. I see that the shape objects keep their own bounds (and frame?) 
 information. It seems clear to me that this is Wrong. What does Sketch do if 
 it ever can have two views of the same objects?

The bounding box is an intrinsic property of a geometric object, independent of 
how it's viewed.

Unless you're talking about something like a bounding box transformed into view 
coordinates; I'm not familiar with the Sketch code. That would definitely be 
part of the view, not the model. That sort of design is often done by having a 
parallel per-view model that's been transformed for use in the view, and code 
that keeps the per-view model synced with changes to the master. Core Animation 
uses this sort of design.

—Jens___

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

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

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

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


Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620

On Nov 25, 2009 2:06am, Kyle Sluder kyle.slu...@gmail.com wrote:

On Tue, Nov 24, 2009 at 10:14 PM, lorenzo7...@gmail.com wrote:



 This returns a non-nil value:



 NSURL * url = [NSURL URLWithString:@sdsds];






 The docs say this should fail. RFC 1758 looks for the string to begin  
with a



 scheme, eg http:





While sdsds is indeed a valid relative URL according to RFC 2396,



don't let NSURL's declaration of RFC-conformance fool you. I have a



pretty severe bug (rdar://problem/7096953) logged against NSURL's



incorrect handling of IDNs. Despite pointing to the spec, copying it



into the bug report, and walking step by step through NSURL's



violation thereof, I was told that it behaves according to the spec



and as designed. I no longer trust NSURL's assertions of conformance.





--Kyle Sluder



So is there a way to validate a string before passing it to URLWithString?
___

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

Please do not post 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: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 8:31 AM, lorenzo7...@gmail.com wrote:

 So is there a way to validate a string before passing it to URLWithString?

Depends on what you want to do. If you want URLs of a specific scheme, check 
the -scheme property of the resulting NSURL. That will weed out degenerate 
cases like foo.

—Jens___

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

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

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

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


Re: Drawing: The Right place to keep bounds

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 8:23 AM, Paul Bruneau wrote:

 And I'm not sure I buy what you are saying, because, just like I mentioned 
 for the Sketch example, what does his program do when the user makes a new 
 window with the same view in it and that view has a different zoom factor, or 
 is scrolled to a different position?

Again, I'm not familiar with Sketch itself, but presumably the program would 
translate view coordinates into model coordinates before comparing with model 
properties like the bounding box.

—Jens___

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

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

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

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


Re: Drawing: The Right place to keep bounds

2009-11-25 Thread Paul Bruneau

On Nov 25, 2009, at 11:24 AM, Jens Alfke wrote:


On Nov 25, 2009, at 7:27 AM, Paul Bruneau wrote:

I think I recognize, and I am pretty sure I have read that Sketch  
does things Wrong. I see that the shape objects keep their own  
bounds (and frame?) information. It seems clear to me that this is  
Wrong. What does Sketch do if it ever can have two views of the  
same objects?


The bounding box is an intrinsic property of a geometric object,  
independent of how it's viewed.


Unless you're talking about something like a bounding box  
transformed into view coordinates; I'm not familiar with the Sketch  
code. That would definitely be part of the view, not the model. That  
sort of design is often done by having a parallel per-view model  
that's been transformed for use in the view, and code that keeps the  
per-view model synced with changes to the master. Core Animation  
uses this sort of design.


Thank you, I was thinking of the bounding box as dependent on the  
view. For example, I think of a zoom value for a view--that affects  
the bounding box, doesn't it? Or do I use a sort of natural bounding  
box for my objects that is then modified by the view's zoom?


I guess this is what you mean by a bounding box transformed into view  
coordinates. Yes, that is the way I am thinking of it, so that I can  
do things like hit-testing in however many views my user might have  
open. So OK I will start thinking about a parallel per-view model.


Thanks!
___

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

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

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

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


Re: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer


On 2009.11.25, at 17:20, Jens Alfke wrote:



On Nov 25, 2009, at 5:49 AM, Mario Kušnjer wrote:

How to hide the disclosure triangle in front of the Root object and  
remove indentation for it, and just that object (and later if there  
is more Root objects for them too) ?


I think what you're looking for is the delegate method
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item;

—Jens



Actually no, because that delegate method is implemented and it  
doesn't hide disclosure triangle and removes indentation (actually it  
makes indentation slightly different),
but draws font and cell (depending on which highlight style used)  
differently to make them look like header or title (group) for rows  
that come under its tree.


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

Please do not post 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: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620

On Nov 25, 2009 10:36am, Jens Alfke j...@mooseyard.com wrote:



On Nov 25, 2009, at 8:31 AM, lorenzo7...@gmail.com wrote:




 So is there a way to validate a string before passing it to  
URLWithString?




Depends on what you want to do. If you want URLs of a specific scheme,  
check the -scheme property of the resulting NSURL. That will weed out  
degenerate cases like foo.





—Jens
Thanks for the reply. I'm looking through the Cocoa API now. I think I  
might be able to use NSNetService's -resolveWithTimeout along with NSURL's  
-scheme to validate a string. Seems like more work than should be  
necessary, but oh well.

Thanks all.
___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Jean-Daniel Dupas

Le 25 nov. 2009 à 17:49, Mario Kušnjer a écrit :

 
 On 2009.11.25, at 17:20, Jens Alfke wrote:
 
 
 On Nov 25, 2009, at 5:49 AM, Mario Kušnjer wrote:
 
 How to hide the disclosure triangle in front of the Root object and remove 
 indentation for it, and just that object (and later if there is more Root 
 objects for them too) ?
 
 I think what you're looking for is the delegate method
 - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item;
 
 —Jens
 
 
 Actually no, because that delegate method is implemented and it doesn't hide 
 disclosure triangle and removes indentation (actually it makes indentation 
 slightly different),
 but draws font and cell (depending on which highlight style used) differently 
 to make them look like header or title (group) for rows that come under its 
 tree.


NSOutlineView delegate:

outlineView:shouldShowOutlineCellForItem:

Returns a whether the specified item should display the outline cell (the 
disclosure triangle).

And if it's not enough, you can subclass NSOutlineView and override 
-[NSOutlineView frameOfOutlineCellAtRow:] to returns NSZeroRect.


-- Jean-Daniel




___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Dave DeLong
You want this delegate method:

- (BOOL)outlineView:(NSOutlineView *)outlineView 
shouldShowOutlineCellForItem:(id)item;

Cheers,

Dave

On Nov 25, 2009, at 9:49 AM, Mario Kušnjer wrote:

 
 On 2009.11.25, at 17:20, Jens Alfke wrote:
 
 
 On Nov 25, 2009, at 5:49 AM, Mario Kušnjer wrote:
 
 How to hide the disclosure triangle in front of the Root object and remove 
 indentation for it, and just that object (and later if there is more Root 
 objects for them too) ?
 
 I think what you're looking for is the delegate method
 - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item;
 
 —Jens
 
 
 Actually no, because that delegate method is implemented and it doesn't hide 
 disclosure triangle and removes indentation (actually it makes indentation 
 slightly different),
 but draws font and cell (depending on which highlight style used) differently 
 to make them look like header or title (group) for rows that come under its 
 tree.
 
 Mario Kušnjer


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Drawing: The Right place to keep bounds

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 8:40 AM, Paul Bruneau wrote:

 I guess this is what you mean by a bounding box transformed into view 
 coordinates. Yes, that is the way I am thinking of it, so that I can do 
 things like hit-testing in however many views my user might have open. So OK 
 I will start thinking about a parallel per-view model.

You probably don't even need parallel models unless you're doing something 
fancy. More typically you just do all the work you can in model coordinates. 
You transform points to view coords when drawing, and you transform mouse 
positions to model coords when handling events.

—Jens___

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

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

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

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


Re: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 8:59 AM, lorenzo7...@gmail.com wrote:

 Thanks for the reply. I'm looking through the Cocoa API now. I think I might 
 be able to use NSNetService's -resolveWithTimeout along with NSURL's -scheme 
 to validate a string. Seems like more work than should be necessary, but oh 
 well.

Wait, what? That NSNetService method is for getting the IP address of a Bonjour 
service. That doesn't sound like what you're doing. It has nothing to do with 
validating the syntax of a URL.

Maybe you could describe what it is that you're trying to do with these URLs?

—Jens___

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

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

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

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


NSConnection retaining delegate?

2009-11-25 Thread Alexander Spohr
Hi list,

is NSConnection retaining its delegate?
(At least as long as it is collecting data)

I thought contract is that a delegate is never retained?

This behavior requires to _always_ send cancel to the connection before you 
release the delegate. Otherwise the NSConnection might still hold on to the 
delegate which should by now have been purged from memory.

Is this right or am I wrong? Should I file a bug?

atze

___

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

Please do not post 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: GC, variable optimized away wrongly?

2009-11-25 Thread Greg Guerin

Nick Rogers wrote:

	NSTimeInterval etaDouble = interval  * ((totalBlocks -  
blockCount) / blockCount);	// * debugger doesn't list this  
variable, mouse shows a pop up saying variable optimized away by  
compiler

int eta = (int)etaDouble;   // value is 0 here instead of something



What are the types of totalBlocks and blockCount?

Have you confirmed, say by NSLog'ing it, that the value of etaDouble  
has a non-zero integer part?


If you NSLog etaDouble, or use it in any way that affects anything  
outside the 'for' block, it won't be optimized away.


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


Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620

On Nov 25, 2009 11:05am, Jens Alfke j...@mooseyard.com wrote:



On Nov 25, 2009, at 8:59 AM, lorenzo7...@gmail.com wrote:




 Thanks for the reply. I'm looking through the Cocoa API now. I think I  
might be able to use NSNetService's -resolveWithTimeout along with  
NSURL's -scheme to validate a string. Seems like more work than should be  
necessary, but oh well.




Wait, what? That NSNetService method is for getting the IP address of a  
Bonjour service. That doesn't sound like what you're doing. It has  
nothing to do with validating the syntax of a URL.




Maybe you could describe what it is that you're trying to do with these  
URLs?





—Jens


I was just looking through the API to see what methods might help me with  
this and NSNetService looked like it might work, until I read the class  
description. What I'm doing exactly, is downloading batches of web pages  
via http. I don't want to make the attempt if the url is not valid.
___

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

Please do not post 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: Creating a NSEvent with NSEventTypeMagnify

2009-11-25 Thread Raleigh Ledet
Are you trying to this internally inside your app? If so, why?

-raleigh

On Nov 24, 2009, at 11:57 AM, Andreas Hegenberg wrote:

 Hello everybody,
 
 I hope this is the correct mailinglist for my question.
 
 I want to create a NSEvent with the NSEventTypeMagnify and a specific 
 magnification. The NSEventTypeMagnify was introduced in 10.6. Unfortunately I 
 don't really know how to do it. I fiddled with otherEventWithType but can't 
 get it to work properly...
 
 Has anybody done this before?
 
 Best 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/ledet%40apple.com
 
 This email sent to le...@apple.com

___

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

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

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

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


Re: URLWithString fails to fails with bad string

2009-11-25 Thread Dave Carrigan

On Nov 25, 2009, at 9:28 AM, lorenzo7...@gmail.com wrote:

 I was just looking through the API to see what methods might help me with 
 this and NSNetService looked like it might work, until I read the class 
 description. What I'm doing exactly, is downloading batches of web pages via 
 http. I don't want to make the attempt if the url is not valid.

The only way to determine the validity of a well-formed url is to attempt to 
retrieve it. 

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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

Please do not post 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: URLWithString fails to fails with bad string

2009-11-25 Thread Mike Abdullah
You should be able to weed stuff out pretty quickly by:

1) Use +URLWithString: to see if the string can be interpreted as a URL
2) Construct a request with the URL and see what +[NSURLConnection 
canHandleRequest:] has to say
3) Try to load the URL

On 25 Nov 2009, at 17:28, lorenzo7...@gmail.com wrote:

 On Nov 25, 2009 11:05am, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Nov 25, 2009, at 8:59 AM, lorenzo7...@gmail.com wrote:
 
 
 
  Thanks for the reply. I'm looking through the Cocoa API now. I think I 
  might be able to use NSNetService's -resolveWithTimeout along with NSURL's 
  -scheme to validate a string. Seems like more work than should be 
  necessary, but oh well.
 
 
 
 Wait, what? That NSNetService method is for getting the IP address of a 
 Bonjour service. That doesn't sound like what you're doing. It has nothing 
 to do with validating the syntax of a URL.
 
 
 
 Maybe you could describe what it is that you're trying to do with these URLs?
 
 
 
 —Jens
 
 I was just looking through the API to see what methods might help me with 
 this and NSNetService looked like it might work, until I read the class 
 description. What I'm doing exactly, is downloading batches of web pages via 
 http. I don't want to make the attempt if the url is not valid.
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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


Re: Re: URLWithString fails to fails with bad string

2009-11-25 Thread lorenzo7620

On Nov 25, 2009 11:34am, Dave Carrigan d...@rudedog.org wrote:



On Nov 25, 2009, at 9:28 AM, lorenzo7...@gmail.com wrote:




 I was just looking through the API to see what methods might help me  
with this and NSNetService looked like it might work, until I read the  
class description. What I'm doing exactly, is downloading batches of web  
pages via http. I don't want to make the attempt if the url is not valid.




The only way to determine the validity of a well-formed url is to attempt  
to retrieve it.





--



Dave Carrigan



d...@rudedog.org



Seattle, WA, USA





Ah, that's a bummer. But I guess that means I can move on to something else  
now.

Thanks
___

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

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

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

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


SCNetworkconnect

2009-11-25 Thread Stefan Lehrner
Hi,

I run a dashboard for multiple 3G vendors. Normally the connection will be done 
without Username/Password - but some Providers have changed their policy, so I 
have to rebuild my Application and enter Username/Password to it.

This is the Code I am now using - but it will not pass the User/Password Data 
to my Dialing Options - which means, User/Pass will not accepted. When I am 
enterining the Data in my Network Options, everything is working fine. 

May someone can check out, what I am doing wrong?

// Code - without User(Password 

SDictionary *pppOptionsForDialModem = [NSDictionary 
dictionaryWithObjectsAndKeys:
   
[connect modemScript], (NSString*)kSCPropNetModemConnectionScript,
   nil];

NSDictionary *pppOptionsForDialAdress = [NSDictionary 
dictionaryWithObjectsAndKeys:

[connect apn], (NSString*)kSCPropNetPPPCommRemoteAddress,

nil];





NSDictionary *optionsForDial = [NSDictionary 
dictionaryWithObjectsAndKeys:

pppOptionsForDialAdress, (NSString*)kSCEntNetPPP,

pppOptionsForDialModem, (NSString*)kSCEntNetModem,


nil];




BOOL startConnection = 
SCNetworkConnectionStart(connection,(CFDictionaryRef)optionsForDial,false);

//NSLog(@der bool ist: %@, startConnection?@YES:@NO); 

if ( ! startConnection ) {
NSString *errorstring = [NSString 
stringWithCString:SCErrorString(SCError()) encoding:NSUTF8StringEncoding];
[[NSAlert alertWithMessageText:@Fehler beim Verbinden des 
Modems defaultButton:@OK alternateButton:nil otherButton:nil 
informativeTextWithFormat:@%@,errorstring] runModal];
}

// End Code without User/Password


Now with the Adaptions:

// Code with User/Password

SDictionary *pppOptionsForDialModem = [NSDictionary 
dictionaryWithObjectsAndKeys:
   
[connect modemScript], (NSString*)kSCPropNetModemConnectionScript,
   nil];

NSDictionary *pppOptionsForDialAdress = [NSDictionary 
dictionaryWithObjectsAndKeys:

[connect apn], (NSString*)kSCPropNetPPPCommRemoteAddress,

nil];

NSDictionary *pppOptionsForDialUserName  =  [NSDictionary 
dictionaryWithObjectsAndKeys:

[connect username], (NSString*)kSCPropNetPPPAuthName,

nil];

NSDictionary *pppOptionsForDialPassword = [NSDictionary 
dictionaryWithObjectsAndKeys:

[connect userPassword], (NSString*)kSCPropNetPPPAuthPassword,

   nil];



NSDictionary *optionsForDial = [NSDictionary 
dictionaryWithObjectsAndKeys:

pppOptionsForDialAdress, (NSString*)kSCEntNetPPP,

pppOptionsForDialModem, (NSString*)kSCEntNetModem,

pppOptionsForDialUserName, (NSString*)kSCPropNetPPPAuthName,

pppOptionsForDialPassword, (NSString*)kSCPropNetPPPAuthPassword,

nil];




BOOL startConnection = 
SCNetworkConnectionStart(connection,(CFDictionaryRef)optionsForDial,false);

//NSLog(@der bool ist: %@, startConnection?@YES:@NO); 

if ( ! startConnection ) {
NSString *errorstring = [NSString 
stringWithCString:SCErrorString(SCError()) encoding:NSUTF8StringEncoding];
[[NSAlert alertWithMessageText:@Fehler beim Verbinden des 
Modems defaultButton:@OK alternateButton:nil otherButton:nil 
informativeTextWithFormat:@%@,errorstring] 

Re: URLWithString fails to fails with bad string

2009-11-25 Thread Jens Alfke


On Nov 25, 2009, at 9:34 AM, Dave Carrigan wrote:

The only way to determine the validity of a well-formed url is to  
attempt to retrieve it.


The two of you are using different terminology. He's asking how to  
tell if a URL is well-formed.


Lorenzo: If you want to know if you can retrieve a URL by HTTP, then  
simply check whether it's an HTTP URL, by getting its -scheme property  
and doing a case-insensitive compare with 'http' or 'https'.


What I'm doing exactly, is downloading batches of web pages via  
http. I don't want to make the attempt if the url is not valid.


You definitely don't want to try to retrieve every URL then, or your  
app is letting an arbitrary untrusted web page let it open any  
imaginable URL. I can't immediately think of a serious exploit using  
this, but the results of opening arbitrary 'file:' URLs can be  
unexpected. For instance, trying to fetch file:///dev/random will  
lock up your app and possibly bring the computer to a crawl as it  
fills your address space with random bytes :)


—Jens___

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

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

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

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


Re: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer

Question for Jean-Daniel and Dave

Is that delegate method in Snow Leopard ?
Because I don't see it in Leopard !

- (BOOL)outlineView:(NSOutlineView *)outlineView  
shouldShowOutlineCellForItem:(id)item;



Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Matthew Lindfield Seager
On Thursday, November 26, 2009, Mario Kušnjer mario.kusn...@sb.t-com.hr wrote:
 Is that delegate method in Snow Leopard ?
 Because I don't see it in Leopard !

 - (BOOL)outlineView:(NSOutlineView *)outlineView 
 shouldShowOutlineCellForItem:(id)item;

I wanted to do something similar recently on Leopard. I ended up with
a one method sub-class  everything else went in the delegate.
Occassionally I had some strange indenting behavior on selection
change (the whole view scrolled right slightly) but I never got
around to isolating the cause of it.

Matt
___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer

Disregard that last question.
I have just checked online documentation on Apple Dev site.
It's Snow Leopard feature, not available in Leopard.

So, I should subclass NSOutlineView to solve my problem (on Leopard) ?

Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

Please do not post 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: NSConnection retaining delegate?

2009-11-25 Thread Andy Lee
On Wednesday, November 25, 2009, at 12:15PM, Alexander Spohr 
a...@freeport.de wrote:
is NSConnection retaining its delegate?
(At least as long as it is collecting data)

FWIW I've never used NSConnection, but in the following quick and dirty code it 
did not retain the delegate I gave it.

TestDelegate * aTestDelegate = [[[TestDelegate alloc] init] 
autorelease];
NSConnection * aConn = [[NSConnection alloc] initWithReceivePort:nil 
sendPort:nil];
[aConn setDelegate:aTestDelegate];

The TestDelegate object got dealloced despite being the NSConnection's delegate.


I thought contract is that a delegate is never retained?

I think there is at least one class that breaks the rule about not retaining 
delegates (and is documented accordingly).  I forget which it is and I don't 
have time to search for it, but it doesn't seem to be NSConnection.

--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: NSURLConnection retaining delegate?

2009-11-25 Thread Alexander Spohr
Shame on me!
I meant NSURLConnection.
Andy, sorry that I bothered you with the wrong test.
This is one example where copy-paste is better than fresh typing...

So the (corrected) question still stands:
is NSURLConnection retaining its delegate?

atze



Am 25.11.2009 um 21:19 schrieb Andy Lee:

 On Wednesday, November 25, 2009, at 12:15PM, Alexander Spohr 
 a...@freeport.de wrote:
 is NSConnection retaining its delegate?
 (At least as long as it is collecting data)
 
 FWIW I've never used NSConnection, but in the following quick and dirty code 
 it did not retain the delegate I gave it.
 
   TestDelegate * aTestDelegate = [[[TestDelegate alloc] init] 
 autorelease];
   NSConnection * aConn = [[NSConnection alloc] initWithReceivePort:nil 
 sendPort:nil];
   [aConn setDelegate:aTestDelegate];
 
 The TestDelegate object got dealloced despite being the NSConnection's 
 delegate.
 
 
 I thought contract is that a delegate is never retained?
 
 I think there is at least one class that breaks the rule about not retaining 
 delegates (and is documented accordingly).  I forget which it is and I don't 
 have time to search for it, but it doesn't seem to be NSConnection.
 
 --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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Jim Puls
Yes, the documentation for that (Snow Leopard) delegate method tells you where 
to go: subclass NSOutlineView, implement the (Leopard) method 
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row
and return NSZeroRect for the appropriate row(s).

- jp

On Nov 25, 2009, at 11:38 AM, Mario Kušnjer wrote:

 Disregard that last question.
 I have just checked online documentation on Apple Dev site.
 It's Snow Leopard feature, not available in Leopard.
 
 So, I should subclass NSOutlineView to solve my problem (on Leopard) ?
 
 Mario Kušnjer
 mario.kusn...@sb.t-com.hr
 +385957051982
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/jim%40nondifferentiable.com
 
 This email sent to j...@nondifferentiable.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


layout subviews

2009-11-25 Thread Torsten Curdt
I have a flipped custom view (within a scroll view) which layouts it's
subviews as follows:

WORKS:

  - (void) layoutSubviews
  {
  NSLog(@layout);

  NSRect frame = [self frame];
  CGFloat width = frame.size.width;
  CGFloat height = 0;
  for(NSView *itemView in itemViews) {
  height += [itemView frame].size.height;
  }

  NSLog(@view height: %1.0f, height);

  if (frame.size.height != height) {
  frame.size.height = height;
  [self setFrame:frame];
  NSLog(@ - view: %@, NSStringFromRect(frame));
  }

  CGFloat y = 0;
  for(NSView *itemView in itemViews) {
  NSRect itemFrame = [itemView frame];
  itemFrame.origin.y = y;
  itemFrame.size.width = width;
  [itemView setFrame:itemFrame];
  NSLog(@ - item: %@, NSStringFromRect(itemFrame));
  y += itemFrame.size.height;
  }

  [self setNeedsDisplayInRect:frame];
  }

The above works just fine. What I don't understand is why moving the
adjustment of the frame size *after* the subview layout is breaking
it. By breaking I mean that some subviews are disappearing. It does
not seem to be a redraw/needsDisplay problem though. Rather like they
end up somewhere off screen.


DOESN'T WORK:

  - (void) layoutSubviews
  {
  NSLog(@layout);

  NSRect frame = [self frame];
  CGFloat width = frame.size.width;
  CGFloat height = 0;
  for(NSView *itemView in itemViews) {
  height += [itemView frame].size.height;
  }

  CGFloat y = 0;
  for(NSView *itemView in itemViews) {
  NSRect itemFrame = [itemView frame];
  itemFrame.origin.y = y;
  itemFrame.size.width = width;
  [itemView setFrame:itemFrame];
  NSLog(@ - item: %@, NSStringFromRect(itemFrame));
  y += itemFrame.size.height;
  }

  NSLog(@view height: %1.0f, height);

  if (frame.size.height != height) {
  frame.size.height = height;
  [self setFrame:frame];
  NSLog(@ - view: %@, NSStringFromRect(frame));
  }

  [self setNeedsDisplayInRect:frame];
  }

Anyone spotting a problem that I am missing?

cheers
--
Torsten
___

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

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


table view header cell bottom border

2009-11-25 Thread Shane
I read in a file, parse the contents, and then I create NSTableColumns
based on the contents of the file … and then I just
addTableColumn:newColumn to the NSTableView. I've attached a small
image of the problem I'm seeing where my border doesn't completely run
across the bottom of each of my headers cells, rather, it only works
on the first column.

Here's how I create my headers and columns ...

tableHeaderCell = [[MyHeaderCell alloc] 
initTextCell:columnName];
[tableHeaderCell setPullsDown:NO];
[tableHeaderCell setControlSize:NSMiniControlSize];
[tableHeaderCell setBordered:NO];
[tableHeaderCell setFont:[NSFont labelFontOfSize:
[NSFont smallSystemFontSize]]];

if (i == 0) {
[tableHeaderCell setEditable:NO];

column = [[DataTableColumn alloc]
  initWithIdentifier:[NSNumber numberWithInt:i]];   
}
else {
[tableHeaderCell setEditable:YES];  
[tableHeaderCell addItemWithTitle:@item1];
[tableHeaderCell addItemWithTitle:@item2];
[tableHeaderCell addItemWithTitle:@item3];

column = [[NSTableColumn alloc]
initWithIdentifier:[NSNumber numberWithInt:i]];
}

[column setHeaderCell:tableHeaderCell];

[myTableView addTableColumn:column];

I've subclass MyHeaderCell from NSPopUpButtonCell and I draw the
borders within drawInteriorWithFrame as follows …

- (void) drawInteriorWithFrame:(NSRect) cellFrame inView:(NSView *) controlView
{
[[NSColor whiteColor] set];
[[NSBezierPath bezierPathWithRect:cellFrame] fill]; 

NSBezierPath *path = [NSBezierPath bezierPath];

[path moveToPoint:NSMakePoint(cellFrame.origin.x, 
cellFrame.size.height)];
[path lineToPoint:NSMakePoint(cellFrame.size.width, 
cellFrame.size.height)];

[[NSColor darkGrayColor] setStroke];
[path stroke];

[super drawInteriorWithFrame:cellFrame inView:controlView];

return;
}

Anyone see any reason why my header cells would not all be underlined?
attachment: columns-prob.tiff___

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

Please do not post 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: NSURLConnection retaining delegate?

2009-11-25 Thread Jerry Krinock

On 2009 Nov 25, at 12:53, Alexander Spohr wrote:

 I meant NSURLConnection.

If it is indeed not documented whether or not NSURLConnection retains its 
delegate, I believe you can design for either case.  

* When a NSURLConnection completes, you may release it or allow it to be 
autoreleased.
* If you wish to terminate a NSURLConnection before it completes, you should 
send it a -cancel first.
* Normally the delegate is receiving and storing headers, data and errors for 
you.  You should retain the delegate as long as you are interested in the 
headers, data or errors being stored.  Once you have extracted or wish to 
abandon this information, release the delegate or allow it to be autoreleased.

The idea is that you mind your own references, and NSURLConnection will mind 
its own references.


___

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

Please do not post 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: EXC_BAD_ACCESS when calling NSOpenPanel

2009-11-25 Thread Ken Thomases
On Nov 23, 2009, at 6:51 PM, Darren Wheatley wrote:

 I have the following code as the action from a button click:
 
 - (IBAction)chooseFile:(id)sender;
 {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];

You haven't retained this panel.  If you want this object to live beyond the 
current autorelease context, you need to retain it.  (Note that not retaining 
doesn't guarantee that it _will_ be released at the end of the autorelease 
context, just that it might.)

[openPanel setCanChooseDirectories:NO];
[openPanel setCanCreateDirectories:NO];
[openPanel beginSheetForDirectory:nil
 file:nil
types:[NSArray arrayWithObject:@txt]
   modalForWindow:window
modalDelegate:self
   
 didEndSelector:@selector(fileOpenDidEnd:returnCode:context:)
  contextInfo:nil];
 }
 
 - (void)fileOpenDidEnd:(NSOpenPanel*)openPanel
returnCode:(NSInteger)code
   context:(void*)context
 {
if (code == NSCancelButton) return;
[self setFilePath:[openPanel filename]];
[filePathField setStringValue:[openPanel filename]];
 }

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


UIImageView Animation Question

2009-11-25 Thread Philip Vallone
Hi,

I have a UIImageView that overlays a MPMoviePLayerController. When the movie 
plays, the view is in landscape. I want to have my overlay image to drop from 
the top of the movie and move down. The below code rotates the image. How do I 
get this effect?


- (void)showOverlay:(NSTimer *)timer {

NSArray *windows = [[UIApplication sharedApplication] windows];

UIImage *image = [UIImage imageNamed:@top.png];   
UIImageView *imageView = [ [ UIImageView alloc ]  
initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ];
imageView.image = image;
imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0);



CGFloat moveDistance = -50.0;
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:@moveImageDown context:context];
[UIView setAnimationDuration:1.0];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 
moveDistance);
[imageView setCenter:CGPointMake(295, 480 / 2  )];
imageView.transform = transform;
[UIView commitAnimations];  



mpw = [windows objectAtIndex:1];
[mpw addSubview:imageView];

}

Thanks

Phil


___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer

Hi !

So I have sub classed NSOutlineView and implemented single method like  
this:


- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row {
return row == 0 ? NSZeroRect : [super frameOfOutlineCellAtRow:row];
}

That works except the indentation problem is still on.
If root object is empty than it is indented (default in IB is 14), but  
when I add child object to it,

root object indentation gets reset to zero (0).
How do I fix that ?

Bye.

Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

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


NSOutlineView - how to have a default item selected

2009-11-25 Thread Boyd Collier
Mario Kušnjer's question reminded me of a question that I've been  
pondering about NSOutlineViews, namely, is there a way to have one  
item on the outline initialized in the selected state when the outline  
is first created?  That is, when the window containing the outline is  
first displayed to the user, what I would like is for the first item  
in my outline to already show as selected.  Seems like there should be  
a simple way of doing this, but if so, I've not yet discovered it.  I  
have a small test project based on code that Itai Ferber was kind  
enough to send me, and I would be more than happy to make it available  
to anyone who would be interested in looking at it.


Boyd___

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

Please do not post 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: UIImageView Animation Question

2009-11-25 Thread Philip Vallone
Never mind,

I figured it out.

Regards,

UIImage *image = [UIImage imageNamed:@top.png];   
UIImageView *imageView = [ [ UIImageView alloc ]  
initWithFrame:CGRectMake(295, 480/2, image.size.width, image.size.height) ];
imageView.image = image;
imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0);



CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:@moveImageDown context:context];
[UIView setAnimationDuration:1.0];
[imageView setCenter:CGPointMake(295, 480 / 2  )];
[UIView commitAnimations];



On Nov 25, 2009, at 6:36 PM, Philip Vallone wrote:

 Hi,
 
 I have a UIImageView that overlays a MPMoviePLayerController. When the movie 
 plays, the view is in landscape. I want to have my overlay image to drop from 
 the top of the movie and move down. The below code rotates the image. How do 
 I get this effect?
 
 
 - (void)showOverlay:(NSTimer *)timer {
   
   NSArray *windows = [[UIApplication sharedApplication] windows];
   
   UIImage *image = [UIImage imageNamed:@top.png];   
   UIImageView *imageView = [ [ UIImageView alloc ]  
 initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ];
   imageView.image = image;
   imageView.transform = CGAffineTransformMakeRotation(M_PI/2.0);
   
   
   
   CGFloat moveDistance = -50.0;
   CGContextRef context = UIGraphicsGetCurrentContext();
   [UIView beginAnimations:@moveImageDown context:context];
   [UIView setAnimationDuration:1.0];
   CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 
 moveDistance);
   [imageView setCenter:CGPointMake(295, 480 / 2  )];
   imageView.transform = transform;
   [UIView commitAnimations];  
   
   
   
   mpw = [windows objectAtIndex:1];
   [mpw addSubview:imageView];
   
 }
 
 Thanks
 
 Phil
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/philip.vallone%40verizon.net
 
 This email sent to philip.vall...@verizon.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


Re: NSOutlineView - how to have a default item selected

2009-11-25 Thread Dave DeLong
How about this?

NSInteger index = [myOutlineView rowForItem:itemToSelect];
NSIndexSet * indexSet = [NSIndexSet indexSetWithIndex:index];
[myOutlineView selectRowIndexes:indexSet byExtendingSelection:NO];

HTH,

Dave

On Nov 25, 2009, at 4:48 PM, Boyd Collier wrote:

 Mario Kušnjer's question reminded me of a question that I've been pondering 
 about NSOutlineViews, namely, is there a way to have one item on the outline 
 initialized in the selected state when the outline is first created?  That 
 is, when the window containing the outline is first displayed to the user, 
 what I would like is for the first item in my outline to already show as 
 selected.  Seems like there should be a simple way of doing this, but if so, 
 I've not yet discovered it.  I have a small test project based on code that 
 Itai Ferber was kind enough to send me, and I would be more than happy to 
 make it available to anyone who would be interested in looking at it.
 
 Boyd


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Drawing: The Right place to keep bounds

2009-11-25 Thread Graham Cox

On 26/11/2009, at 3:40 AM, Paul Bruneau wrote:

 Thank you, I was thinking of the bounding box as dependent on the view. For 
 example, I think of a zoom value for a view--that affects the bounding box, 
 doesn't it? Or do I use a sort of natural bounding box for my objects that 
 is then modified by the view's zoom?
 
 I guess this is what you mean by a bounding box transformed into view 
 coordinates. Yes, that is the way I am thinking of it, so that I can do 
 things like hit-testing in however many views my user might have open. So OK 
 I will start thinking about a parallel per-view model.


I can't comment too much on Sketch, but I can on DrawKit, which uses a similar 
architecture, but also supports multiple (parallel) views of the same model 
(drawing).

Things like zoom and scroll position are properties of the view, not the model. 
Each graphic object has a bounding rectangle which occupies some particular 
part of the drawing's coordinate space. That bounding rectangle never changes 
as long as the size and position (and angle, in my case) of the object remains 
the same - zooming and scrolling do not affect this. When a view wants to show 
some part of the model, it asks each object to draw itself, but does so having 
established the graphics transform for the view (which is affected by zoom and 
scroll, but is an intrinsic property of NSView, so there isn't much work to 
do). This transform maps the view's dirty rectangles to the coordinate system 
of the underlying drawing model, so that any graphic object can directly 
compare its own bounds against the view's dirty rects with -needsToDrawRect: 
and so go ahead or not.

If there are different views of the same drawing, the drawing itself is unaware 
of it - it just gets called as many times as necessary to draw as many views as 
there are, but a different view transform will be set for each one.

When an object in the model is moved so that its bounding rect changes, the 
relevant parts of all views must be marked dirty to ensure that the views 
redraw the object to show the change. Again, this is done in a way that keeps 
the model unaware of the view(s). The bounds change is signalled to the view 
controllers which in turn mark the bounds dirty using -setNeedsDisplayInRect: 
The appropriate view transform for the view ensures that the right part of the 
view is so marked, which again is automatically handled by NSView.

The scroll position of the view transform is set automatically when using 
NScrollView, and the zoom aspect of it is set by using -setUnitSquareToSize:

Since the code for making the view zoomable has nothing to do with what is 
actually drawn, it's entirely reusable: http://apptree.net/gczoomview.htm which 
just gives you some simple high-level zooming actions built on 
-scaleUnitSquareToSize:

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


Core Data and +[NSExpression expressionForFunction:...]

2009-11-25 Thread Ron Aldrich
Hello All,

I'm trying to query a Core Data database which contains geoLocation information 
for all of the objects of type Photo which are within a specified distance of 
a target point, using the following code.

- (NSArray*) photosNearLatitude: (NSNumber*) inLatitude
  longitude: (NSNumber*) inLongitude
{
  NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression 
expressionForEvaluatedObject]
selectorName: 
@distanceFromLatitude:longitude:
   arguments: [NSArray 
arrayWithObjects:
   [NSExpression 
expressionForConstantValue: inLatitude],
   [NSExpression 
expressionForConstantValue: inLongitude],
   nil]];

  NSExpression* theRHS = [NSExpression expressionForConstantValue: [NSNumber 
numberWithDouble: 0.1]];
  
  NSPredicate* thePredicate = [NSComparisonPredicate 
predicateWithLeftExpression: theLHS
 
rightExpression: theRHS

modifier: NSDirectPredicateModifier

type: NSLessThanOrEqualToPredicateOperatorType
 
options: 0];

  NSManagedObjectContext* theManagedObjectContext = [self managedObjectContext];

  NSFetchRequest* theFetch = [[[NSFetchRequest alloc] init] autorelease];
  theFetch.entity = [NSEntityDescription entityForName: @Photo
inManagedObjectContext: 
theManagedObjectContext];
  theFetch.predicate = thePredicate;
  
  NSError* theError = NULL;
  NSArray* theResults = [theManagedObjectContext executeFetchRequest: theFetch
   error: 
theError];
  
  return theResults;
}

The Photo class has the following selector.

- (NSNumber*) distanceFromLatitude: (NSNumber*) inLatitude
 longitude: (NSNumber*) inLongitude

My problem is that when I call executeFetchRequest, an exception occurs:

2009-11-25 16:55:20.633 Serendipity[8498:a0f] Unsupported function expression 
FUNCTION(SELF, distanceFromLatitude:longitude: , 47.712834, -122.225)

-[Photo distanceFromLatitude:longitude:] is never called.

Can anyone suggest what might be going wrong?

- Ron Aldrich

___

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

Please do not post 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: EXC_BAD_ACCESS when calling NSOpenPanel

2009-11-25 Thread Jens Alfke

On Nov 25, 2009, at 3:25 PM, Ken Thomases wrote:

 You haven't retained this panel.  If you want this object to live beyond the 
 current autorelease context, you need to retain it. (Note that not retaining 
 doesn't guarantee that it _will_ be released at the end of the autorelease 
 context, just that it might.)

It's a window, so it'll be retained by AppKit as long as it's open. I've never 
seen any code using open/save panels that bothers to retain the objects.

—Jens___

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

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

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

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


Looking for PCI card with IR transmitter ports and OS X drivers

2009-11-25 Thread Brad Gibbs
Hi,

I couldn't find a dedicated hardware list, so, I thought I'd post this here.

I've Googled this several times over the past year or so, but can't find 
anything relevant.  I'm looking for a PCI card or even a USB or firewire device 
with 3.5mm ports for IR transmitters (or bugs or eyes) and OS X drivers.  Not 
an IR blaster, like iRed, but a programmable card with 3-6 or more ports for IR 
bugs.  There are several PCI cards with serial (RS-232) ports and I've got to 
believe someone makes an IR card with OS X drivers, but I can't find it.

If anyone has any information on this, I'd really appreciate it.

Thanks.

Brad
___

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

Please do not post 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: NSOutlineView - How to hide disclosure triangle for root nodes ?

2009-11-25 Thread Mario Kušnjer

Here's me again !

So I have found a different solution for my problem and it does not  
include subclassing NSOutlineView,

but trough the use of two delegate method.
This is my implementation:

- (NSCell *)outlineView:(NSOutlineView *)outlineView  
dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
	[outlineView rowForItem:item] == 0 ? [outlineView  
setIndentationPerLevel:0.0] : [outlineView setIndentationPerLevel:14.0];
	return nil == tableColumn ? nil : [tableColumn dataCellForRow: 
[outlineView rowForItem:item]];

}

- (void)outlineView:(NSOutlineView *)outlineView  
willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn  
*)tableColumn item:(id)item {
	[outlineView rowForItem:item] == 0 ? [cell setTransparent:YES] :  
[cell setTransparent:NO];

}

To explain:
In both methods I ask if row in question is the root. If it is, than  
set no indentation and hide triangle,

otherwise set some indentation and show the triangle.

I believe that this is better solution than subclassing.
Still I have some issues to resolve. Work in progress.

Thanks everyone for their suggestions. If anyone is interested in  
reviewing my code,

the project is in zip archive at http://www.box.net/crowebster-public.
Bye.

Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982



___

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

Please do not post 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 same DeviceID for input and output for Playback

2009-11-25 Thread Symadept
Hi,

I am trying use CAPlayThru (
http://developer.apple.com/mac/library/samplecode/CAPlayThrough/) example
code of Apple, to get playthru happening from my Mic to Speakers. It works
well for the device with different DeviceId for Input and Output. If the
deviceId is same, then it gives me a problem.

Can anybody help me how to handle this issue.

Regards
Mustafa
___

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

Please do not post 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: NSURLConnection retaining delegate?

2009-11-25 Thread Alexander Spohr

Am 25.11.2009 um 23:25 schrieb Jerry Krinock:

 
 On 2009 Nov 25, at 12:53, Alexander Spohr wrote:
 
 I meant NSURLConnection.
 
 * Normally the delegate is receiving and storing headers, data and errors for 
 you.  You should retain the delegate as long as you are interested in the 
 headers, data or errors being stored.  Once you have extracted or wish to 
 abandon this information, release the delegate or allow it to be autoreleased.

This is the problem. Releasing is not enough in this case.

I have this layout:

Ownership:
Controller - Loader - NSURLConnection

Delegation:
NSURLConnection - Loader - Controller

 The idea is that you mind your own references, and NSURLConnection will mind 
 its own references.

Controller's dealloc would just release Loader.
Loaders dealloc would just call cancel and release NSURLConnection.
Controller does not set Loader's delegate to nil because it will get recycled 
anyway because Controller and no one else owns it.
-BUT-
NSURLConnection still holds on to Loader and sends it connectionDidFinish. This 
in turn makes Loader tell its own delegate that the loading is complete. 
Because Loader does not retain its delegate (avoiding retain-cycles) everything 
blows up.

Or is the contract to always [anyObject setDelegate:nil] before you release the 
related objects? That would be news for me.

atze

___

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

Please do not post 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: Core Data and +[NSExpression expressionForFunction:...]

2009-11-25 Thread Alexander Spohr
Ron,

I am not sure if that works at all. I never fetched using methods that are not 
part of the database as a qualifier. Your code has to be very slow because it 
would need to fetch all Photos and then call distanceFromLatitude:longitude: on 
each.

Why not qualify directly using a bounding rect?
latitude  inLatitude - 0.1  latitude  inLatitude + 0.1 
longitude  inLongitude - 0.1  longitude  inLongitude + 0.1
The database can figure that out very fast.

atze



Am 26.11.2009 um 02:08 schrieb Ron Aldrich:

 Hello All,
 
 I'm trying to query a Core Data database which contains geoLocation 
 information for all of the objects of type Photo which are within a 
 specified distance of a target point, using the following code.
 
 - (NSArray*) photosNearLatitude: (NSNumber*) inLatitude
  longitude: (NSNumber*) inLongitude
 {
  NSExpression *theLHS = [NSExpression expressionForFunction: [NSExpression 
 expressionForEvaluatedObject]
selectorName: 
 @distanceFromLatitude:longitude:
   arguments: [NSArray 
 arrayWithObjects:
   [NSExpression 
 expressionForConstantValue: inLatitude],
   [NSExpression 
 expressionForConstantValue: inLongitude],
   nil]];
 
  NSExpression* theRHS = [NSExpression expressionForConstantValue: [NSNumber 
 numberWithDouble: 0.1]];
 
  NSPredicate* thePredicate = [NSComparisonPredicate 
 predicateWithLeftExpression: theLHS
 
 rightExpression: theRHS

 modifier: NSDirectPredicateModifier

 type: NSLessThanOrEqualToPredicateOperatorType
 
 options: 0];
 
  NSManagedObjectContext* theManagedObjectContext = [self 
 managedObjectContext];
 
  NSFetchRequest* theFetch = [[[NSFetchRequest alloc] init] autorelease];
  theFetch.entity = [NSEntityDescription entityForName: @Photo
inManagedObjectContext: 
 theManagedObjectContext];
  theFetch.predicate = thePredicate;
 
  NSError* theError = NULL;
  NSArray* theResults = [theManagedObjectContext executeFetchRequest: theFetch
   error: 
 theError];
 
  return theResults;
 }
 
 The Photo class has the following selector.
 
 - (NSNumber*) distanceFromLatitude: (NSNumber*) inLatitude
 longitude: (NSNumber*) inLongitude
 
 My problem is that when I call executeFetchRequest, an exception occurs:
 
 2009-11-25 16:55:20.633 Serendipity[8498:a0f] Unsupported function expression 
 FUNCTION(SELF, distanceFromLatitude:longitude: , 47.712834, 
 -122.225)
 
 -[Photo distanceFromLatitude:longitude:] is never called.
 
 Can anyone suggest what might be going wrong?
 
 - Ron Aldrich
 

___

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

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