Re: UNIX signals

2008-12-18 Thread Jean-Daniel Dupas


Le 18 déc. 08 à 04:55, Michael Ash a écrit :

On Wed, Dec 17, 2008 at 2:32 PM, Greg Parker   
wrote:

On Dec 16, 2008, at 7:22 PM, Michael Ash wrote:


On Tue, Dec 16, 2008 at 8:02 PM, Chris Idou   
wrote:


Is there any Cocoa and/or Carbon interface to UNIX signals?


Nope. It's pretty easy to set up a signal handler that can call back
to a Cocoa/CoreFoundation runloop though, by having it write to a  
pipe

or mach port which the runloop monitors.


Be warned that, to a close approximation, your code isn't allowed  
to do

anything inside the signal handler itself. This includes sending any
Objective-C messages to any object. (objc_msgSend may take locks.  
If the
signal is interrupting a thread that already holds those locks,  
you're

stuck.)

The official list of functions you can call is in the sigaction man  
page.
Some Mach functions are also safe, but I don't know of an official  
list of

which ones.


Yep, that's a very good point. To use my suggestion, your signal
handler must do *nothing* but write to the pipe or mach port, and it
must ensure that the write is guaranteed non-blocking. This isn't too
hard, but it must be adhered to rigidly.

Mike


Although, as mention by Greg Parker, I didn't find doc that guarantee  
that using mach_msg() is safe in a signal. (but Apple is using it in  
securityd, so I'm not worry about it).



___

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

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

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

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


Re: Validation of a Custom View NSToolbarItem

2008-12-18 Thread Ashley Clark

On Dec 17, 2008, at 8:20 AM, Carmen Cerino Jr. wrote:


I understand I need to have a NSToolbarItem subclass and override its
validate method, but who is responsible for calling it? Will NSToolbar
call it during its validation routine or do I need to come up with my
own validation routine?


NSToolbar will call validate on the item during its normal validation  
routine like it does on all other toolbar items where you haven't  
disable automatic validation. If you have disabled automatic  
validation with setAutovalidates:NO, because your validation routine  
is expensive, then you'll have to manually call validate on your  
toolbar items whenever it's appropriate.



Ashley
___

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

Please do not post 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: Validation of a Custom View NSToolbarItem

2008-12-18 Thread Keith Blount
> I understand I need to have a NSToolbarItem subclass and override its
> validate method, but who is responsible for calling it? Will NSToolbar
> call it during its validation routine or do I need to come up with my
> own validation routine?

As Ashley says, NSToolbar will call validate on the toolbar item as it does 
with other items, which you can control via the NSToolbar delegate method 
-validateToolbarItem: or using the NSUserInterfaceValidations protocol's 
-validateUserInterfaceItem: method. However, the problem in the case of an 
NSToolbarItem that contains a view is that -validate will do nothing, as you 
note and as explained in the toolbar programming guide:

---
View item validation
Validation for view items is not automatic because a view item can be of 
unknown complexity. To implement validation for a view item, you must subclass 
NSToolbarItem and override validate (because NSToolbarItem’s implementation of 
validate does nothing for view items). In your override method, do the 
validation specific to the behavior of the view item and then enable or disable 
whatever you want in the contents of the view accordingly. If the view is an 
NSControl you can call setEnabled:, which will in turn call setEnabled: on the 
control.
---

This means that although you are not responsible for calling -validate, when it 
gets called automatically it will do nothing for view items. So in order for 
validation for work, when you subclass the -validate method, you can call on 
the delegate or user interface validation methods yourself, just as the 
superclass's method would for non-view items, to validate automatically.

Here is the -validate method in my own NSToolbarItem subclass:

- (void)validate
{
if ([[self toolbar] delegate])
{
BOOL enabled = YES;

if ([[[self toolbar] delegate] 
respondsToSelector:@selector(validateToolbarItem:)])
enabled = [[[self toolbar] delegate] 
validateToolbarItem:self];

else if ([[[self toolbar] delegate] 
respondsToSelector:@selector(validateUserInterfaceItem:)])
enabled = [[[self toolbar] delegate] 
validateUserInterfaceItem:self];

[self setEnabled:enabled];
}

else if ([self action])
{
if (![self target])
[self setEnabled:self view] window] firstResponder] 
respondsToSelector:[self action]]];

else
[self setEnabled:[[self target] 
respondsToSelector:[self action]]];
}

else
[super validate];
}

This allows you to control the validation of toolbar items with views in them 
the same as you would for standard image toolbar items. (Note that [self 
action] actually calls the control's -action, as the subclass passes things 
through to the control it holds.)

Looking at this code - I haven't reviewed it for a while - it's far from 
perfect. Really it should try to emulate going through the responder chain to 
look for -validateUserInterfaceItem: rather than just looking for that method 
in the delegate. However, for most apps (certainly for mine) where you have a 
window controller or NSDocument subclass as the delegate of your toolbar and 
validating most of your actions, it works fine. The rest of this very simple 
NSToolbarItem subclass for handling views can be downloaded from my site here: 
http://www.literatureandlatte.com/freestuff/ - it's called KBViewToolbarItem, 
surprisingly enough.

Hope that helps.
All the best,
Keith




___

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

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

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

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


NSURL creation problem with colon: a partial workaround

2008-12-18 Thread Jérome Laurens

Hi list,

I have a relative path with colons "file:test", and I would like to  
create a NSURL relative to a given base URL "file://localhost/root/".

This does not work as expected.

Consider the simple URL creation method

NSURL * url1 = [NSURL fileURLWithPath:@"/root/file:test"];

The url is properly created and its absoluteURL reads

file://localhost/root/file:test/

If I use a base URL things go wrong

NSURL * url2 = [NSURL fileURLWithPath:@"/root/"];
NSURL * url3 = [NSURL URLWithString:@"file:test" relativeToURL:url2];

The absolute URL of url3 reads

file:test

which is not the expected value.
Apparently NSURL parses the string as if there were no base URL at all,
which produces a wrong value.
Fortunately, there is a warkaround by prepending "./" to the relative  
path.


NSURL * url4 = [NSURL URLWithString:@"./file:test" relativeToURL:url2];

The absolute URL of url4 reads

file://localhost/root/file:test

what is the expected value.

But the standardizedURL still reads the wrong value

file:test

So prepending "./" to the relative path is just a partial workaround.

Regards
___

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

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


NSToolbar Error

2008-12-18 Thread Carmen Cerino Jr.
Can anyone explain where I should be looking for the cause of this
issue? I pulled my toolbar code from another project that is working
completely fine.

2008-12-18 09:19:02.485 MyProject [36461:10b] *** Assertion failure in
-[NSToolbar _forceMoveItemFromIndex:toIndex:],
/SourceCache/AppKit/AppKit-949.35/Toolbar.subproj/NSToolbar.m:1205
2008-12-18 09:19:02.485 MyProject [36461:10b] Invalid parameter not
satisfying: frIndex>=0 && frIndex<[self _numberOfItems]

-- 
Carmen C. Cerino
   University of Akron ACM Chapter President
   University of Akron Aux. Services Student Assistant
   Cell: 440.263.5057
   AIM: UAcodeweaver
   [ I <3 MACs ]
___

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

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

2008-12-18 Thread Carmen Cerino Jr.
Allow me to add some more context to this error. It occurs during
customization of the toolbar when I try to move a item from one
location on the toolbar to another. The odd thing is if I drag out the
default toolbar from the customization palette and repeat the same
process, this error does not occur.

On Thu, Dec 18, 2008 at 9:22 AM, Carmen Cerino Jr.  wrote:
> Can anyone explain where I should be looking for the cause of this
> issue? I pulled my toolbar code from another project that is working
> completely fine.
>
> 2008-12-18 09:19:02.485 MyProject [36461:10b] *** Assertion failure in
> -[NSToolbar _forceMoveItemFromIndex:toIndex:],
> /SourceCache/AppKit/AppKit-949.35/Toolbar.subproj/NSToolbar.m:1205
> 2008-12-18 09:19:02.485 MyProject [36461:10b] Invalid parameter not
> satisfying: frIndex>=0 && frIndex<[self _numberOfItems]
>
> --
> Carmen C. Cerino
>   University of Akron ACM Chapter President
>   University of Akron Aux. Services Student Assistant
>   Cell: 440.263.5057
>   AIM: UAcodeweaver
>   [ I <3 MACs ]
>



-- 
Carmen C. Cerino
   University of Akron ACM Chapter President
   University of Akron Aux. Services Student Assistant
   Cell: 440.263.5057
   AIM: UAcodeweaver
   [ I <3 MACs ]
___

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

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


Using a NSCollectionView in a table cell.

2008-12-18 Thread Eric Gorr
I need to be able to use a NSCollectionView inside of a cell for a  
NSOutlineView.


The outline view will have only a single column and look like:

  > Collapsible Row 1
  NSCollectionView 1

  > Collapsible Row 2
  NSCollectionView 2

and so on.

What I am uncertain about is just how to get the NSCollectionView  
inside of a table cell and be able to select an item inside of the  
collection view.


The NSCollectionView will contain a set of images with labels.

Of course, I could probably subclass a NSTextFieldCell and draw this  
all myself, but I would prefer to use the NSCollectionView which has  
all of the behaviors I want already done.


Any thoughts, comment and especially pointers to sample code would be  
appreciated.



___

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

Please do not post 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: NSURL creation problem with colon: a partial workaround

2008-12-18 Thread Mike Abdullah
According to the RFC specs referenced by the NSURL documentation, the  
colon is a reserved character. You should percent escape it before  
using it as a relative path. I believe that would be:


NSURL * url2 = [NSURL fileURLWithPath:@"/root/"];
NSURL * url3 = [NSURL URLWithString:@"file%3Atest" relativeToURL:url2];

On 18 Dec 2008, at 14:05, Jérome Laurens wrote:


Hi list,

I have a relative path with colons "file:test", and I would like to  
create a NSURL relative to a given base URL "file://localhost/root/".

This does not work as expected.

Consider the simple URL creation method

NSURL * url1 = [NSURL fileURLWithPath:@"/root/file:test"];

The url is properly created and its absoluteURL reads

file://localhost/root/file:test/

If I use a base URL things go wrong

NSURL * url2 = [NSURL fileURLWithPath:@"/root/"];
NSURL * url3 = [NSURL URLWithString:@"file:test" relativeToURL:url2];

The absolute URL of url3 reads

file:test

which is not the expected value.
Apparently NSURL parses the string as if there were no base URL at  
all,

which produces a wrong value.
Fortunately, there is a warkaround by prepending "./" to the  
relative path.


NSURL * url4 = [NSURL URLWithString:@"./file:test"  
relativeToURL:url2];


The absolute URL of url4 reads

file://localhost/root/file:test

what is the expected value.

But the standardizedURL still reads the wrong value

file:test

So prepending "./" to the relative path is just a partial workaround.

Regards
___

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

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


[Q] What type the Final Cut Pro expect when a file is drag&dropped to its project?

2008-12-18 Thread JongAm Park

Hello.

I wrote some codes which will enable drag&drop from my application to 
FCP's project.
Before implementing it, I tried dragging and dropping a file from a 
Finder to an FCP's project which was opened with the FCP.
After confirming that the FCP supports drag&drop from the Finder, I 
started implementing codes like below.


In awakeFromNib
  /
  // Registering the drag type for Drag & Drop support
  [mClipTable registerForDraggedTypes:[NSArray 
arrayWithObjects:NSFilenamesPboardType,NSURLPboardType, nil]];


  // Allow that the drag target or where it drops is other application,
  // especially the Final Cut Pro.
  [mClipTable setDraggingSourceOperationMask:NSDragOperationEvery 
forLocal:NO];

  

- (BOOL)tableView:(NSTableView *)aTableView 
writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard 
*)pboard

{
  JALog(@"--[Initiation of Drag]--");
  JALog(@"rowIndexes : %@", rowIndexes);
 
  NSMutableArray *fileNamesArray = [NSMutableArray array];

  NSURL *draggedFileURL;

  // The pasteboard is for NSFilenamesPboard
  [pboard declareTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil] 
owner:self];
 
  NSString *configPath = [preferenceSetting configPath];

  NSIndexSet *selectedRowsIndexSet = [mClipTable selectedRowIndexes];
  unsigned int anIndex;
  int indexInClipsArray;
  NSString *fileName;
 
  anIndex = [selectedRowsIndexSet firstIndex];

  while( anIndex != NSNotFound )
  {
   // For NSFilenamesPboardType
   indexInClipsArray = [self getClipsArrayIndex:anIndex];
   fileName = [NSString stringWithFormat:@"%@/%@", configPath, 
[[mClipArray objectAtIndex:indexInClipsArray] longName]];

   [fileNamesArray addObject:fileName];

// For NSURLPboardType
draggedFileURL = [[NSURL alloc] initFileURLWithPath:fileName];
[draggedFileURL writeToPasteboard:pboard];
[draggedFileURL release];

   // next index
   anIndex = [selectedRowsIndexSet indexGreaterThanIndex:anIndex];
  }

  [pboard setPropertyList:fileNamesArray forType:NSFilenamesPboardType];

  return YES;

}

When I drag and dropped a file which is shown in my application to the 
FCP, the FCP displayed a dialog box which said "File Error: Unknown 
file.". Because the paste board type to use is NSFilenamesPboardType, I 
populate file names with its path prefixed. But it didn't work.

Also, I tried NSURLPboardType, but it didn't work also.
Two options left are "file content" and "File Promise", but I am not sure if 
which one will work.

Can anyone tell me what paste board type the FCP can accept?

Thank you.


___

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

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

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

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


Re: Using a NSCollectionView in a table cell.

2008-12-18 Thread Corbin Dunn


On Dec 18, 2008, at 7:28 AM, Eric Gorr wrote:

I need to be able to use a NSCollectionView inside of a cell for a  
NSOutlineView.


The outline view will have only a single column and look like:

 > Collapsible Row 1
 NSCollectionView 1

 > Collapsible Row 2
 NSCollectionView 2

and so on.

What I am uncertain about is just how to get the NSCollectionView  
inside of a table cell and be able to select an item inside of the  
collection view.


The NSCollectionView will contain a set of images with labels.

Of course, I could probably subclass a NSTextFieldCell and draw this  
all myself, but I would prefer to use the NSCollectionView which has  
all of the behaviors I want already done.


Any thoughts, comment and especially pointers to sample code would  
be appreciated.




You will have more problems and trouble attempting to get an NSView  
inside of a cell. I suggest subclassing NSTextFieldCell. Please do log  
a bug requesting the ability to easily put views into cells.


corbin


___

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

Please do not post 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: Using a NSCollectionView in a table cell.

2008-12-18 Thread Randall Meadows

On Dec 18, 2008, at 9:52 AM, Corbin Dunn wrote:


On Dec 18, 2008, at 7:28 AM, Eric Gorr wrote:

I need to be able to use a NSCollectionView inside of a cell for a  
NSOutlineView.


[snip]
You will have more problems and trouble attempting to get an NSView  
inside of a cell. I suggest subclassing NSTextFieldCell. Please do  
log a bug requesting the ability to easily put views into cells.


Not that Corbin's advice really needs any validating, but I just tried  
to do a very similar thing (putting an NSView into a table cell), and  
ended up NOT doing so after much headache.  I ended up doing all  
custom drawing instead.


Myself, I'm off to file that bug...
___

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

Please do not post 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: Using a NSCollectionView in a table cell.

2008-12-18 Thread Eric Gorr


On Dec 18, 2008, at 11:52 AM, Corbin Dunn wrote:



On Dec 18, 2008, at 7:28 AM, Eric Gorr wrote:


I need to be able to use a NSCollectionView inside of a cell for a
NSOutlineView.

The outline view will have only a single column and look like:


Collapsible Row 1

NSCollectionView 1


Collapsible Row 2

NSCollectionView 2

and so on.

What I am uncertain about is just how to get the NSCollectionView
inside of a table cell and be able to select an item inside of the
collection view.

The NSCollectionView will contain a set of images with labels.

Of course, I could probably subclass a NSTextFieldCell and draw this
all myself, but I would prefer to use the NSCollectionView which has
all of the behaviors I want already done.

Any thoughts, comment and especially pointers to sample code would
be appreciated.



You will have more problems and trouble attempting to get an NSView
inside of a cell. I suggest subclassing NSTextFieldCell. Please do log
a bug requesting the ability to easily put views into cells.


Thanks for the advice.

Searching more through the archives, I did find:

http://www.joar.com/code/body.html

which seems to do what I want and subclasses a NSCell.

Could you provide some information on what problems I will run into  
going the route suggested by joar?



I filed the bug - rdar://6455493


___

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

Please do not post 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: Using a NSCollectionView in a table cell.

2008-12-18 Thread Eric Gorr

On Dec 18, 2008, at 11:59 AM, Randall Meadows wrote:


On Dec 18, 2008, at 9:52 AM, Corbin Dunn wrote:


On Dec 18, 2008, at 7:28 AM, Eric Gorr wrote:


I need to be able to use a NSCollectionView inside of a cell for a
NSOutlineView.

[snip]

You will have more problems and trouble attempting to get an NSView
inside of a cell. I suggest subclassing NSTextFieldCell. Please do
log a bug requesting the ability to easily put views into cells.


Not that Corbin's advice really needs any validating, but I just tried
to do a very similar thing (putting an NSView into a table cell), and
ended up NOT doing so after much headache.  I ended up doing all
custom drawing instead.

Myself, I'm off to file that bug...


Interesting.

What troubles did you run into?

Did you try using the method suggested by Joar at 
http://www.joar.com/code/body.html?

___

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

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

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

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


Re: Using a NSCollectionView in a table cell.

2008-12-18 Thread Corbin Dunn




Thanks for the advice.

Searching more through the archives, I did find:

http://www.joar.com/code/body.html

which seems to do what I want and subclasses a NSCell.

Could you provide some information on what problems I will run into  
going the route suggested by joar?




One problem is navigation; keyboard users expect to be able to tab to  
those items -- you won't be able to do that. Editing items may also  
not work, and have trouble. You may also have issues with selecting  
things, and getting background colors correct.




I filed the bug - rdar://6455493


thanks! It is useful to know how many people are wanting this feature.

corbin

___

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

Please do not post 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: Using a NSCollectionView in a table cell.

2008-12-18 Thread Randall Meadows

On Dec 18, 2008, at 10:06 AM, Eric Gorr wrote:


On Dec 18, 2008, at 11:52 AM, Corbin Dunn wrote:


On Dec 18, 2008, at 7:28 AM, Eric Gorr wrote:


You will have more problems and trouble attempting to get an NSView
inside of a cell. I suggest subclassing NSTextFieldCell. Please do  
log

a bug requesting the ability to easily put views into cells.


Thanks for the advice.

Searching more through the archives, I did find:

http://www.joar.com/code/body.html

which seems to do what I want and subclasses a NSCell.

Could you provide some information on what problems I will run into  
going the route suggested by joar?


I filed the bug - rdar://6455493


Mine's #6455498.
___

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

Please do not post 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: More - Safari Download Security Alerts

2008-12-18 Thread Dave

Hi,

I've been digging and delving and have found out why this is flakey!

When I Drag in the folder in PM, it sets the privileges to the same  
as the local copy. I then override then in the content pane, so then  
become owner: root, group: admin. This seems to work ok when you  
press "Apply Recommendations", however, if you drill down into the  
hierarchy of file, you see see that inside the .app bundle, the  
contents are still set to the local settings. If you "Select All" and  
do it, it correctly changes them to root/admin.


If you then build and run an installer, it creates:

/Application/AppFolder/AppFolder/myApp.app!

If you then remove the Destination field from the Folder (not the  
container) e.g. set it blank, then all works as expected!


So it looks like it does do the sensible thing. e.g. If the  
Destination Field is blank on an item in the Container, then it  
defaults to the Destination of the Container.


All the Best
Dave

On 17 Dec 2008, at 17:00, Jeremy Pereira wrote:



On 17 Dec 2008, at 15:27, Dave wrote:



On 17 Dec 2008, at 12:03, Jeremy Pereira wrote:



On 17 Dec 2008, at 11:28, Dave wrote:


Hi Mark,

Thanks a lot, it certainly is a lot easier to use and a lot less  
flakey, but it still doesn't work. It does not create a folder  
in "/Applications" it just installs the raw files there instead.  
I'm giving up on PackageMaker, it just doesn't work and there  
doesn't seem to be any support for it.


Seems crazy that you can't do this one simple thing with it, in  
every other installer I've ever used this would have been a 5  
min job, 2 days later using PackageMaker and still nothing. Oh  
well, such is life.


It would be crazy if it were true, but it's not.

I've just created a simple package maker project that installs to  
a sub directory of /Applications and it works absolutely fine.


Here's how I did it.

I created a directory in my home folder that mirrored the way I  
want the final installation to look i.e.


/Users/jeremyp/
->   /Applications
->   /ASubDir

I put the distribution application in ASubDir, so I have this  
directory structure:


/Users/jeremyp/
->   Applications/
->   ASubDir/
->   MyApp.app

In package maker, I added /Users/jeremyp/Applications as content.  
On the right hand pane


Install was /Users/jeremyp/Applications
Destination was /Applications (I had to change this from "/")

After running the installer with the built package, I had a  
subdirectory within /Applications called ASubDir containing my  
application exactly as expected.




Please see my last post. Did you set the Destination on the  
Contained and the Folder within it?


I'm not quite sure what you mean.  It seems to me that what  
actually happens is that PM takes everything *in* the folder you  
specify in the Install field and copies it *into* the location in  
the destination field.


I think the reason it's like this and the destination field  
defaults to / is that a common use-case of PM is you want to  
install lots of components in different places e.g. an application  
in /Applications and a driver in /System/Library/Extensions.


It doesn't seem to work unless you do this. To me this seems odd,  
if left empty surely better behavior would be to use the  
Containing Item's Destination rather than "/" ? If you wanted it  
to go into "/", you could just override by entering "/" in the  
folder Destination.


Also did you try it with files other than just the .app file? e.g.  
the .app file and (say) a .txt file.


Yes.  In fact, I just tried it with an empty directory in my  
package and the empty directory was created successfully. I had  
this structure:


$HOME/testpm/Applications/
subdir/
hosts (copied frome /etc/hosts)
emptydir/

I added $HOME/Applications as the content.  The install field was  
$HOME/Applications, the destination was /Applications


The subdir structure was created faithfully in /Applications  
including the emptydir.


Incidentally, this method preserved the folder icon I set for the  
subdir directory.





All the Best
Dave












___

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

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

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

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


Re: Using a NSCollectionView in a table cell.

2008-12-18 Thread Eric Gorr


On Dec 18, 2008, at 12:13 PM, Corbin Dunn wrote:





Thanks for the advice.

Searching more through the archives, I did find:

http://www.joar.com/code/body.html

which seems to do what I want and subclasses a NSCell.

Could you provide some information on what problems I will run into  
going the route suggested by joar?




One problem is navigation; keyboard users expect to be able to tab  
to those items -- you won't be able to do that. Editing items may  
also not work, and have trouble. You may also have issues with  
selecting things, and getting background colors correct.




Ah. I was hoping that these problems would involve things I am not  
interested in, but sadly, they are.


So, my next idea which I think will work well since I don't need a  
table header, is to dynamically create a remove columns based on the  
width of the table and create a remove rows as needed. Then, each cell  
in the table is simply one of the images I need drawn. Since I need to  
be able to support editing the label of the image, this seems like it  
would be the easiest route to go regardless.




I filed the bug - rdar://6455493


thanks! It is useful to know how many people are wanting this feature.


Well, here's hoping for support in 10.6 and that everyone reading this  
who wants the feature files a bug report and also mentions the new  
report in this thread.

___

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

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


Performance of calculation on float point numbe rs in a array • NSNumber in NSArray, or classic C ar ray?

2008-12-18 Thread Stanislas Krásnaya

Hello everyone!

I've got a basic question. I'm sure this is a very vast debate, since  
I've found several answers on the subject, but I'm not satisfied.



I've read that, since we're programming in Objective-C, it's more  
elegant and reliable to use an NSArray stuffed with NSNumber instead  
of a classic C array. But what I want to do, it's performing classic  
calculation, like mean value, variance... etc, on floating point  
numbers. Typically around 1000 of them.


I know that our computers are fast now, but this doesn't mean that we  
have to not take care of optimization.



So, since NSArray is designed to store all kinds of NSObject's, and  
mine will just store some NSNumber's, wouldn't it be a bit stupid to  
use it?


Thanks in advance.


Stanislas
___

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

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


Receiving controlTextDidChange: from change in bound value?

2008-12-18 Thread Chad Bailey

Hello list,

I have an NSTextField that has its Value attribute bound to an  
NSString object. When I update the NSString object from another place  
in my code, the value of my NSTextField updates appropriately (that's  
Bindings for you).


However, I'm trying to call sizeToFit on that NSTextField after it  
updates its value. I tried using the controlTextDidChange: delegate  
method, but it doesn't seem to fire when the control value is updated  
from bindings—only when the control is manipulated directly. I also  
tried adding code directly in a custom setter method for the NSString,  
but the value of the NSTextField doesn't seem to update until after  
the setter method completes (which makes sense).


Is there a way to fire that delegate method when the value of a  
control is updated via bindings, or is there another way I should be  
approaching this? Thanks in advance for your help.


-Chad Bailey___

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

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


Error with malloc and NSFileWrapper

2008-12-18 Thread Guillaume Campagna

Ok, I've search everywhere! And I see no reason of that error!

I'm using a NSDirectoryEnumerator to add all the content of a folder  
to some array... I'm filtering these files (I don't want certains  
types of files). One of these file types is symbolic link (alias). So  
I'm using NSFileWrapper to check that with -(BOOL) isRegularFile.  
After that I'm including these array to an custom object.


The problem is : when I include the FileWrapper code, it does not  
work. It gives me this error :


RFM(52227,0xa0182720) malloc: *** mmap(size=28672) failed (error  
code=12)

RFM(52227,0xa0182720) malloc: *** error: can't allocate region
RFM(52227,0xa0182720) malloc: *** set a breakpoint in  
malloc_error_break to debug


If I do not include the code, it works like this part of the code... :


//if([[[NSFileWrapper alloc] initWithPath:path] 
isRegularFile]) {
//Don't want nib resources and add it to the 
dictionnary
if  ([fileType isEqualToString:@"nib"]) {
[resourcesArray 
addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray 
addObject:pathResourcesName];
[resourcesNum skipDescendents];
}
//Nor these types of files
else if (([fileType isEqualToString:@"t2t"]) ||
 ([fileType 
isEqualToString:@"html"]) ||
 ([fileType 
isEqualToString:@"helpindex"]) ||
 ([fileType 
isEqualToString:@"css"]) ||
 ([fileType 
isEqualToString:@"mpkg"]) ||
 ([fileType 
isEqualToString:@"pkg"]) ||
 ([fileType 
isEqualToString:@"strings"]) ||
 ([fileType 
isEqualToString:@"plist"]) ||
 ([fileType 
isEqualToString:@"txt"]) ||
 ([fileType 
isEqualToString:@"app"]))
[resourcesNum skipDescendents];
else if (([fileType isEqualToString:@""]) ||
 ([fileType 
isEqualToString:@"lproj"]));
else {
[resourcesArray 
addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray 
addObject:pathResourcesName];
}
//}


Any help appreciated! 
___


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

Please do not post 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: Using a NSCollectionView in a table cell.

2008-12-18 Thread Kevin Gessner
An alternative route: you could use an NSCollectionView in place of  
your NSOutlineView, and populate it with more NSCollectionViews. Then  
you'd be imitating the outline view's behavior (essentially just  
collapsing), which might be simpler than trying to mimic NSView with  
NSTextFieldCell.


HTH,
-- Kevin

Kevin Gessner
http://kevingessner.com
ke...@kevingessner.com





On Dec 18, 2008, at 10:28 AM, Eric Gorr wrote:

I need to be able to use a NSCollectionView inside of a cell for a  
NSOutlineView.


The outline view will have only a single column and look like:

 > Collapsible Row 1
 NSCollectionView 1

 > Collapsible Row 2
 NSCollectionView 2

and so on.

What I am uncertain about is just how to get the NSCollectionView  
inside of a table cell and be able to select an item inside of the  
collection view.


The NSCollectionView will contain a set of images with labels.

Of course, I could probably subclass a NSTextFieldCell and draw this  
all myself, but I would prefer to use the NSCollectionView which has  
all of the behaviors I want already done.


Any thoughts, comment and especially pointers to sample code would  
be appreciated.



___

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

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

This email sent to ke...@kevingessner.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: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Rob Rix
Do the simplest thing that could possibly work. In some cases, like if  
you need to be calling -performSelector:withObject: with each of these  
things, that might be the NSArray. In your case, it sounds to me like  
it’s the C array of floats.


Just my two cents.

Rob

On 17-Dec-08, at 3:04 PM, Stanislas Krásnaya wrote:


Hello everyone!

I've got a basic question. I'm sure this is a very vast debate,  
since I've found several answers on the subject, but I'm not  
satisfied.



I've read that, since we're programming in Objective-C, it's more  
elegant and reliable to use an NSArray stuffed with NSNumber instead  
of a classic C array. But what I want to do, it's performing classic  
calculation, like mean value, variance... etc, on floating point  
numbers. Typically around 1000 of them.


I know that our computers are fast now, but this doesn't mean that  
we have to not take care of optimization.



So, since NSArray is designed to store all kinds of NSObject's, and  
mine will just store some NSNumber's, wouldn't it be a bit stupid to  
use it?


Thanks in advance.


Stanislas
___

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

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

This email sent to rix@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


-[NSURLConnection cancel] doesn't release its delegate?

2008-12-18 Thread Jonathan del Strother
Heya,
I ran into a memory leak recently that I finally managed to track down
to NSURLConnection retaining its delegate.

It appears that cancelling an NSURLConnection won't actually release
its delegate until the next time around the run loop.  Normally this
is fine, but I was running on a separate thread with its own run loop,
and I was just cancelling the connection & immediately exiting the
thread.

Is this a bug, undocumented feature, or am I missing something?

A teeny sample program demonstrating the problem appears below.

-Jonathan




#import 
#include 


static int32_t factoryCount=0;

@interface ConnectionFactory : NSObject { }
@end

@implementation ConnectionFactory

-(id)init {
if (self = [super init]) {
OSAtomicIncrement32Barrier(&factoryCount);
NSLog(@"Made new connection factory : we now have %lu 
instances",
factoryCount);

[NSThread detachNewThreadSelector:@selector(startConnection)
toTarget:self withObject:nil];

}
return self;
}
-(void)dealloc {
[super dealloc];
OSAtomicDecrement32Barrier(&factoryCount);
NSLog(@"Killing connection factory : %lu instances remaining ", 
factoryCount);
}

// This all occurs on a secondary thread
-(void)startConnection {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Starting connection on secondary thread, NSURLConnection will
retain the connection factory");
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL
URLWithString:@"http://google.com";]];
NSURLConnection* connection = [[NSURLConnection alloc]
initWithRequest:request delegate:self];

NSLog(@"Cancelling connection");
[connection cancel];
[connection release];

//  [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];//
Uncommenting this seems to allow NSURLConnection to release its
delegate.

NSLog(@"Secondary thread is done");
[pool release];
}

@end




int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
[[[ConnectionFactory alloc] init] release];
[pool drain];

sleep(5);

pool = [[NSAutoreleasePool alloc] init];
NSCAssert(factoryCount==0, @"By this point our connection factory
really should have been dealloced");
NSLog(@"Yay, looks like our factory was properly released");
[pool drain];

return 0;
}
___

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

Please do not post 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: Performance of calculation on float point numbers in a array € NSNumber in NSArray, or classic C array?

2008-12-18 Thread Scott Ribe
Depends...

How likely are you to need to resize arrays? How often do you need to
allocate & free them? Both of these are easier with NSArray & the
framework's reference-counting memory management. On the other hand, for
simple arrays of floats, packaging everything up into NSNumbers or NSValues
is also a bit of work.

For a size of 1000, I don't think it could matter. Move up to larger problem
sizes, and yes the overhead can become noticeable. I tried ripping out some
NSArray stuff and replaced it with std::vector in code that displays a
large (>30,000) item outline view, and that got a 5% overall
improvement--not huge, but still a significant amount of time to spend in
pure overhead in a tiny portion of the logic. And this 5% was after the
big-picture optimization of the algorithms involved, which had greatly
reduced the use of the arrays in question.

The usual guideline applies--try it the easiest way first; then optimize if
you need to.

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Re: Thread ID in crash log

2008-12-18 Thread Scott Ribe
> But there's still a difference, right? And when called or passed through alot,
> that small difference can become really big.
...
> The fwrite was just an example. We actually do our debugging through memory
> first (ofcourse, there's still locking) and then another debugger thread does
> the writing so the real application threads do not have to block on the IO.

Let me put it this way: the difference is small enough that if you were
logging often enough for it to be a problem, then I you might well be
filling your hard disk with the log file ;-)

Actually, have you benchmarked to see how much you gain by not using fwrite
directly? I considered this approach, and then dropped it when I saw the
actual performance. Remember, if you're not forcing fsync, then your write
is buffered and you're not waiting for a disk write. Of course you are still
calling into the kernel and dealing with locking and communications between
process, so it is indeed faster to push something on to an in-process
queue--just not as a big a difference as I had expected.

And of course the other problem is that by having a background thread
writing out queued log messages, if your thread bug causes a crash, you'll
lose some number of the most recent log messages. That's what convinced me
in the end to go ahead and write directly--I needed the most recent messages
I could possibly get.

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Re: -[NSURLConnection cancel] doesn't release its delegate?

2008-12-18 Thread Keary Suska


On Dec 18, 2008, at 10:57 AM, Jonathan del Strother wrote:


Heya,
I ran into a memory leak recently that I finally managed to track down
to NSURLConnection retaining its delegate.

It appears that cancelling an NSURLConnection won't actually release
its delegate until the next time around the run loop.  Normally this
is fine, but I was running on a separate thread with its own run loop,
and I was just cancelling the connection & immediately exiting the
thread.

Is this a bug, undocumented feature, or am I missing something?



Risking yet another foot-in-mouth syndrome, I will comment.

I would file a radar both on NSURLConnection and the documentation. An  
object shouldn't be retaining its delegate except with good reason,  
and that reason (or simply the fact of the retention) should be well  
documented. Otherwise you could get a nasty retain cycle.


Anyway, it looks like NSURLConnection is releasing the delegate using  
a performSelector:withObject:afterDelay: or similar method. Running  
the run loop as you remark in the code is the only way I know of to  
make sure the delegate is released before the thread exits.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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

Please do not post 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: Age Old Question: How Do You Set __MyCompanyName__

2008-12-18 Thread Quincey Morris

On Dec 18, 2008, at 09:47, Andy Lee wrote:

* There should be an Xcode-wide default setting for the value that  
is used for __MyCompanyName__.


* You should be able to tell what that default setting is by looking  
in Xcode's preferences, because that's the first place you're going  
to look -- not in the Xcode 3.1 release notes.


* It's fine to have "whatever is in Address Book" as a default.

* If "whatever is in Address Book" is the default, there should be a  
button in Xcode that takes you to Address Book, or some such UI, so  
you can conveniently edit the value.


* You should have the option to use something else as the default,  
because you may want to identify with a different organization for  
whatever purposes that Address Book uses that field for (what are  
those purposes, anyway?) -- including not wanting an organization  
name in Address Book at all.


* You should be able to specify a different organization, overriding  
the default, on a per-project basis.


I seem to recall there are other placeholders that can be put into  
project file templates, not just organization name.  I suspect it  
would not be appropriate to have these be fields in Address Book.   
Therefore I think there should be a preference tab in Xcode  
dedicated to these placeholders.  This would make clear what the  
complete list is and what reasonable default values are for each,  
and it would make it convenient for developers to set their values.


This information should not be buried in oral tradition, and I'm  
frankly surprised there's any debate about this.  The fact that this  
has been asked about time and time again should really be a glaring  
clue that this functionality should be exposed in UI. A developer  
shouldn't have to search list archives to find out that the  
information is in a paragraph of the Xcode 3.1 release notes.


Amen.

___

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

Please do not post 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 cancel] doesn't release its delegate?

2008-12-18 Thread Stephen J. Butler
Actually, this works for me on 10.5.6, with XCode 3.1.1. The assert
doesn't trigger.

I wonder... NSThread posts an NSThreadWillExitNotification with the
NSThread instance as the object, which is retaining your
ConnectionFactory. Is it possible that since you have no run loops the
notification gets stuck until some run loop runs?

Or it could be a bug that was fixed in the latest release.Try putting
a run loop in your main function instead. I'd try it, but like I said,
I don't think I'm seeing the failure.
___

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

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


a few Core Data questions: Predicates and document based app

2008-12-18 Thread Michael B Johnson
Getting back into Core Data over the holidays, and I've got a few  
questions.  First, the easy one:


I have an entity (let's called  it MyThing) that has an optional  
parentThing relationship.  I'm interested in MyThings that either  
don't have their parent set, ("parentThing == NIL") or have their  
parent set to themselves ("parentThing == SELF"). Do those predicate  
forms sound right?


Normally I would just test this myself and fumble around, but since I  
can't seem to get the PredicateEditorSample example to work on my  
machine (finds nothing in my large address book), I'm a little spooked  
right now.


My other question is regarding the mundanity of doing a Core Data  
document based app version versus an old skool Cocoa one, especially  
one that used a file package for document storage.


I'm realizing that I have a lot of state in my document that's  
specific to the document (i.e. not application settings).  Normally,  
these would be instance variables of my NSDocument subclass that I  
would load/save as part of my document data.


It seems more Core Dataish, though, to make an NSManagedEntity to hold  
these values, and then perhaps cache the values in a property of the  
NSManagedDocument subclass as I open up.  Assuming that is best  
practice, though, here's my concern:


Assuming I have a MyThing, and MyThing can have a single parent  
MyThing and some number of child MyThings.


In my DocInfo entity, I want to hold onto several different MyThings:  
two single ones (called bigKahuna and currentThing) and a set of them  
(called topThings).


In other words, I have 2 one-to-one relationships to MyThing in  
DocInfo, and 1 one-to-many relationships, all of which are pointing to  
MyThing.


Given Core Data's penchant (understandable!) for inverse  
relationships, I'm okay with putting a docInfo relationship in  
MyThing, I wanted to confirm that it's cool to overload it that way,  
i.e. all 3 of the relationships hanging off of DocInfo using MyThing's  
docInfo as their inverse relationship.


As always, thanks for any insight.  Looking forward to getting my  
third Core Data under my belt so my intuition for this stuff widens...



--> Michael B. Johnson, PhD
--> http://homepage.mac.com/drwave (personal)
--> http://xenia.media.mit.edu/~wave (alum)
--> MPG Lead
--> Pixar Animation Studios




___

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

Please do not post 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: Error with malloc and NSFileWrapper

2008-12-18 Thread Quincey Morris

On Dec 17, 2008, at 17:22, Guillaume Campagna wrote:

I'm using a NSDirectoryEnumerator to add all the content of a folder  
to some array... I'm filtering these files (I don't want certains  
types of files). One of these file types is symbolic link (alias).  
So I'm using NSFileWrapper to check that with -(BOOL) isRegularFile.  
After that I'm including these array to an custom object.


The problem is : when I include the FileWrapper code, it does not  
work. It gives me this error :


RFM(52227,0xa0182720) malloc: *** mmap(size=28672) failed (error  
code=12)

RFM(52227,0xa0182720) malloc: *** error: can't allocate region
RFM(52227,0xa0182720) malloc: *** set a breakpoint in  
malloc_error_break to debug


If I do not include the code, it works like this part of the code... :


//if([[[NSFileWrapper alloc] initWithPath:path] 
isRegularFile]) {
//Don't want nib resources and add it to the 
dictionnary
if  ([fileType isEqualToString:@"nib"]) {
[resourcesArray 
addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray 
addObject:pathResourcesName];
[resourcesNum skipDescendents];
}
//Nor these types of files
else if (([fileType isEqualToString:@"t2t"]) ||
 ([fileType 
isEqualToString:@"html"]) ||
 ([fileType 
isEqualToString:@"helpindex"]) ||
 ([fileType 
isEqualToString:@"css"]) ||
 ([fileType 
isEqualToString:@"mpkg"]) ||
 ([fileType 
isEqualToString:@"pkg"]) ||
 ([fileType 
isEqualToString:@"strings"]) ||
 ([fileType 
isEqualToString:@"plist"]) ||
 ([fileType 
isEqualToString:@"txt"]) ||
 ([fileType 
isEqualToString:@"app"]))
[resourcesNum skipDescendents];
else if (([fileType isEqualToString:@""]) ||
 ([fileType 
isEqualToString:@"lproj"]));
else {
[resourcesArray 
addObject:[pathResourcesName lastPathComponent]];
[fullPathsArray 
addObject:pathResourcesName];
}
//}


The error suggests that you're running out memory (or, more  
specifically, VM address space).


If this is NOT a garbage-collected application, you're leaking a  
NSFileWrapper every time through this code. (You created it, so you  
own it, so you must release it.) You could fix that by arranging to  
release the NSFileWrapper after you're done with it.


If this is a garbage-collected application, and you're in a tight loop  
over a lot of files, the garbage collector may not be getting a chance  
to run. You could fix that by calling collectIfNeeded periodically  
during the loop.



___

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

Please do not post 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: Age Old Question: How Do You Set __MyCompanyName__

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 1:39 PM, Quincey Morris
 wrote:
> On Dec 18, 2008, at 09:47, Andy Lee wrote:
>
...
>> A developer shouldn't have to search
>> list archives to find out that the information is in a paragraph of the
>> Xcode 3.1 release notes.
>
> Amen.

  It looks like you accidentally cross-posted between lists (this was
on xcode-users and really still belongs there), but I agree with every
single point Andy made. I'm off to read the thread on xcode-users
because it looks like there's been a lively debate. :-)

--
I.S.
___

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

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

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

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


Re: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Boyd Collier

Stanislas,

I don't have anything useful to add to what others have already said  
about the merits of classic C arrays vs NSArray.  However, since you  
mentioned wanting to calculate variance and other stats, if you aren't  
already familiar with the subtleties of algorithms for statistical  
calculations, you might want to read up on this topic.  Depending on  
the size of the numbers you're working with, the sample size, etc.,  
some algorithms (especially those based on the usual formulas given in  
entry-level statistics texts) can produce results that are noticeably  
different from what you ought to get, were computers able to do  
floating point arithmetic with exactness.


Boyd



On Dec 17, 2008, at 12:04 PM, Stanislas Krásnaya wrote:


Hello everyone!

I've got a basic question. I'm sure this is a very vast debate,  
since I've found several answers on the subject, but I'm not  
satisfied.



I've read that, since we're programming in Objective-C, it's more  
elegant and reliable to use an NSArray stuffed with NSNumber instead  
of a classic C array. But what I want to do, it's performing classic  
calculation, like mean value, variance... etc, on floating point  
numbers. Typically around 1000 of them.


I know that our computers are fast now, but this doesn't mean that  
we have to not take care of optimization.



So, since NSArray is designed to store all kinds of NSObject's, and  
mine will just store some NSNumber's, wouldn't it be a bit stupid to  
use it?


Thanks in advance.


Stanislas
___

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

Please do not post 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/bcollier%40sunstroke.sdsu.edu

This email sent to bcoll...@sunstroke.sdsu.edu



___

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

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


Enabling add button

2008-12-18 Thread Andre Masse

Hi,

I'm using a classic master/detail view. The detail view has a bunch of  
fields, a table view and a button (with a shortcut) for adding rows to  
it. The table view is bound to an NSArrayController. Now, I want to  
enable the button only when the table view (in the detail view) has  
the focus. I tried to bind the "enable" property of the button to the  
"canInsert" controller key of the array controller but it doesn't work  
(it's always enabled). I guess I could subclass NSArrayController,  
override "canInsert" to check if the table view is the firstResponder  
but I'm wondering if there's another way...


Thanks,

Andre Masse
___

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

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

2008-12-18 Thread Michael Ash
On Thu, Dec 18, 2008 at 3:30 AM, Jean-Daniel Dupas
 wrote:
>
> Le 18 déc. 08 à 04:55, Michael Ash a écrit :
>
>> On Wed, Dec 17, 2008 at 2:32 PM, Greg Parker  wrote:
>>>
>>> On Dec 16, 2008, at 7:22 PM, Michael Ash wrote:

 On Tue, Dec 16, 2008 at 8:02 PM, Chris Idou  wrote:
>
> Is there any Cocoa and/or Carbon interface to UNIX signals?

 Nope. It's pretty easy to set up a signal handler that can call back
 to a Cocoa/CoreFoundation runloop though, by having it write to a pipe
 or mach port which the runloop monitors.
>>>
>>> Be warned that, to a close approximation, your code isn't allowed to do
>>> anything inside the signal handler itself. This includes sending any
>>> Objective-C messages to any object. (objc_msgSend may take locks. If the
>>> signal is interrupting a thread that already holds those locks, you're
>>> stuck.)
>>>
>>> The official list of functions you can call is in the sigaction man page.
>>> Some Mach functions are also safe, but I don't know of an official list
>>> of
>>> which ones.
>>
>> Yep, that's a very good point. To use my suggestion, your signal
>> handler must do *nothing* but write to the pipe or mach port, and it
>> must ensure that the write is guaranteed non-blocking. This isn't too
>> hard, but it must be adhered to rigidly.
>
> Although, as mention by Greg Parker, I didn't find doc that guarantee that
> using mach_msg() is safe in a signal. (but Apple is using it in securityd,
> so I'm not worry about it).

Good luck finding *any* documentation about the mach functions.
(Seriously. If you know of good Apple-provided ones, I'd like to
know!) Normally I'd be wary, but in this case not having documentation
is simply par for the course.

Mike
___

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

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

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

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

Re: -[NSURLConnection cancel] doesn't release its delegate?

2008-12-18 Thread Michael Ash
On Thu, Dec 18, 2008 at 1:43 PM, Stephen J. Butler
 wrote:
> I wonder... NSThread posts an NSThreadWillExitNotification with the
> NSThread instance as the object, which is retaining your
> ConnectionFactory. Is it possible that since you have no run loops the
> notification gets stuck until some run loop runs?

NSThreadWillExitNotification is posted synchronously by the exiting
thread on the exiting thread as it exits, and as such doesn't care at
all about runloops.

Mike
___

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

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

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

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


Re: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Quincey Morris

On Dec 17, 2008, at 12:04, Stanislas Krásnaya wrote:

I've read that, since we're programming in Objective-C, it's more  
elegant and reliable to use an NSArray stuffed with NSNumber instead  
of a classic C array. But what I want to do, it's performing classic  
calculation, like mean value, variance... etc, on floating point  
numbers. Typically around 1000 of them.


I know that our computers are fast now, but this doesn't mean that  
we have to not take care of optimization.



So, since NSArray is designed to store all kinds of NSObject's, and  
mine will just store some NSNumber's, wouldn't it be a bit stupid to  
use it?


There's nothing inelegant about using a classic C array for this. You  
can allocate the memory for the array with malloc, for a classic- 
classic solution, or allocate the memory as a NSData object for a  
classic-hybrid solution. If you only want to do calculations with the  
numbers, this seems like the obvious approach.


There's also nothing wrong with using a NSArray of NSNumber objects.  
You might consider this solution if you think there might be side  
benefits, or if it is easier to code somehow. For example, if you have  
a NSArray of NSNumber objects, it's very easy to add a NSTableView to  
your interface that displays them.


It's unlikely that calculating mean, variance, etc on 1000 NSNumber  
objects is going to be a performance issue, unless you're doing these  
calculations over and over.


So, choose the approach that gives the clearest, most maintainable  
code, then (if necessary) measure the performance to see whether you  
need to optimize your approach.


FWIW.

___

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

Please do not post 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: garbage collection memory leak

2008-12-18 Thread Bill Bumgarner

On Dec 17, 2008, at 3:16 PM, Michael Link wrote:
I'm trying to track down a memory leak even though I'm using garbage  
collection. I was curious what the "rc:" field means when using  
"info gc-roots" in gdb? It doesn't seem to correlate to the Retain  
Count when inspecting an address in Instruments and it doesn't seem  
to always correlate to using "info gc-references" in gdb. I would  
tend to assume that it would make more sense if it meant the retain  
count since that would explain why the root objects have something >  
0.


rc refers to the CF level retain count.  Under GC, CFRetain() and  
CFRelease() still maintain a retain count and the collector will not  
reap objects with a non-zero retain count.


After running about 40 NSURLConnections in an application and  
closing out everything so that only the menu bar is left I noticed  
that there are some objects not being collected that are definitely  
not being used anymore and should have been collected.


Some of the objects I noticed right away are NSXMLDocuments which  
are created right after a connection sends the - 
connectionDidFinishLoading: delegate message. The method looks like:


- (void)connectionDidFinishLoading:(NSURLConnection*)connection
{
NSError* error = nil;
	NSString* string = [[NSString alloc] initWithData:connection.data  
encoding:NSUTF8StringEncoding];

NSXMLDocument* document = nil;

	if (document = [[NSXMLDocument alloc] initWithXMLString:string  
options:[self options] error:&error]) {
		... extract some NSStrings using objectsForXQuery:@"xs:string(/ 
some[1]/path[1])

... assign strings to NSManagedObject
}
}

the -connectionDidFinishLoading: runs on a background thread that is  
using NSRunLoop, so the stack should be cleared.


I was mistaken in my previous post.  The main event loop clears the  
stack, but not regular old NSRunLoops.


You'll need to clear the stack with a stock NSRunLoop.

().

I would guess that something in that thread has some objects laying  
around or possibly is falsely rooted on the stack? I'd be curious to  
find out any solutions on how to get these objects collected. After  
a few thousand NSURLConnections the leakage can be in the 100s of MBs.


Given that the rooting objects have non-zero retain counts, that is a  
source of the problem.   The roots look like the XML document has some  
low level back references to the document that are also retained by  
something.


Odd.


Filed as bug #6452901


Thanks for the bug.

b.bum

___

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

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

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

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


Re: a few Core Data questions: Predicates and document based app

2008-12-18 Thread mmalc Crawford


On Dec 18, 2008, at 10:47 AM, Michael B Johnson wrote:
I have an entity (let's called  it MyThing) that has an optional  
parentThing relationship.  I'm interested in MyThings that either  
don't have their parent set, ("parentThing == NIL") or have their  
parent set to themselves ("parentThing == SELF"). Do those predicate  
forms sound right?



Yes, for more details see
 and




My other question is regarding the mundanity of doing a Core Data  
document based app version versus an old skool Cocoa one, especially  
one that used a file package for document storage.
I'm realizing that I have a lot of state in my document that's  
specific to the document (i.e. not application settings).  Normally,  
these would be instance variables of my NSDocument subclass that I  
would load/save as part of my document data.
It seems more Core Dataish, though, to make an NSManagedEntity to  
hold these values, and then perhaps cache the values in a property  
of the NSManagedDocument subclass as I open up.


It would probably be more appropriate to store this as metadata -- see  
 for an example of how to set metadata (this is for Spotlight  
metadata, but the same principles apply).  That would also cut the  
Gordian Granny Knot of your other concerns.


mmalc

___

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

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


[Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType

2008-12-18 Thread JongAm Park

Hello, all.

I'm struggling to enable drag&dropping to Final Cut Pro's project window 
from my application.


While I was trying to figure out how to, I found this strange thing.

NSArray *supportedTypes = [NSArray 
arrayWithObject:NSFileContentsPboardType];


NSString *matchingType = [pboard availableTypeFromArray:supportedTypes];
if( [matchingType compare:@"NSFileContentsPboardType] == NSOrderedSame )
{
   outputFileName = [NSString stringWithFormat:@"%@/Desktop/test.mov", 
NSHomeDirectory()];
   outputFileNameResult = [pboard 
readFileContentsType:NSFileContentsPboardType toFile:outputFileName];

}


I expected that the matchingType returned by calling 
availableTypeFromArray is @"NSFileContentsPboardType".

But, in fact, it returns @"NXFileContentsPboardType".
So, it doesn't reach the body of the if clause.
Is this a bug?

For other pboard types, it seems to return NS*PboardType, according to 
this document.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/Reference/Reference.html#//apple_ref/doc/uid/2328-availableTypeFromArray_

___

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

Please do not post 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: Enabling add button

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 1:57 PM, Andre Masse  wrote:

> I'm using a classic master/detail view. The detail view has a bunch of
> fields, a table view and a button (with a shortcut) for adding rows to it.
> The table view is bound to an NSArrayController. Now, I want to enable the
> button only when the table view (in the detail view) has the focus. I tried
> to bind the "enable" property of the button to the "canInsert" controller
> key of the array controller but it doesn't work (it's always enabled). I
> guess I could subclass NSArrayController, override "canInsert" to check if
> the table view is the firstResponder but I'm wondering if there's another
> way...

  Why do you need the button's enabled state to depend on which
control has focus? This is *not* usual Mac OS X UI behavior and is in
fact counterintuitive. As a user, I would never think to click inside
a table to enable an associated button. I would assume that - for
reasons unknown - I'm not allowed to add to that table because it is
grayed out. Unless, of course, I happen to click in the table first
... then I would still likely not associate the behavior with clicking
the table. I would most likely report this to you as a bug in the UI.
Most astute users would (if they bothered continuing to use a
perceived "buggy" application) as well.

  I suggest you reconsider this. Better yet, post your reasons why you
feel this is necessary and maybe others can suggest alternatives.

  At a guess, the reasoning is that you only want users to be able to
add to the details of the selected master object when a master object
is selected. Right? If you describe your setup a bit more
(particularly the controller and button bindings/targets), maybe we
can help you figure out why the add button is always enabled.

--
I.S.
___

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

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

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

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


Re: Age Old Question: How Do You Set __MyCompanyName__

2008-12-18 Thread Quincey Morris

On Dec 18, 2008, at 10:56, I. Savant wrote:


 It looks like you accidentally cross-posted between lists (this was
on xcode-users and really still belongs there), but I agree with every
single point Andy made. I'm off to read the thread on xcode-users
because it looks like there's been a lively debate. :-)


Oops, my apologies.

The debate has been lively, but not heated (for a change).


___

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

Please do not post 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: a few Core Data questions: Predicates and document based app

2008-12-18 Thread Michael B Johnson


On Dec 18, 2008, at 11:04 AM, mmalc Crawford wrote:



On Dec 18, 2008, at 10:47 AM, Michael B Johnson wrote:
I have an entity (let's called  it MyThing) that has an optional  
parentThing relationship.  I'm interested in MyThings that either  
don't have their parent set, ("parentThing == NIL") or have their  
parent set to themselves ("parentThing == SELF"). Do those  
predicate forms sound right?



Yes, for more details see
 and





Great, thanks.  I had skimmed that, but missed the specific example in  
"Using".





My other question is regarding the mundanity of doing a Core Data  
document based app version versus an old skool Cocoa one,  
especially one that used a file package for document storage.
I'm realizing that I have a lot of state in my document that's  
specific to the document (i.e. not application settings).   
Normally, these would be instance variables of my NSDocument  
subclass that I would load/save as part of my document data.
It seems more Core Dataish, though, to make an NSManagedEntity to  
hold these values, and then perhaps cache the values in a property  
of the NSManagedDocument subclass as I open up.


It would probably be more appropriate to store this as metadata --  
see  for an example of how to set metadata (this is for Spotlight  
metadata, but the same principles apply).  That would also cut the  
Gordian Granny Knot of your other concerns.


I guess that's my question, though.  Why is that a bad thing, to have  
three relationships from on entity all pointing to another entity,  
which is only pointing to the other entity once?


Trying to gain some deeper understanding...

- wave






mmalc



___

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

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


Preventing Automatic Gzip Decompression with NSURLConnection?

2008-12-18 Thread Andrew Lindesay

Hello;

I have figured out that NSURLConnection is decompressing data when the  
header "Content-Encoding" is equal to "gzip".  Fair enough and  
probably quite handy, but I would like to stop it doing this as I  
would like to show a progress bar for a download and if the data is  
being automatically decompressed then I can't see how far through the  
process it is.  Is there a means to repress the automatic  
decompression of this data as it comes down?


cheers.

___
Andrew Lindesay
www.lindesay.co.nz

___

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

Please do not post 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: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classic C array?

2008-12-18 Thread I. Savant
Stanislas:

> I've read that, since we're programming in Objective-C, it's more elegant
> and reliable to use an NSArray stuffed with NSNumber instead of a classic C
> array. But what I want to do, it's performing classic calculation, like mean
> value, variance... etc, on floating point numbers. Typically around 1000 of
> them.
>
> I know that our computers are fast now, but this doesn't mean that we have
> to not take care of optimization.

  I faced this very same situation with a scientific data mining and
visualization application. In my case, it was a permutation test
against a whole lot of doubles (for reasons of precision). When
dealing with any level of precision, you may have to "roll the dice"
10,000 times per comparison or more. Because the application takes
advantage of Core Data and (to an extent Cocoa Bindings) I first
implemented this using NS[Mutable]Arrays of NSNumbers.

  It did not perform well. :-)

  The standard test set I used took literally around a minute to run.
Unacceptable for a "explore as you go" visualization UI. I then asked
myself why I felt everything had to be shoehorned into Cocoa /
Objective-C ... of course I was embarrassed and had no explanation to
offer myself. After I'd thoroughly chastised myself for being so
ridiculous, I re-implemented the test by extracting the necessary
values into a C array of doubles (and another of randomized vector
indices) then doing the calculations.

  First, I'll say that this felt wasteful because "they're already
neatly-packaged objects - won't performance suffer copying values back
and forth like that?" Once I got over that and actually reasoned it
out, I informed myself that the answer was, of course, "no, because
comparatively speaking, copying the values around is nothing next to
100,000 iterations and many more sufficiently-random-number
generations to shuffle the vectors".

  To which I replied, "Oh." :-)

  All told, the minute-long permutation test was reduced to about two
seconds. Wow.

  I hope this is helpful.

--
I.S.
___

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

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

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

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


Re: Age Old Question: How Do You Set __MyCompanyName__

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 2:12 PM, Quincey Morris
 wrote:

> The debate has been lively, but not heated (for a change).

  Indeed - I encourage anyone not subscribed directly to the
xcode-users list to check out the archives (look for the thread of
this same subject). Some very salient UI (I = "interaction" in this
case, not necessarily "interface") issues came up.

  I share the frustration. :-)

--
I.S.
___

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

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

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

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


does this crash make sense to anyone?

2008-12-18 Thread slasktrattena...@gmail.com
Hi,

my app keeps annoying me by crashing at launch every now and then.
What's weird about the backtrace is that it tells me I have called a
CLASS method named setFrame:. The class varies: in this case it says
NSClipView, sometimes is says NSAttributedString, or NSObject, or
whatever. Of course, I don't make any such calls explicitly, and most
of the time the app launches just fine. Any idea what the problem
could be, or how to locate it with gdb? I never learned using the
debugger properly.

Thanks
Fabian

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0002, 0x
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** +[NSClipView setFrame:]:
unrecognized selector sent to class 0xa0370c60'

Thread 0 Crashed:
0   com.apple.CoreFoundation0x90df3fb4
___TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION___ + 4
1   libobjc.A.dylib 0x94babe3b objc_exception_throw + 40
2   com.apple.CoreFoundation0x90dfb3ca +[NSObject
doesNotRecognizeSelector:] + 186
3   com.apple.CoreFoundation0x90df990c ___forwarding___ + 892
4   com.apple.CoreFoundation0x90df99d2 _CF_forwarding_prep_0 + 50
5   com.apple.imageKit  0x90a9cdc0 -[IKImageFlowView
_adjustScroller] + 219
6   com.apple.imageKit  0x90a9ced3 -[IKImageFlowView
frameDidChange:] + 66
7   com.apple.Foundation0x9569ce1a _nsnote_callback + 106
8   com.apple.CoreFoundation0x90d5b8da __CFXNotificationPost + 362
9   com.apple.CoreFoundation0x90d5bbb3
_CFXNotificationPostNotification + 179
10  com.apple.Foundation0x9569a080 -[NSNotificationCenter
postNotificationName:object:userInfo:] + 128
11  com.apple.Foundation0x956a38c8 -[NSNotificationCenter
postNotificationName:object:] + 56
12  com.apple.AppKit0x92aeef43 -[NSView
_postFrameChangeNotification] + 198
13  com.apple.AppKit0x92af4db3 -[NSView setFrameSize:] + 788
14  com.apple.AppKit0x92af4a71 -[NSView setFrame:] + 253
15  com.myCompany.myApp 0x0003c7bc 0x1000 + 243644
16  com.apple.CoreFoundation0x90e02915 -[NSSet
makeObjectsPerformSelector:] + 181
17  com.apple.AppKit0x92adc45a -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:] + 1533
18  com.apple.AppKit0x92ad2686 loadNib + 264
19  com.apple.AppKit0x92ad1fe8 +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:] + 946
20  com.apple.AppKit0x92ad1c2b +[NSBundle(NSNibLoading)
loadNibFile:externalNameTable:withZone:] + 171
21  com.apple.AppKit0x92ad1b69 +[NSBundle(NSNibLoading)
loadNibNamed:owner:] + 391
22  com.apple.AppKit0x92ad1818 NSApplicationMain + 434
23  com.myCompany.myApp 0x2942 0x1000 + 6466
___

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

Please do not post 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: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Stanislas Krásnaya

Thank you, Rob, Rich Scott, and Quincey for these answers.


I'm new to the programming world, so I think the first thing to do is  
to figure out exactly what I want and then what I need. If I have to  
optimise something later, I will do it.


Since it is about an array of a measurement points of a X-rays planar  
dose (just doses at points on a plan) on witch the statistical  
calculations are only made once in a while, I will first stick with  
the objects and take benefit of all the Cocoa frameworks that make  
things easier.


But you've enlarged my horizon on some other aspects that I didn't  
know :) I will dig deeper there too.


Thanks again!

Stanislas.




On Dec 18, 2008, at 6:55 PM, Rob Rix wrote:

Do the simplest thing that could possibly work. In some cases, like  
if you need to be calling -performSelector:withObject: with each of  
these things, that might be the NSArray. In your case, it sounds to  
me like it’s the C array of floats.


Just my two cents.

Rob








On Dec 18, 2008, at 7:00 PM, Rich Collyer wrote:


"bit stupid" - no, but..

The resulting assembly from:

NSArray testArray = [NSArray alloc] init];
// TODO: fill array with a bunch of NSNumbers (floats)

int i;
float bigNum;
for (i = 0; i < [testArray count]; ++i)
{
bigNum *= [testArray objectAtIndex:i];
}

Will be a bit slower than the assembly of:

float testArray[SIZEOFARRAY];
// TODO: fill array with a bunch of floats

int i;
float bigNum;
for (i = 0; i < SIZEOFARRAY; ++i)
{
bigNum *= testArray[i];
}

mainly because the c array and be stuffed into a processor register  
and there are no object manipulations involved.


However, you never know when Apple will do something tricky with  
Grand Central Dispatch that will void this argument.


+++
Rich Collyer - Senior Software Engineer
rcoll...@ironkey.com

IronKey - The World's Most Secure Flash Drive
2008 SC Magazine Readers Choice Award Winner
2008 FOSE Best of Show Winner
2007 GCN Labs Reviewers Choice Winner
+++






On Dec 18, 2008, at 7:02 PM, Scott Ribe wrote:


Depends...

How likely are you to need to resize arrays? How often do you need to
allocate & free them? Both of these are easier with NSArray & the
framework's reference-counting memory management. On the other hand,  
for
simple arrays of floats, packaging everything up into NSNumbers or  
NSValues

is also a bit of work.

For a size of 1000, I don't think it could matter. Move up to larger  
problem
sizes, and yes the overhead can become noticeable. I tried ripping  
out some
NSArray stuff and replaced it with std::vector in code that  
displays a

large (>30,000) item outline view, and that got a 5% overall
improvement--not huge, but still a significant amount of time to  
spend in
pure overhead in a tiny portion of the logic. And this 5% was after  
the

big-picture optimization of the algorithms involved, which had greatly
reduced the use of the arrays in question.

The usual guideline applies--try it the easiest way first; then  
optimize if

you need to.






On Dec 18, 2008, at 8:01 PM, Quincey Morris wrote:

There's nothing inelegant about using a classic C array for this.  
You can allocate the memory for the array with malloc, for a classic- 
classic solution, or allocate the memory as a NSData object for a  
classic-hybrid solution. If you only want to do calculations with  
the numbers, this seems like the obvious approach.


There's also nothing wrong with using a NSArray of NSNumber objects.  
You might consider this solution if you think there might be side  
benefits, or if it is easier to code somehow. For example, if you  
have a NSArray of NSNumber objects, it's very easy to add a  
NSTableView to your interface that displays them.


It's unlikely that calculating mean, variance, etc on 1000 NSNumber  
objects is going to be a performance issue, unless you're doing  
these calculations over and over.


So, choose the approach that gives the clearest, most maintainable  
code, then (if necessary) measure the performance to see whether you  
need to optimize your approach.


FWIW.

___

___

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

Please do not post 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: does this crash make sense to anyone?

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 2:33 PM, slasktrattena...@gmail.com
 wrote:

> my app keeps annoying me by crashing at launch every now and then.
> What's weird about the backtrace is that it tells me I have called a
> CLASS method named setFrame:. The class varies

  This is a CLASSic sign of a memory management problem.

> I never learned using the debugger properly.

  That's very unfortunate ... as a developer you're doing yourself the
single-biggest disservice by not learning to use arguably the most
basic tool of the trade. I'd recommend getting familiar with it ASAP.

--
I.S.
___

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

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

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

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


Re: does this crash make sense to anyone?

2008-12-18 Thread Shawn Erickson
On Thu, Dec 18, 2008 at 11:33 AM, slasktrattena...@gmail.com
 wrote:
> Hi,
>
> my app keeps annoying me by crashing at launch every now and then.
> What's weird about the backtrace is that it tells me I have called a
> CLASS method named setFrame:. The class varies: in this case it says
> NSClipView, sometimes is says NSAttributedString, or NSObject, or
> whatever. Of course, I don't make any such calls explicitly, and most
> of the time the app launches just fine. Any idea what the problem
> could be, or how to locate it with gdb? I never learned using the
> debugger properly.

This is indicative of not correctly retaining an object (likely an
object given to you that you then stick into an instance var without
taking "ownership" of it) . As a result the object is deallocated out
from under you (likely as a result of the currently auto release pool
being drained) and then that slot in memory is randomly replaced with
a different object instance likely of a totally unrelated class.

You can use NSZombie to help isolate...

http://developer.apple.com/technotes/tn2004/tn2124.html

-Shawn
___

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

Please do not post 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: a few Core Data questions: Predicates and document based app

2008-12-18 Thread Quincey Morris

On Dec 18, 2008, at 11:18, Michael B Johnson wrote:

I guess that's my question, though.  Why is that a bad thing, to  
have three relationships from on entity all pointing to another  
entity, which is only pointing to the other entity once?


It's not a *bad* thing, but the model editor won't let you do it. (If  
relationships A and B both have C as their inverse, what is C's  
inverse?)


If the size of the objects is not an issue, it's probably easiest to  
go ahead and have 3 pairs of relationships. The 2 "unnecessary"  
inverses then just become housekeeping that Core Data takes care of  
(that you otherwise forget about).



___

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

Please do not post 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: does this crash make sense to anyone?

2008-12-18 Thread Shawn Erickson
On Thu, Dec 18, 2008 at 11:45 AM, Shawn Erickson  wrote:
> On Thu, Dec 18, 2008 at 11:33 AM, slasktrattena...@gmail.com
>  wrote:
>> Hi,
>>
>> my app keeps annoying me by crashing at launch every now and then.
>> What's weird about the backtrace is that it tells me I have called a
>> CLASS method named setFrame:. The class varies: in this case it says
>> NSClipView, sometimes is says NSAttributedString, or NSObject, or
>> whatever. Of course, I don't make any such calls explicitly, and most
>> of the time the app launches just fine. Any idea what the problem
>> could be, or how to locate it with gdb? I never learned using the
>> debugger properly.
>
> This is indicative of not correctly retaining an object (likely an
> object given to you that you then stick into an instance var without
> taking "ownership" of it) . As a result the object is deallocated out
> from under you (likely as a result of the currently auto release pool
> being drained) and then that slot in memory is randomly replaced with
> a different object instance likely of a totally unrelated class.
>
> You can use NSZombie to help isolate...
>
> http://developer.apple.com/technotes/tn2004/tn2124.html

I should note it could also be because you are releasing an object
that you shouldn't be releasing. Normally an over release would fail
in a different way (crash in a future release message) but it is
possible to get what you are seeing because of an over release in
addition to an under release situation.

If this is a GC using application then the issue will be different.

-Shawn
___

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

Please do not post 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: Enabling add button

2008-12-18 Thread Andre Masse

Thanks for your reply.


Why do you need the button's enabled state to depend on which
control has focus? This is *not* usual Mac OS X UI behavior and is in
fact counterintuitive. As a user, I would never think to click inside
a table to enable an associated button. I would assume that - for
reasons unknown - I'm not allowed to add to that table because it is
grayed out. Unless, of course, I happen to click in the table first
... then I would still likely not associate the behavior with clicking
the table. I would most likely report this to you as a bug in the UI.
Most astute users would (if they bothered continuing to use a
perceived "buggy" application) as well.

 I suggest you reconsider this. Better yet, post your reasons why you
feel this is necessary and maybe others can suggest alternatives.



Let me explain a bit more. This is an in house application for only 3  
people (me, my wife and my son) that was originally built with 4th  
Dimension. I agree that this is not the expected behavior for mac  
users but it is for mine, as this is the way automatic buttons are  
handled in 4D. I'm willing to make this more "mac like" but I want to  
prevent something like this:


1- user select a row in the master table view,
2- press the button's shortcut (intentionally or not)
3- a row is added to the detail's table view but since it does not  
have the focus, the row selection's is grayed and its not that evident  
that an operation has occurred. Further more, to edit the new row, the  
user will have to move the focus to the table view by clicking on it...




 At a guess, the reasoning is that you only want users to be able to
add to the details of the selected master object when a master object
is selected. Right? If you describe your setup a bit more
(particularly the controller and button bindings/targets), maybe we
can help you figure out why the add button is always enabled.


The detail's view is only shown when a row is selected in the master  
table view. If not, a view similar to Versions (http://www.versionsapp.com/ 
) is displayed. I should mention that this application uses a lot of  
data entries and almost all operations are done using the keyboard. A  
typical use case is something like this:


1- do a query to find a client by name
2- user either add a client or modify one by adding rows in the  
detail's table view

repeat...

The master table view use a datasource (no bindings).

I'm open to any suggestions,

Andre Masse


___

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

Please do not post 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: Preventing Automatic Gzip Decompression with NSURLConnection?

2008-12-18 Thread Knut Lorenzen


Am 18.12.2008 um 20:22 schrieb Andrew Lindesay:

I have figured out that NSURLConnection is decompressing data when  
the header "Content-Encoding" is equal to "gzip".  Fair enough and  
probably quite handy, but I would like to stop it doing this as I  
would like to show a progress bar for a download and if the data is  
being automatically decompressed then I can't see how far through  
the process it is.  Is there a means to repress the automatic  
decompression of this data as it comes down?



Take a look at NSURLDownload's delegate  
download:shouldDecodeSourceDataOfMIMEType:


Setting your MIMEType to @"gzip" and returning NO should to the trick.

Cheers,

Knut





___

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

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


Implementing a record counter (record n of records)

2008-12-18 Thread Jon C. Munson II
Namaste!

I'm attempting to implement a simple record counter:

Record n of records

 n = current record number 

 records = total number of records

I've looked at the Events Manager sample and borrowed the text field from
there which has a representation of "# out #."  It uses the Value with
Pattern Bindings method:  %{value1}@ out of %{valu...@.  value1 =
somecontroller.selecti...@count, value2 =
somecontroller.arrangedobjec...@count.

However, the first binding, Value1, is incorrect.  It holds the number of
records that are selected (most likely used in conjunction with a
tableView).  So, I changed it to selectedIndex instead of the binding it
had.  This, of course, yields a zero-based index value vs. count which is
1-based.  Then, the question after that is, what happens when there aren't
any objects?  selectionIndex is most likely going to be some number other
than 0 (and it is from my own testing).

Attempting my own move methods resulted in not being able to get an initial
count of records in the arrangedObjects (which can seemingly only be
retrieved through awakeFromNib, though arrangedObjects hasn't been retrieved
yet).

Thus my question:  what is the correct way to implement a record counter?
Or, what is the correct key value binding for Value1?

Thanks in advance!

Peace, Love, and Light,
 
/s/ Jon C. Munson II

___

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

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


Question Regarding the Memory Address of Objects

2008-12-18 Thread Carter R. Harrison

Ok, hopefully this is an easy one.

I have a Nib file setup with an NSView and some NSButton's as subviews  
of that view.  I have IBOutlets for each of the NSButton's in my  
NSView subclass.


In the awakeFromNib: method of my NSView subclass I do the following:

- (void)awakeFromNib
{   
//Initialize NSMutableDictionary instance variable
	dict = [[NSMutableDictionary alloc] initWithCapacity:1];		// "dict"  
is an NSMutableDictionary instance variable


	//Set the value "button1" into the dictionary and make it's key the  
string representation of button1's memory address.
	[dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x",  
&button1]];		// "button1" is one of my IBOutlets.

}

When a user clicks the button the following method fires and promptly  
crashes my app.


- (void)buttonClicked:(id)sender
{
// Print out the value for the button pressed.  THIS LINE CRASHES
	NSString *value = [dict valueForKey:[NSString stringWithFormat:@"%x",  
&sender]];


//This next line crashes app - EXC_BAD_ACCESS
NSLog(@"Value is: %@", value);
}

It seems like the memory address of the sender is different than what  
it should be.  I did some debugging and the address of the sender is  
always bfffe2e8 which really shouldn't be possible at all.


Any ideas?  As always, thanks in advance.


___

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

Please do not post 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: Preventing Automatic Gzip Decompression with NSURLConnection?

2008-12-18 Thread Knut Lorenzen


Am 18.12.2008 um 20:53 schrieb Knut Lorenzen:


Setting your MIMEType to @"gzip" and returning NO should to the trick.


Ouch, this should probably be @"application/gzip" :)

Cheers,

Knut




___

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

Please do not post 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: Enabling add button

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 2:52 PM, Andre Masse  wrote:

> Let me explain a bit more. This is an in house application for only 3 people
> (me, my wife and my son) that was originally built with 4th Dimension. I
> agree that this is not the expected behavior for mac users but it is for
> mine, as this is the way automatic buttons are handled in 4D. I'm willing to
> make this more "mac like" but I want to prevent something like this:
>
> 1- user select a row in the master table view,
> 2- press the button's shortcut (intentionally or not)
> 3- a row is added to the detail's table view but since it does not have the
> focus, the row selection's is grayed and its not that evident that an
> operation has occurred. Further more, to edit the new row, the user will
> have to move the focus to the table view by clicking on it...

  I see ... I can't really suggest anything more than what you'd
mentioned if you're using bindings for the detail view (subclassing
and overriding). Well, except maybe binding the button to a
KVC/KVO-compliant "state" property somewhere else in your app that
returns true if the table's window's first responder is the desired
table ...

  I see the problem you're referring to, though, in a keyboard-driven
environment, but this is a difficult problem to solve without causing
other problems (ie, unexpected UI behavior). It's almost the classic
"more security == less convenience" scenario. In this case "security"
refers to that of your data integrity. :-)

> A typical use case is something like this:
>
> 1- do a query to find a client by name
> 2- user either add a client or modify one by adding rows in the detail's
> table view
> repeat...
>
> The master table view use a datasource (no bindings).
>

  Perhaps all your tables should use a datasource (and delegate). This
way your add button can call a method that directly checks the
responder status, then if everything is okay, adds the object, reloads
the table's data (so the object is available immediately - not
possible using Bindings), then call the table's
-editColumn:row:withEvent:select: method to make the table ready to
edit.

--
I.S.
___

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

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

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

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


Re: Enabling add button

2008-12-18 Thread Andre Masse


On Dec 18, 2008, at 15:10, I. Savant wrote:

 It's almost the classic "more security == less convenience"  
scenario. In this case "security"

refers to that of your data integrity. :-)



Exactly :-)


 Perhaps all your tables should use a datasource (and delegate). This
way your add button can call a method that directly checks the
responder status, then if everything is okay, adds the object, reloads
the table's data (so the object is available immediately - not
possible using Bindings), then call the table's
-editColumn:row:withEvent:select: method to make the table ready to
edit.


I guess I have no choice. BTY, when does NSArrayController canInsert:  
returns NO?


Thanks again,

Andre Masse
___

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

Please do not post 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: Enabling add button

2008-12-18 Thread Kyle Sluder
On Thu, Dec 18, 2008 at 2:52 PM, Andre Masse  wrote:
> 1- user select a row in the master table view,
> 2- press the button's shortcut (intentionally or not)
> 3- a row is added to the detail's table view but since it does not have the
> focus, the row selection's is grayed and its not that evident that an
> operation has occurred. Further more, to edit the new row, the user will
> have to move the focus to the table view by clicking on it...

If you place the control correctly (using a small square button with
the standard plus symbol, located directly underneath the table view
it modifies and flush with its left edge) then there will be no
confusion.  Clicking the button should transfer focus to the editable
text in the new row in the table view.

--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: Question Regarding the Memory Address of Objects

2008-12-18 Thread Quincey Morris

On Dec 18, 2008, at 11:57, Carter R. Harrison wrote:

I have a Nib file setup with an NSView and some NSButton's as  
subviews of that view.  I have IBOutlets for each of the NSButton's  
in my NSView subclass.


In the awakeFromNib: method of my NSView subclass I do the following:

- (void)awakeFromNib
{   
//Initialize NSMutableDictionary instance variable
	dict = [[NSMutableDictionary alloc] initWithCapacity:1];		// "dict"  
is an NSMutableDictionary instance variable


	//Set the value "button1" into the dictionary and make it's key the  
string representation of button1's memory address.
	[dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x",  
&button1]];		// "button1" is one of my IBOutlets.

}

When a user clicks the button the following method fires and  
promptly crashes my app.


- (void)buttonClicked:(id)sender
{
// Print out the value for the button pressed.  THIS LINE CRASHES
	NSString *value = [dict valueForKey:[NSString  
stringWithFormat:@"%x", &sender]];


//This next line crashes app - EXC_BAD_ACCESS
NSLog(@"Value is: %@", value);
}

It seems like the memory address of the sender is different than  
what it should be.  I did some debugging and the address of the  
sender is always bfffe2e8 which really shouldn't be possible at all.


Don't use an "&" in either place. You don't want the address of the  
outlet or the address of a local variable on the stack, you want a  
pointer to the button, which is what you get without the &.



___

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

Please do not post 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: Enabling add button

2008-12-18 Thread Andre Masse


On Dec 18, 2008, at 15:32, Kyle Sluder wrote:


If you place the control correctly (using a small square button with
the standard plus symbol, located directly underneath the table view
it modifies and flush with its left edge) then there will be no
confusion.  Clicking the button should transfer focus to the editable
text in the new row in the table view.


This is what I'm using (in a Mail like toolbar). The confusion occur  
when the user is using the shortcut...


Thanks,

Andre Masse
___

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

Please do not post 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: Implementing a record counter (record n of records)

2008-12-18 Thread Kevin Gessner

On Dec 18, 2008, at 2:50 PM, Jon C. Munson II wrote:


Namaste!

I'm attempting to implement a simple record counter:

Record n of records

n = current record number

records = total number of records

I've looked at the Events Manager sample and borrowed the text field  
from

there which has a representation of "# out #."  It uses the Value with
Pattern Bindings method:  %{value1}@ out of %{valu...@.  value1 =
somecontroller.selecti...@count, value2 =
somecontroller.arrangedobjec...@count.

However, the first binding, Value1, is incorrect.  It holds the  
number of

records that are selected (most likely used in conjunction with a
tableView).  So, I changed it to selectedIndex instead of the  
binding it
had.  This, of course, yields a zero-based index value vs. count  
which is
1-based.  Then, the question after that is, what happens when there  
aren't
any objects?  selectionIndex is most likely going to be some number  
other

than 0 (and it is from my own testing).


You could use a value transformer that would add 1 to selectedIndex.  
It could also return something like "(nothing selected)" when there's  
no selection. The "some number other than 0" might be  
NSNoSelectionMarker, so you could check against that in your value  
transformer.


HTH,
-- Kevin

Kevin Gessner
http://kevingessner.com
ke...@kevingessner.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: Enabling add button

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 3:27 PM, Andre Masse  wrote:
> BTY, when does NSArrayController canInsert: returns NO?

  From the docs: "Returns a Boolean value that indicates whether an
object can be inserted into the receiver's content collection."

  I've only ever seen it return NO when the content collection isn't
present. In other words, if your Widget Detail controller's content
array (or set) is bound to the Master's selection.widgets and a valid
Master object is selected, it would return YES. If there is no Master
selection, you'd get NO.

  There may be other stipulations but I can't think of them off-hand.

--
I.S.
___

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

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

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

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


Re: Enabling add button

2008-12-18 Thread I. Savant
On Thu, Dec 18, 2008 at 3:32 PM, Kyle Sluder  wrote:

> If you place the control correctly (using a small square button with
> the standard plus symbol, located directly underneath the table view
> it modifies and flush with its left edge) then there will be no
> confusion.  Clicking the button should transfer focus to the editable
> text in the new row in the table view.

  The issue Andre mentioned is that the app is mostly keyboard-driven
(and the key combo fires the button, which he fears can be triggered
inadvertently). This means it doesn't matter where the button is - the
key combo can still trigger the action without calling "enough"
attention to the resulting insert.

--
I.S.
___

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

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

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

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


Re: Question Regarding the Memory Address of Objects

2008-12-18 Thread David Duncan

On Dec 18, 2008, at 11:57 AM, Carter R. Harrison wrote:

	[dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x",  
&button1]];		// "button1" is one of my IBOutlets.
	NSString *value = [dict valueForKey:[NSString  
stringWithFormat:@"%x", &sender]];


It seems like the memory address of the sender is different than  
what it should be.  I did some debugging and the address of the  
sender is always bfffe2e8 which really shouldn't be possible at all.



Your confusing the pointer with the object itself. button1 is a  
pointer to a button. sender is a pointer to the object that sent the  
message. When you take the address of either pointer, you get the  
location of that pointer in memory - not the location of the object.  
The pointer itself contains the location of the object in memory.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


Re: Question Regarding the Memory Address of Objects

2008-12-18 Thread Carter R. Harrison


On Dec 18, 2008, at 3:44 PM, David Duncan wrote:


On Dec 18, 2008, at 11:57 AM, Carter R. Harrison wrote:

	[dict setValue:@"button1" forKey:[NSString stringWithFormat:@"%x",  
&button1]];		// "button1" is one of my IBOutlets.
	NSString *value = [dict valueForKey:[NSString  
stringWithFormat:@"%x", &sender]];


It seems like the memory address of the sender is different than  
what it should be.  I did some debugging and the address of the  
sender is always bfffe2e8 which really shouldn't be possible at all.



Your confusing the pointer with the object itself. button1 is a  
pointer to a button. sender is a pointer to the object that sent the  
message. When you take the address of either pointer, you get the  
location of that pointer in memory - not the location of the object.  
The pointer itself contains the location of the object in memory.

--
David Duncan
Apple DTS Animation and Printing



David,

Once again you have saved me from pulling my hair out.  Thank you once  
again for your assistance.  For the rest of the folks on the thread  
the solution was to remove the "&" from the front of all my pointers.


Regards,
Carter
___

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

Please do not post 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: Implementing a record counter (record n of records)

2008-12-18 Thread Jon C. Munson II
Thanks alot, that worked out well as far as a single value goes. :)

How does one create a value transformer for multiple values?  Do you need to
write a transformer for each value in the chain, etc.?

Thanks again!

Peace, Love, and Light, 

/ s/ Jon C. Munson II

-Original Message-
From: Kevin Gessner [mailto:ke...@kevingessner.com] 
Sent: Thursday, December 18, 2008 3:40 PM
To: jmun...@his.com
Cc: 'cocoa dev'
Subject: Re: Implementing a record counter (record n of records)


You could use a value transformer that would add 1 to selectedIndex.  
It could also return something like "(nothing selected)" when there's  
no selection. The "some number other than 0" might be  
NSNoSelectionMarker, so you could check against that in your value  
transformer.

HTH,
-- Kevin

Kevin Gessner
http://kevingessner.com
ke...@kevingessner.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: Validation of a Custom View NSToolbarItem

2008-12-18 Thread Carmen Cerino Jr.
I apologize if I cam of snarky in my last email. I guess I may still
confused on how the validation process works. My impression from the
Toolbar Programming guide was that if you are dealing with  image
based items you want to implement the validateToolbarItem in your
target. However if you are dealing with an item with a custom view you
need to go the subclassing route and override validate. They did not
mention in the guide that validate needs to make a call to  any other
methods outside whatever you need to do in order to make the contents
of the view appear disabled or enabled. Another issue I am having is
that I read view based items don't get autovalidated, so by
autovalidation are they referring to the act of validating or the
process of checking if something is valid or not? I guess that would
be the reason why I made my first post. I was unsure if I was suppose
to ask the item to validate itself  or if the toolbar should be doing
it.

I did try the class that Keith provided, but had no luck. I am a
breakpoint and an NSLog statement inside validate and neither are
getting hit. From this point on lets assume that I am using Keith's
custom item, but here is some of the rest of my code.



static void addToolbarItem(NSMutableDictionary *theDict,NSString
*identifier,NSString *label,NSString *paletteLabel,NSString
*toolTip,id target,SEL settingSelector, id itemContent,SEL action,
NSMenu * menu)
{
   NSMenuItem *mItem;
   NSToolbarItem *item;

   if([identifier isEqualToString:@"uploads"])
   {
  item = [[[KBViewToolbarItem alloc]
initWithItemIdentifier:identifier] autorelease];
   }
   else
   {
  item = [[[NSToolbarItem alloc]
initWithItemIdentifier:identifier] autorelease];
   }

   [item setLabel:label];
   [item setPaletteLabel:paletteLabel];
   [item setToolTip:toolTip];
   [item setTarget:target];
   [item performSelector:settingSelector withObject:itemContent];
   [item setAction:action];

   if (menu!=NULL)
   {
  // we actually need an NSMenuItem here, so we construct one
  mItem=[[[NSMenuItem alloc] init] autorelease];
  [mItem setSubmenu: menu];
  [mItem setTitle: [menu title]];
  [item setMenuFormRepresentation:mItem];
   }

   [theDict setObject:item forKey:identifier];
}

+ (NSToolbar*)initialToolbarWithDelegate:(id)delegate
{
   NSToolbar *toolbar=[[[NSToolbar alloc]
initWithIdentifier:@"myToolbar"] autorelease];
   [toolbar setDelegate:delegate];
   [toolbar setAllowsUserCustomization:YES];
   [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
   [toolbar setSizeMode:NSToolbarSizeModeSmall];
   return toolbar;
}

-(void)awakeFromNib
{
   mToolbarItems = [[NSMutableDictionary alloc] init];
   
addToolbarItem(mToolbarItems,@"login",@"Login",@"Login/Logout",@"Login.",self,@selector(setImage:),[NSImage
imageNamed:NSImageNameUser],@selector(loginLogout:),NULL);
   
addToolbarItem(mToolbarItems,@"serverStatus",@"servername.domain.com",@"servername.domain.com",@"Connected
server status.",self,@selector(setImage:),[NSImage
imageNamed:@"ConnectionGood"],@selector(showWebsite:),NULL);
   addToolbarItem(mToolbarItems,@"uploads",@"View Uploads",@"View
Uploads",@"View your pending
uploadds.",self,@selector(setView:),ibPendingUploadsItemView,
NULL,NULL);
}

- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
itemForItemIdentifier:(NSString *)itemIdentifier
willBeInsertedIntoToolbar:(BOOL)flag
{
   // We create and autorelease a new NSToolbarItem, and then go
through the process of setting up its
   // attributes from the master toolbar item matching that identifier
in our dictionary of items.
   NSToolbarItem *newItem = [[[NSToolbarItem alloc]
initWithItemIdentifier:itemIdentifier] autorelease];
   NSToolbarItem *item=[mToolbarItems objectForKey:itemIdentifier];

   [newItem setLabel:[item label]];
   [newItem setPaletteLabel:[item paletteLabel]];
   if ([item view]!=NULL)
   {
  [newItem setView:[item view]];
   }
   else
   {
  [newItem setImage:[item image]];
   }
   [newItem setToolTip:[item toolTip]];
   [newItem setTarget:[item target]];
   [newItem setAction:[item action]];
   [newItem setMenuFormRepresentation:[item menuFormRepresentation]];
   if ([newItem view]!=NULL)
   {
  [newItem setMinSize:[[item view] bounds].size];
  [newItem setMaxSize:[[item view] bounds].size];
   }

   [newItem setEnabled:YES];
   return newItem;
}


- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
   return [NSArray
arrayWithObjects:@"login",@"uploads",NSToolbarSeparatorItemIdentifier,NSToolbarFlexibleSpaceItemIdentifier,@"serverStatus",nil];
}

- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
   return [NSArray arrayWithObjects:@"login",@"uploads",
NSToolbarSeparatorItemIdentifier,NSToolbarFlexibleSpaceItemIdentifier,@"serverStatus",
NSToolbarSpaceItemIdentifier,nil];
}


- (BOOL)validateToolbarItem:(NSToolbarItem *)theItem
{
   if([[theItem itemIdentifier] isEqualToString:@"login"])
   {
  if((mLoggedIn && ![[theItem label] is

Re: NSToolbar Error

2008-12-18 Thread Carmen Cerino Jr.
This issue has been resolved. Unfortunately, I can't think of an easy
way to describe the issue without providing some deep contextual
details of some of my code. However it is not related to the issue I
am having with validation of a toolbar item with a custom view.

On Thu, Dec 18, 2008 at 9:42 AM, Carmen Cerino Jr.  wrote:
> Allow me to add some more context to this error. It occurs during
> customization of the toolbar when I try to move a item from one
> location on the toolbar to another. The odd thing is if I drag out the
> default toolbar from the customization palette and repeat the same
> process, this error does not occur.
>
> On Thu, Dec 18, 2008 at 9:22 AM, Carmen Cerino Jr.  
> wrote:
>> Can anyone explain where I should be looking for the cause of this
>> issue? I pulled my toolbar code from another project that is working
>> completely fine.
>>
>> 2008-12-18 09:19:02.485 MyProject [36461:10b] *** Assertion failure in
>> -[NSToolbar _forceMoveItemFromIndex:toIndex:],
>> /SourceCache/AppKit/AppKit-949.35/Toolbar.subproj/NSToolbar.m:1205
>> 2008-12-18 09:19:02.485 MyProject [36461:10b] Invalid parameter not
>> satisfying: frIndex>=0 && frIndex<[self _numberOfItems]
>>
>> --
>> Carmen C. Cerino
>>   University of Akron ACM Chapter President
>>   University of Akron Aux. Services Student Assistant
>>   Cell: 440.263.5057
>>   AIM: UAcodeweaver
>>   [ I <3 MACs ]
>>
>
>
>
> --
> Carmen C. Cerino
>   University of Akron ACM Chapter President
>   University of Akron Aux. Services Student Assistant
>   Cell: 440.263.5057
>   AIM: UAcodeweaver
>   [ I <3 MACs ]
>



-- 
Carmen C. Cerino
   University of Akron ACM Chapter President
   University of Akron Aux. Services Student Assistant
   Cell: 440.263.5057
   AIM: UAcodeweaver
   [ I <3 MACs ]
___

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

Please do not post 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: [Q] availableTypeFromArray returns NXFileContentsPboardType instead of NSFileContentsPboardType

2008-12-18 Thread Michael Ash
On Thu, Dec 18, 2008 at 2:09 PM, JongAm Park
 wrote:
> Hello, all.
>
> I'm struggling to enable drag&dropping to Final Cut Pro's project window
> from my application.
>
> While I was trying to figure out how to, I found this strange thing.
>
> NSArray *supportedTypes = [NSArray
> arrayWithObject:NSFileContentsPboardType];
>
> NSString *matchingType = [pboard availableTypeFromArray:supportedTypes];
> if( [matchingType compare:@"NSFileContentsPboardType] == NSOrderedSame )
> {
>   outputFileName = [NSString stringWithFormat:@"%@/Desktop/test.mov",
> NSHomeDirectory()];
>   outputFileNameResult = [pboard
> readFileContentsType:NSFileContentsPboardType toFile:outputFileName];
> }
> 
>
> I expected that the matchingType returned by calling availableTypeFromArray
> is @"NSFileContentsPboardType".
> But, in fact, it returns @"NXFileContentsPboardType".
> So, it doesn't reach the body of the if clause.
> Is this a bug?

It's a bug in your code.

Cocoa defines a string constant called NSFileContentsPboardType.
You're using a constant string with the *contents*
@"NSFileContentsPboardType". This is *not* the same thing. Nothing
says that the string constant must contain a string which exactly
matches its name. And in this case, it doesn't match. Use
NSFileContentsPboardType instead of @"NSFileContentsPboardType" and
you'll find your code will suddenly work. Any time the actual content
of a string constant is not documented, you *must* only use the
constant itself in your code, not what it contains (or what you think
it contains).

Mike
___

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

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

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

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


Re: Question Regarding the Memory Address of Objects

2008-12-18 Thread Michael Ash
On Thu, Dec 18, 2008 at 3:53 PM, Carter R. Harrison
 wrote:
> Once again you have saved me from pulling my hair out.  Thank you once again
> for your assistance.  For the rest of the folks on the thread the solution
> was to remove the "&" from the front of all my pointers.

I'd suggest that your basic approach isn't really very good. For one
thing, it'll break on 64-bit (%x is an int, which is still 32-bit).
Even if you fix that, generating a string with a pointer value is a
pretty baroque way to do what you're doing.

If you can require 10.5, simply use NSMapTable. It works like an
NSDictionary but can take arbitrary (non-NSCopying) pointers as keys,
when properly configured.

If you must run on 10.4 or below, either use CFDictionary with
customized callbacks (and *don't* use the toll-free bridging support
if you do, TFB'd CFDictionaries will copy their keys even if you tell
them not to) or use [NSValue valueWithPointer:] to generate keys.

Mike
___

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

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

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

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


Debugging a Plugin

2008-12-18 Thread Bridger Maxwell
Hey,
I am setting up my application to work with plugins. I can see how I can get
a plugin to build, and how to load/use it from the application, but I can't
figure out how I would debug the plugin. Is it possible to configure Xcode
to launch the application, tell it to use that plugin (some sort of startup
parameter?), and then debug the plugin's code even though it is the
application running it? Because most of the programming for this application
will actually be in developing the plugins, it is very important that the
debugging process it easy to setup and use. Perhaps there is an article or
something on how to set up Xcode to launch a binary in a non-standard way?

Thank You,
Bridger Maxwell
___

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

Please do not post 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: Debugging a Plugin

2008-12-18 Thread Nick Zitzmann


On Dec 18, 2008, at 3:56 PM, Bridger Maxwell wrote:


Is it possible to configure Xcode
to launch the application, tell it to use that plugin (some sort of  
startup

parameter?), and then debug the plugin's code even though it is the
application running it?


It's possible.


Perhaps there is an article or
something on how to set up Xcode to launch a binary in a non- 
standard way?



It's not non-standard, and it's pretty easy. All you do is create a  
custom executable in the plugin project pointing it to the program  
that will launch the plugin, then load it in the debugger. I do this  
to test preference panes, IB plugins, etc. all the time.


Be warned, if your plugin is for QuickTime or iTunes, then you'll run  
into some problems with ptrace(). Search Google for details.


Nick Zitzmann




___

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

Please do not post 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: Enabling add button

2008-12-18 Thread Andre Masse

On Dec 18, 2008, at 15:42, I. Savant wrote:


 I've only ever seen it return NO when the content collection isn't
present. In other words, if your Widget Detail controller's content
array (or set) is bound to the Master's selection.widgets and a valid
Master object is selected, it would return YES. If there is no Master
selection, you'd get NO.


I had a bug that was setting the content array to nil, strangely the  
button bound to "canInsert:" was enabled... Didn't try binding to  
selection though.


Thanks for your help,

Andre Masse
___

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

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


[Q] How to let the pasteboard know a file type?

2008-12-18 Thread JongAm Park

Hi,

Thanks to a utility program, called DragPeeker X, I found out some clue 
why the FCP treated dragged file as a file with unknown type.


When I dragged the same file from the Finder to the FCP, it shows :

Number of Items: 1
1. Item Reference: 19884c10
   Item Bounds (tlbr): { 86, 1, 104, 191 }
   Number of flavors: 2
   1.Flavor Type: 'furl'
   Flavor Flags: 0
   Length: 54
   Data:
   66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 
file://localhost
   2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E 
/Volumes/172.16.
   32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 
246.146/MOV/0003
   59 42 2E 6D 6F 76   
YB.mov 
   2.Flavor Type: 'hfs '

   Flavor Flags: 300
   Length: 80
   Data:
   4D 6F 6F 56 3F 3F 3F 3F 00 00 FF 98 00 00 00 13 
MooV
   0A 30 30 30 33 59 42 2E 6D 6F 76 DC 00 00 00 00 
.0003YB.mov.
   FF FF FF FF 00 00 00 00 00 25 F0 A0 A0 31 60 34 
.%...1`4
   91 F6 C0 A0 BF FF DA 80 84 04 20 42 91 F6 6B 44 
.. B..kD
   91 F6 C0 A0 00 86 B4 00 17 BB 17 FC BF FF DA C4 



But if I drag one from my application to the FCP, it shows :

Number of Items: 1
1. Item Reference: c0c0a
   Item Bounds (tlbr): { 219, 244, 219, 244 }
   Number of flavors: 2
   1.Flavor Type: 'furl'
   Flavor Flags: 0
   Length: 54
   Data:
   66 69 6C 65 3A 2F 2F 6C 6F 63 61 6C 68 6F 73 74 
file://localhost
   2F 56 6F 6C 75 6D 65 73 2F 31 37 32 2E 31 36 2E 
/Volumes/172.16.
   32 34 36 2E 31 34 36 2F 4D 4F 56 2F 30 30 30 33 
246.146/MOV/0003
   59 42 2E 6D 6F 76   
YB.mov 
   2.Flavor Type: 'hfs '

   Flavor Flags: 0
   Length: 80
   Data:
   00 00 00 00 00 00 00 00 00 00 FF 98 00 00 00 13 

   0A 30 30 30 33 59 42 2E 6D 6F 76 FC 00 25 DB A0 
.0003YB.mov..%..
   00 00 00 06 00 18 80 00 00 00 00 60 00 25 8E B0 
...`.%..
   90 10 7A 44 BF FF DA 70 44 04 20 42 90 10 7D EC 
..zD...pD. B..}.
   00 00 00 02 BF FF DA 90 00 00 00 20 BF FF DC F4 
... 



( I also tried NSURLPboardType and NSFileContentsPboardType. But they 
didn't make information like above appear. )

The PboardType I used was NSFilenamesPboardType.

The major difference between those are in the 2nd flavor type 'hfs'.
Their flavor flags are different: one is 300, while the other is 0.

What actually matters, I think, is the data of the 2nd flavor.
The one using the Finder starts with MooV, which says that the 
dragged item is a QuickTime movie, while the one from my application 
doesn't contain anything. ( all 0's. )


So, is there any way to mark that the interested file is in a specific 
type, i.e. QuickTime movie file?


Thank you.

___

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

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

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

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


NSTableView cross-coupling rows when editing strings?

2008-12-18 Thread Graham Cox
I have a weird problem with NSTableView that I'm having trouble  
getting to the bottom of. The situation is a little complicated...


I have an array of objects. The table shows the properties of these  
objects, one object per row, one property per column, as usual. One of  
the properties of the object is its 'representedObject', which is a  
further object that can be one of five specific classes. To store  
these, the custom object has a mutable dictionary, which uses a string  
key, one for each class (the key is derived from the Class, but I'm  
pretty sure that's not important here). The overall container of these  
custom objects has a setting indicating which of the five classes its  
objects should be delivering.


To edit the custom objects, the table view has a column for the  
representedObject property. According to the current setting, I swap  
in a different type of dataCell for the table column appropriate to  
the class to be edited.


The five kinds of representedObject are a) a custom class of my own,  
b) a NSColor, c) a NSString, d) a NSValue and d) an NSImage.  
Corresponding to these I set the dataCell to a,d) NSImageCell, b) a  
custom cell type to handle colours, c,d) a NSTextFieldCell.


The custom colour cell and the image cell situation works fine. But  
when I'm using the NSTextFieldCell, I get interference between rows. I  
can set the text for row 0 for example, but then when I start editing  
row 1 (or any other row), the existing string is first set to empty,  
then to whatever I enter - all rows that have a string set end up with  
the same string. Tracing in the debugger I can see they are all  
retaining the same NSString object. It's as if the NSTextFieldCell  
isn't editing a copy of the string.


I've been staring at this for so long now I just can't see the wood  
for the trees. Any ideas? Note that I'm not using bindings or any  
hidden magic other than KVC - just a classic dataSource. Relevant bits  
of code (I think) follow.


Data source - nothing up my sleeve here folks:

- (NSInteger)   numberOfRowsInTableView:(NSTableView*) aTableView
{
#pragma unused(aTableView)

return [mTransformer countOfBins];
}


- (id)			tableView:(NSTableView *)aTableView	objectValueForTableColumn: 
(NSTableColumn*) aTableColumn	row:(NSInteger) rowIndex

{
#pragma unused(aTableView)

	return [[[mTransformer bins] objectAtIndex:rowIndex] valueForKey: 
[aTableColumn identifier]];

}


- (void)		tableView:(NSTableView*)aTableView setObjectValue:anObject  
forTableColumn:(NSTableColumn*) aTableColumn row:(NSInteger) rowIndex

{
#pragma unused(aTableView)

NSString* ident = [aTableColumn identifier];

if([ident isEqualToString:@"index"])
return;

DKOBin* bin = [[mTransformer bins] objectAtIndex:rowIndex];

[bin setValue:anObject forKey:ident];
}

Here's where I switch the table column's cell according to the data  
type of the representedObject:


- (void)setOutputType:(int) aType
{
[mTransformer setBinDataType:aType];

// set title of column header

NSString* title = [self titleForDataType:aType];

	NSTableColumn* tc = [mBinsTable  
tableColumnWithIdentifier:@"representedObject"];

NSTableHeaderCell* thecell = [tc headerCell];
[thecell setTitle:title];

	// the cell type must be set to be appropriate to the class of data  
expected from -representedObject
	// for styles/images  this is an image, colours = special colour  
cell, text and number = text cell.


NSCell* aCell = [self dataCellForType:aType];
[aCell setEditable:YES];
[aCell setEnabled:YES];
[tc setDataCell:aCell];

[mBinsTable reloadData];

[mDataTypePopUpButton selectItemWithTag:aType];
[mBlendColoursButton setEnabled:aType == kBinOutputTypeColour];
}

The -dataCellForType: method just alloc/init/autoreleases a cell of  
the relevant class.


Here's where the actual object's representedObject property is  
actually set:


- (void)setRepresentedObject:(id) anObject
{
	// each bin is able to store a variety of represented objects of  
unique class. The class is used as a key.
	// The set data type of the container is used to pick the appropriate  
class when -representedObject is invoked.


if( anObject )
{
// what class are we expecting? Sanity check the object against 
this:

		Class expectedClass = [DKOBinningDataTransformer classForDataType: 
[[self container] binDataType]];


if([anObject isKindOfClass:expectedClass])
{
NSString* key = NSStringFromClass(expectedClass);

			NSLog(@"bin %@ setting object (%p) '%@' for key '%@'", self,  
anObject, anObject, key );


[mRepresentedObjects setObje

Re: Enabling add button

2008-12-18 Thread Andre Masse


On Dec 18, 2008, at 15:43, I. Savant wrote:


 The issue Andre mentioned is that the app is mostly keyboard-driven
(and the key combo fires the button, which he fears can be triggered
inadvertently). This means it doesn't matter where the button is - the
key combo can still trigger the action without calling "enough"
attention to the resulting insert.


Exactly. You're way better than me explaining my own problems :-) I  
used to talk/write English much more 5-6 years ago (even co-translated  
a book from French to English). Now, I only use English in this list  
and it shows :-)


Thanks,

Andre Masse
___

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

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


[ANN] Objective-XML 4.3

2008-12-18 Thread Marcel Weiher
Just a quick note that I have just released version 4.3 of Objective- 
XML, an efficient and convenient XML framework for Cocoa (Touch):


http://www.metaobject.com/downloads/Objective-C/Objective-XML-4.3.tgz


From the Readme:

Objective-XML is an XML processing framework for Objective-C.  It  
provides both highly efficient implementations of existing DOM and SAX  
APIs as well as a new Message oriented API for XML (MAX).



MAX

The Message Oriented API for XML is a streaming API similar to SAX  
with two important innovations.  First, it translates from XML element  
names directly to specific Objective-C messages, so clients don't have  
to do string matching on the tag names.  Second, it handles most of  
the book-keeping associated with tree-building, while giving to the  
client full control over what kind of tree to build, including none at  
all.


MAX's flexibility allows clients of the parser to easily create DOM or  
SAX style parsers, or freely mix elements as needed.  In the tradition  
of eating your own dog food, Objective-XML's SAX and DOM parsers are  
both built on top of MAX.


SAX

Objective-XML's SAX parser is plug-compatible with Cocoa's  
NSXMLParser, but performs much faster while using far less memory.   
How much faster and how much less memory?  Usually around an order of  
magnitude on both counts.


DOM

A DOM is an inherently memory intensive way of representing XML  
documents.  So although Objective-XML's DOM is relatively efficient  
both in memory and CPU usage, it is not just much more efficient to  
build a MAX parser to your own objects, it is usually easier, too.




___

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

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


Return key for sheet button - different behaviour on 10.4

2008-12-18 Thread Andy Bettis

Hi,

In my app I have several sheets that have an OK button linked to the  
return key - the classic default button behaviour. Some of them are  
used for multiple entry so after pressing OK the fields are cleared  
but the sheet remains open for the next entry. All works fine in  
development and testing (10.5, Intel) but when I try the app on my  
older test machine (10.4, G5) the entry point is moved down to another  
field, it's as if the return key generates a tab input. This occurs  
after the return key is processed, I send an explicit  
makeFirstResponder message but the entry point is set to the next  
field in the tab order. As I said, all works fine under 10.5.


Any ideas? Or workarounds?

Rev. 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: NSTableView cross-coupling rows when editing strings?

2008-12-18 Thread Corbin Dunn


On Dec 18, 2008, at 3:28 PM, Graham Cox wrote:

The five kinds of representedObject are a) a custom class of my own,  
b) a NSColor, c) a NSString, d) a NSValue and d) an NSImage.  
Corresponding to these I set the dataCell to a,d) NSImageCell, b) a  
custom cell type to handle colours, c,d) a NSTextFieldCell.


A regular NSTextFieldCell, or a custom subclass? If so, what code is  
in in it?


corbin
___

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

Please do not post 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: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Rich Collyer

"bit stupid" - no, but..

The resulting assembly from:

NSArray testArray = [NSArray alloc] init];
// TODO: fill array with a bunch of NSNumbers (floats)

int i;
float bigNum;
for (i = 0; i < [testArray count]; ++i)
{
bigNum *= [testArray objectAtIndex:i];
}

Will be a bit slower than the assembly of:

float testArray[SIZEOFARRAY];
// TODO: fill array with a bunch of floats

int i;
float bigNum;
for (i = 0; i < SIZEOFARRAY; ++i)
{
bigNum *= testArray[i];
}

mainly because the c array and be stuffed into a processor register  
and there are no object manipulations involved.


However, you never know when Apple will do something tricky with Grand  
Central Dispatch that will void this argument.


+++
Rich Collyer - Senior Software Engineer
rcoll...@ironkey.com

IronKey - The World's Most Secure Flash Drive
2008 SC Magazine Readers Choice Award Winner
2008 FOSE Best of Show Winner
2007 GCN Labs Reviewers Choice Winner
+++




On Dec 17, 2008, at 12:04 PM, Stanislas Krásnaya wrote:


Hello everyone!

I've got a basic question. I'm sure this is a very vast debate,  
since I've found several answers on the subject, but I'm not  
satisfied.



I've read that, since we're programming in Objective-C, it's more  
elegant and reliable to use an NSArray stuffed with NSNumber instead  
of a classic C array. But what I want to do, it's performing classic  
calculation, like mean value, variance... etc, on floating point  
numbers. Typically around 1000 of them.


I know that our computers are fast now, but this doesn't mean that  
we have to not take care of optimization.



So, since NSArray is designed to store all kinds of NSObject's, and  
mine will just store some NSNumber's, wouldn't it be a bit stupid to  
use it?


Thanks in advance.


Stanislas
___

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

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


This email sent to rcoll...@ironkey.com




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

subclassing NSApplication run

2008-12-18 Thread Chinh Nguyen
I know everyone is going to say don't do this but I really need to do  
this.  I need to duplicate the behavior of NSApplication run's event  
handling.  What the docs say about subclassing run is "This a critical  
and complex task, however, that you should only attempt with good  
reason." with no further information.  I've got a good reason and I  
can get into more detail about why later if necessary.


My app is a cross platform app (Mac, Windows, and Unix) that all run  
in a single thread and share the same event handling model--the app  
controls the event loop.  The app has an "engine" that controls  
everything such as processing commands, creating graphs, running  
scripts, displaying help files, etc.  90% of the app's functionality  
must run through the engine which are submitted as commands.  Although  
most of the engine is not reentrant, it makes sure it's in a safe  
state when it polls in case the GUI needs to, for example, create and  
display a programmable dialog from a script on disk that describes the  
dialog while it's already creating a complicated graph.


It's not practical to rewrite this behavior in the app although we're  
taking steps towards instancing up the engine.  However, it'll be  
quite some time before that happens and our users are clamoring for  
the 64-bit version of our app now (necessary for the huge amount of  
data they work with).


I've been working on porting my Carbon app to Cocoa for 64-bit  
support.  Because NSApplicationMain() (and namely, NSApplication run)  
never returns, I created a separate worker thread for the engine to  
run in (the old polling logic is macro'd to nothing).  It's constantly  
looping waiting for commands to be submitted to it (it does idle when  
necessary though).  This works great but the problem is that the  
engine is not thread-safe.  Since neither is AppKit, I'm constantly  
having to make sure methods perform in the right thread otherwise I  
get crashes.  I'm still going through my code to do this and it's  
really tedious.  This biggest issue is that I've found the GUI to be  
quite sluggish in some instances.  For example, the GUI may respond to  
an event by performing code in the worker thread (without waiting, a  
must) which may in turn may perform GUI methods in the main thread  
(while waiting).  Not waiting for methods to perform in the main  
thread speeds things up a little but I haven't confirmed whether  
that's safe yet.


So I've decided to investigate going back to the original single- 
threaded polling model.  To avoid being blocked by NSApplication run,  
I duplicated the behavior of NSApplicationMain() and part of run by  
initializing my NSApplication instance, loading my main nib, then  
invoking finishLaunching.  Control then goes to my engine as before.   
I poll using nextEventMatchingMask:untilDate:inMode:dequeue: and  
sendEvent:.  I just added this earlier today and my app seems to be  
running OK, is much snappier in the situations where it was sluggish  
in the multi-threaded model, and I haven't observed any memory leaks.   
However, I noticed that after a closing a window, the previous key  
window does not become key.  I can add code to handle this but I'm  
concerned there are other things going on in NSApplication's run  
method do/while loop that I'm missing.  Can anyone tell me what else I  
need to do in my event loop?


Again, I can get into more detail about why my app has to behave the  
way it does for clarification.


-Chinh Nguyen
 cngu...@stata.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: proper way to release a static NSMutableDictionary?

2008-12-18 Thread Dale Merrick

As someone else suggested why not just use

[lookup removeAllObjects]

or perhaps I am missing a part of the bigger picture for the project  
you're working on.


Dale Merrick


On Dec 15, 2008, at 4:54 PM, John Michael Zorko wrote:



Hello, all ...

Imagine this:

static NSMutableDictionary *lookup = [NSMutableDictionary new];

... now imagine a situation where I need to clear that dictionary.   
If I call


[lookup release];
lookup = [NSMutableDictionary new];

... it will obviously be faster than coding a for loop and removing  
each object in the dictionary, but since it was declared as static,  
which is safer?


Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.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/theuone%40me.com

This email sent to theu...@me.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


NSAppleScript returns wrong result on multiple Safari windows, applescript editor works

2008-12-18 Thread Jot Kali

Hello,

I'm trying to get the URL of whatever is the front window / selected  
tab in Safari. But for multiple windows it does not work.


Say the user opens a window in Safari and navigates to apple.com,  
opens a tab and goes to nytimes.com, opens a NEW window and goes to  
arstechnica.com


If I run this script in Script Editor it works every time, returns  
arstechnica.com (the URL of the new front window) :


tell application "Safari"
return URL of front document as string
end tell


However if I do this in my Cocoa app :

NSDictionary *dict;
NSAppleEventDescriptor *result;

	NSAppleScript *script = [[NSAppleScript alloc] initWithSource:  
@"\ntell application \"Safari\"\n\tget URL of front document \nend tell 
\n"];

result = [script executeAndReturnError:&dict];

[script release];

if ((result != nil) && ([result descriptorType] != kAENullEvent))  
{;

   NSLog (@"URL %@", [result stringValue]);   
}


It returns nytimes.com. It always returns the last tab of the FIRST  
window that was opened in safari. I have to close that window to get  
it to return the actual front most window site arstechnica.com.


I tried both 'front document' and 'document 1', both no go.

Any hints on what is going wrong?

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


Problem when userSpaceScaleFactor is not 1.0

2008-12-18 Thread Gary Crandall
I have a situation that I have been unable to solve for several weeks. Inside a 
view, I am drawing a "box" that shows a "drop down" effect, similar to a 
drawer. So in the "closed" state it is a narrow rectangle, and when it "opens," 
it expands into a larger rectangle, with a "drop-down" effect. The effect is 
created by calling [[self animator]setFrameSize:size]. The result is a nice, 
smooth "drop down" effect, because the top origin position is pinned to the 
same location (using Interface Builder "springs and struts").

However, when the userSpaceScaleFactor for the app is set to some fractional 
value (such as scaling by 1.25), the box is not stable. Instead, the top origin 
visibly "jumps" around by a pixel or two. I am sure this has something to do 
with the rounding of fractional pixels, but I have been unable to solve it. 
Note that this happens only when setting the frame size through the animator 
(because the result is system calls to setFrameSize), and it only jumps around 
if the scale factor is not 1.0. 

I have tried overriding setFrameSize, and setFrameOrigin, attempting 
conversions that seem like they should work---all to no avail. No matter what I 
do, I cannot figure out how to keep the box pinned to the same vertical 
location during the "animation" of the frame.

Anyone have any ideas?
___

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

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


Newbie scroll view problem

2008-12-18 Thread Andy Bettis

Hi,

In my app I have an NSScrollView that contains a simple NSView in  
which I add other NSView subclass objects. All works well until the  
window (and hence the scroller) is resized - making it smaller is OK  
but if it is made bigger than the original (IB) size my added views  
migrate down the window. I've tried adjusting the autosizing settings  
but to no avail.


I'm trying not to have to subclass the containing view, I just want  
the scroller to reveal more of it as it is enlarged while leaving my  
subviews aligned to the top left corner. Do I need to flip the  
coordinates to keep them up there? I'll probably end up limiting the  
maximum window size so the user can't make it too big but I'd like to  
know what's going on.


Any help, explanation or advice gratefully received.

Rev. 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: NSTableView cross-coupling rows when editing strings?

2008-12-18 Thread Graham Cox


On 19 Dec 2008, at 10:50 am, Corbin Dunn wrote:



On Dec 18, 2008, at 3:28 PM, Graham Cox wrote:

The five kinds of representedObject are a) a custom class of my  
own, b) a NSColor, c) a NSString, d) a NSValue and d) an NSImage.  
Corresponding to these I set the dataCell to a,d) NSImageCell, b) a  
custom cell type to handle colours, c,d) a NSTextFieldCell.


A regular NSTextFieldCell, or a custom subclass? If so, what code is  
in in it?


corbin



Actually I'm using RSVerticallyCenteredTextFieldCell from Daniel  
Jalkut. But I've tried substituting an ordinary NSTextFieldCell and I  
get the same outcome. Just to show, the code where I make the cell is:


- (NSCell*) dataCellForType:(int) aType
{
NSCell* aCell = nil;

switch( aType )
{
default:
break;

case kBinOutputTypeStyle:
case kBinOutputTypeImage:
aCell = [[NSImageCell alloc] init];
break;

case kBinOutputTypeColour:
aCell = [[GCColourCell alloc] init];
break;

case kBinOutputTypeText:
case kBinOutputTypeValue:
aCell = [[NSTextFieldCell alloc] init];
//aCell = [[RSVerticallyCenteredTextFieldCell alloc] 
init];
// TODO: for value cell, attach suitable formatter
break;
}

return [aCell autorelease];
}


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


NSData downloaded over socket is bigger than it should be...

2008-12-18 Thread Jean-Nicolas Jolivet
Well this is going to be a bit vague since my situation is a bit  
specific but basically I am downloading data using AsyncSocket...   
then I'm saving it directly to the HD...
However in like 80% of the cases, the resulting data on disk is  
slightly bigger (usually around 12 or 13bytes) than it should be  
(according to the crc32)


I am downloading multiparts email attachments (encoded via either  
uuencode, yEnc or Base64)... and the corresponding decoder always  
complains of bad CRC checks when I try to decode the downloaded data...


It's always a *tiny* amount of bytes (but not a constant amount) so  
for example if I downloaded an Mp3 file, the resulting decoded data  
will play, but with little glitches every here and there (probably  
where the parts were joined)some examples of the decoder's otuput:


Part 1.rar: Decoded size (384012) does not match expected size (384000)
Part 2.rar: Decoded size (384013) does not match expected size (384000)
...

Now as I said, I know this is really vague, but did anyone experience  
something similar with AsyncSocket or any other sockets? or NSData  
altogether??




Jean-Nicolas Jolivet
silver...@videotron.ca
http://www.silverscripting.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


CLLocationDistance contents?

2008-12-18 Thread Jacob Rhoden

Hi Guys, I am doing the following to find a distance between two locations:

CLLocation* venueLocation = [[CLLocation alloc] initWithLatitude: 
venue.latitude longitude:venue.longditude];
CLLocationDistance distance = [venueLocation 
getDistanceFrom:currentLocation];


Is distance in metres/miles/km? How do I display it on screen in a 
platform independent way? I cant find any examples in the developer 
centre thingy.


Thanks
-jacob

---
http://jacobrhoden.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: NSTableView cross-coupling rows when editing strings?

2008-12-18 Thread Corbin Dunn


On Dec 18, 2008, at 3:59 PM, Graham Cox wrote:



On 19 Dec 2008, at 10:50 am, Corbin Dunn wrote:



On Dec 18, 2008, at 3:28 PM, Graham Cox wrote:

The five kinds of representedObject are a) a custom class of my  
own, b) a NSColor, c) a NSString, d) a NSValue and d) an NSImage.  
Corresponding to these I set the dataCell to a,d) NSImageCell, b)  
a custom cell type to handle colours, c,d) a NSTextFieldCell.


A regular NSTextFieldCell, or a custom subclass? If so, what code  
is in in it?


corbin



Actually I'm using RSVerticallyCenteredTextFieldCell from Daniel  
Jalkut. But I've tried substituting an ordinary NSTextFieldCell and  
I get the same outcome. Just to show, the code where I make the cell  
is:


Unfortunately, I don't know. Editing makes a copy of the cell, and  
sometimes people don't get the copying write, causing things to share  
data. It sounds like that isn't your issue.


I'd suggest overriding preparedCellAtColumn:row: and po'ing the  
resulting cell each time it is drawn.


Also, using -dataCellForColumn:row: is a better approach than changing  
the datacell on the tablecolumn.


corbin


___

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

Please do not post 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: Newbie scroll view problem

2008-12-18 Thread Graham Cox


On 19 Dec 2008, at 10:57 am, Andy Bettis wrote:

In my app I have an NSScrollView that contains a simple NSView in  
which I add other NSView subclass objects. All works well until the  
window (and hence the scroller) is resized - making it smaller is OK  
but if it is made bigger than the original (IB) size my added views  
migrate down the window. I've tried adjusting the autosizing  
settings but to no avail.


I'm trying not to have to subclass the containing view, I just want  
the scroller to reveal more of it as it is enlarged while leaving my  
subviews aligned to the top left corner. Do I need to flip the  
coordinates to keep them up there? I'll probably end up limiting the  
maximum window size so the user can't make it too big but I'd like  
to know what's going on.



One thing I've noticed in this sort of situation is that the "simple  
view" will typically need to be flipped, which requires subclassing,  
just for that one setting. Otherwise the scroller that contains it  
starts off scrolled to the bottom, which is not usually what you want.


Also, remember that the subviews are positioned relative to the bounds  
of the "simple view", which presumably is of some fixed size which is  
why you want to scroll it. If this view isn't flipped everything will  
be positioned relative to the bottom left corner. That should be OK,  
but given the behaviour of NSScrollView when it contains a non-flipped  
view, I think that's why you're seeing the views move around.


Just try flipping the "simple view".

hth,

Graham


___

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

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

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

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


Re: CLLocationDistance contents?

2008-12-18 Thread David Duncan

On Dec 18, 2008, at 4:14 PM, Jacob Rhoden wrote:

Hi Guys, I am doing the following to find a distance between two  
locations:


CLLocation* venueLocation = [[CLLocation alloc] initWithLatitude:  
venue.latitude longitude:venue.longditude];
CLLocationDistance distance = [venueLocation  
getDistanceFrom:currentLocation];


Is distance in metres/miles/km? How do I display it on screen in a  
platform independent way? I cant find any examples in the developer  
centre thingy.



From the documentation of -getDistanceFrom:
"Returns the distance (in meters) from the receiver’s coordinate to  
the coordinate of the specified location."

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


NSTrackingAreas, mouse entered/exited not firing

2008-12-18 Thread Randall Meadows
Yet another simple operation I've apparently managed to miss something  
with...


I have an NSTableView subclass (actually, a subclass of  
BGHUDTableView), that contains a bunch of custom cells.  For a couple  
types of those cells, I want to switch the cursor while it's in that  
cell.  I'm following the code in the PhotoSearch sample project that's  
been mentioned here a couple times recently.


I've overridden -updateTrackingAreas in my table class, and I can see  
it adding the correct rect relative to the appropriate view, with  
options (NSTrackingEnabledDuringMouseDrag |  
NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways).


I've called [[self window] setAcceptsMouseMovedEvents:YES]; from the  
table subclass's -awakeFromNib.


But -mouse[Entered|Exited]: is not being called when I move the mouse  
into those areas.


On a whim I even overrode -acceptsFirstResponder to return YES, but  
still no joy.


Any ideas?


Thanks.
randy
___

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

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


download security hanging app

2008-12-18 Thread Robert Clair

I have an app that puts up a registration window if it is not
registered when it starts. (The usual 30 day buy later / by now /
enter license kind of thing.) The app is distributed by downloading a
dmg.

I put the window up with:

[NSApp runModalForWindow: licensePanel];

which is called from

- (void)applicationDidFinishLaunching:(NSNotification *)notification

The problem is (not sure when this started, it's just been reported)
that when it is started the first time after downloading, the "x
is an Application which was downloaded from the internet warning"
screws things up. After clicking on "open" the warning dismisses, but
the license window never becomes visible. Since it isn't visible, it
can't be dismissed and things are hung.

If you kill the app and start it again it runs fine.

Anybody have any ideas ?

TIA

Bob
___

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

Please do not post 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: CLLocationDistance contents?

2008-12-18 Thread Jacob Rhoden


CLLocation* venueLocation = [[CLLocation alloc] initWithLatitude: 
venue.latitude longitude:venue.longditude];
CLLocationDistance distance = [venueLocation 
getDistanceFrom:currentLocation];


Is distance in metres/miles/km? How do I display it on screen in a 
platform independent way?

On 19/12/08 11:42 AM, David Duncan wrote:

From the documentation of -getDistanceFrom:
"Returns the distance (in meters) from the receiver’s coordinate to 
the coordinate of the specified location."


Thanks Duncan! Why do people always seem to be able to find stuff in the 
documentation. When I "Option + Mouse double click" on 
"CLLocationDistance" Xcode only shows me this!


CLLocationDistance
A distance measurement from an existing location.

typedef double CLLocationDistance;
Availability
Available in iPhone OS 2.0 and later.
Declared In
CLLocation.h

___

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

Please do not post 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: CLLocationDistance contents?

2008-12-18 Thread Roland King

try searching for 'Full-Text'.

But the documentation is correct either way. A CLLocationDistance  
itself isn't necessarily in meters, it's just a double. The functions  
which return it, like getDistanceFrom: and the altitude property tell  
you what it means and tells you that it's in meters.


check the function documentation as well as the type info.

On Dec 19, 2008, at 10:22 AM, Jacob Rhoden wrote:



CLLocation* venueLocation = [[CLLocation alloc] initWithLatitude:  
venue.latitude longitude:venue.longditude];
CLLocationDistance distance = [venueLocation  
getDistanceFrom:currentLocation];


Is distance in metres/miles/km? How do I display it on screen in a  
platform independent way?

On 19/12/08 11:42 AM, David Duncan wrote:

From the documentation of -getDistanceFrom:
"Returns the distance (in meters) from the receiver’s coordinate to  
the coordinate of the specified location."


Thanks Duncan! Why do people always seem to be able to find stuff in  
the documentation. When I "Option + Mouse double click" on  
"CLLocationDistance" Xcode only shows me this!


   CLLocationDistance
   A distance measurement from an existing location.

   typedef double CLLocationDistance;
   Availability
   Available in iPhone OS 2.0 and later.
   Declared In
   CLLocation.h

___

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

Please do not post 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/rols%40rols.org

This email sent to r...@rols.org


___

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

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

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

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


Re: Performance of calculation on float point numbers in a array • NSNumber in NSArray, or classi c C array?

2008-12-18 Thread Martin Wierschin

If I have to optimise something later, I will do it.


You can take advantage of Objective-C's categories to make future  
optimization an easier task. For example, rather than coding:


for( unsigned ii = 0; ii < count; ii++ ) {
sum += [[array objectAtIndex:ii] floatValue];
}

Instead do:

@interface NSArray (MYStatsAdditions)
- (float) floatAtIndex:(unsigned)idx ;
@end

@implementation NSArray (MYStatsAdditions)
- (float) floatAtIndex:(unsigned)idx
{
return [[self objectAtIndex:idx] floatValue];
}
@end

for( unsigned ii = 0; ii < count; ii++ ) {
sum += [array floatAtIndex:ii];
}

Then later you can just pop in a custom NSObject subclass that  
implements "floatAtIndex" backed by a plain C array without changing  
any other code. You could even take this a step further by (perhaps  
abusing) categories to add:


@interface NSArray (MYStatsAdditions)
- (float) floatAtIndex:(unsigned)idx ;
- (float) floatSum ;
- (float) floatMedian ;
// etc
@end

At that point it would probably be worth creating a custom object  
(eg: MYStatsVector), initially backed by a normal NSArray and only  
changing the guts to a plain C array later if needed.


~Martin

___

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

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

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

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


Re: download security hanging app

2008-12-18 Thread Geoff Beier
On Thu, Dec 18, 2008 at 8:05 PM, Robert Clair  wrote:
> [NSApp runModalForWindow: licensePanel];
>
> which is called from
>
> - (void)applicationDidFinishLaunching:(NSNotification *)notification
>
> The problem is (not sure when this started, it's just been reported)
> that when it is started the first time after downloading, the "x
> is an Application which was downloaded from the internet warning"
> screws things up. After clicking on "open" the warning dismisses, but
> the license window never becomes visible. Since it isn't visible, it
> can't be dismissed and things are hung.
>
> If you kill the app and start it again it runs fine.
>
> Anybody have any ideas ?
>

Have you tried launching your license panel from your main window
delegate's -windowDidBecomeKey method instead? IIRC that doesn't
happen till after the warning is dismissed.

HTH,

Geoff
___

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

Please do not post 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: download security hanging app

2008-12-18 Thread Andrew Farmer

On 18 Dec 08, at 19:27, Geoff Beier wrote:
On Thu, Dec 18, 2008 at 8:05 PM, Robert Clair   
wrote:

[NSApp runModalForWindow: licensePanel];

which is called from

- (void)applicationDidFinishLaunching:(NSNotification *)notification

The problem is (not sure when this started, it's just been reported)
that when it is started the first time after downloading, the "x
is an Application which was downloaded from the internet warning"
screws things up. After clicking on "open" the warning dismisses, but
the license window never becomes visible. Since it isn't visible, it
can't be dismissed and things are hung.

If you kill the app and start it again it runs fine.

Anybody have any ideas ?



Have you tried launching your license panel from your main window
delegate's -windowDidBecomeKey method instead? IIRC that doesn't
happen till after the warning is dismissed.


I'm pretty sure that your application isn't launched at all until the  
warning is dismissed, so where you display a splashscreen from  
shouldn't make a difference.

___

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

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


NSAppleScript returns wrong result on multiple Safari windows, applescript editor works

2008-12-18 Thread Craig Williams



From: Jot Kali 
Date: December 18, 2008 2:54:30 PM MST
To: Cocoa-dev@lists.apple.com
Subject: NSAppleScript returns wrong result on multiple Safari  
windows, applescript editor works



Hello,

I'm trying to get the URL of whatever is the front window / selected  
tab in Safari. But for multiple windows it does not work.


Say the user opens a window in Safari and navigates to apple.com,  
opens a tab and goes to nytimes.com, opens a NEW window and goes to  
arstechnica.com


If I run this script in Script Editor it works every time, returns  
arstechnica.com (the URL of the new front window) :


tell application "Safari"
return URL of front document as string
end tell


However if I do this in my Cocoa app :

NSDictionary *dict;
   NSAppleEventDescriptor *result;

	NSAppleScript *script = [[NSAppleScript alloc] initWithSource:  
@"\ntell application \"Safari\"\n\tget URL of front document \nend  
tell\n"];

   result = [script executeAndReturnError:&dict];

   [script release];

   if ((result != nil) && ([result descriptorType] != kAENullEvent))  
{;

   NSLog (@"URL %@", [result stringValue]);   
   }


It returns nytimes.com. It always returns the last tab of the FIRST  
window that was opened in safari. I have to close that window to get  
it to return the actual front most window site arstechnica.com.


I tried both 'front document' and 'document 1', both no go.

Any hints on what is going wrong?

thanks.



Try this.

@"\ntell application \"Safari\" to tell current tab of window 1 to  
return get URL\n"


Window 1 is always the frontmost window. I have had better results  
targeting it instead of the document.


Cheers,

Craig
___

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

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


  1   2   >