Re: Debugging problem

2010-03-03 Thread Laurent Daudelin
I tried setting a breakpoint on [NSException raise]. Didn't try on the [NSURL 
initWithString:baseURL:] but I'll try it tomorrow. Maybe that will help.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

On Mar 3, 2010, at 22:46, Laurent Cerveau wrote:

> Did you try to break on -[NSException raise] or on the NSURL initWithString 
> method?
> 
> Laurent
> 
> Sent from my road phone
> 
> 
> On Mar 4, 2010, at 4:24 AM, Laurent Daudelin  
> wrote:
> 
>> I'm trying to debug a problem where an NSOutlineView, as part of a drag, 
>> tries to create an instance of NSURL using "- (id)initWithString:(NSString 
>> *)URLString relativeToURL:(NSURL *)baseURL" with a nil string and get the 
>> following error:
>> 
>> *** Ignoring exception 'NSInvalidArgumentException' (reason '*** -[NSURL 
>> initWithString:relativeToURL:]: nil string parameter') raised by 
>>  during a dragging session
>> 
>> It happens *after* I write the dragging items to a NSFilesPromisePboardType 
>> pasteboard type. I have no idea where this NSURL is created.
>> 
>> I have tried to create a subclass of NSURL and make that class to pose as 
>> NSURL but then, I'm getting all kind of unknown messages sent to instances 
>> of various classes like:
>> 
>> -[NSCFString absoluteURL]: unrecognized selector sent to instance 0x30e940
>> or
>> -[%NSURL length]: unrecognized selector sent to instance 0x503930
>> 
>> I also set a future break on [NSException raise] but it's doesn't break on 
>> that call.
>> 
>> How can I find where this initWithString:relativeToURL: comes from? The 
>> problem is that it doesn't always happen. I tried to reproduce it but so 
>> far, I'm not sure what I'm doing different that will trigger the bug. The 
>> drag is from my app to the Finder. If I drag from within my app, the error 
>> never occurs. It really seems to be with the NSFilesPromisePboardType 
>> pasteboard type that this happens.
>> 
>> Anybody have any suggestion?
>> 
>> Thanks in advance!
>> 
>> -Laurent.
>> -- 
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelinhttp://nemesys.dyndns.org
>> Logiciels Nemesys Software  
>> laurent.daude...@gmail.com
>> Photo Gallery Store: 
>> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/lcerveau%40me.com
>> 
>> This email sent to lcerv...@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


Re: Debugging problem

2010-03-03 Thread Laurent Cerveau
Did you try to break on -[NSException raise] or on the NSURL  
initWithString method?


Laurent

Sent from my road phone


On Mar 4, 2010, at 4:24 AM, Laurent Daudelin  
 wrote:


I'm trying to debug a problem where an NSOutlineView, as part of a  
drag, tries to create an instance of NSURL using "- (id) 
initWithString:(NSString *)URLString relativeToURL:(NSURL *)baseURL"  
with a nil string and get the following error:


*** Ignoring exception 'NSInvalidArgumentException' (reason '*** - 
[NSURL initWithString:relativeToURL:]: nil string parameter') raised  
by  during a dragging session


It happens *after* I write the dragging items to a  
NSFilesPromisePboardType pasteboard type. I have no idea where this  
NSURL is created.


I have tried to create a subclass of NSURL and make that class to  
pose as NSURL but then, I'm getting all kind of unknown messages  
sent to instances of various classes like:


-[NSCFString absoluteURL]: unrecognized selector sent to instance  
0x30e940

or
-[%NSURL length]: unrecognized selector sent to instance 0x503930

I also set a future break on [NSException raise] but it's doesn't  
break on that call.


How can I find where this initWithString:relativeToURL: comes from?  
The problem is that it doesn't always happen. I tried to reproduce  
it but so far, I'm not sure what I'm doing different that will  
trigger the bug. The drag is from my app to the Finder. If I drag  
from within my app, the error never occurs. It really seems to be  
with the NSFilesPromisePboardType pasteboard type that this happens.


Anybody have any suggestion?

Thanks in advance!

-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelinhttp://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

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

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

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


Re: Returning a useful error from NSDocument's -readFromURL:...

2010-03-03 Thread Charles Srstka
On Mar 3, 2010, at 11:41 PM, Jerry Krinock wrote:

>> I could put all of the information into NSLocalizedDescriptionKey, but this 
>> looks horrible as it’s all in bold
> 
> Ah, yes.  That's another reason why I don't use Cocoa's error presentation.  
> I hate that boldface crap.

What’s wrong with NSLocalizedRecoverySuggestionErrorKey? Yeah, I know the name 
doesn’t make that much sense, but text you put in there does end up in the 
error box in regular, non-boldface type when Cocoa presents the error.

Charles___

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

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

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

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


Re: Returning a useful error from NSDocument's -readFromURL:...

2010-03-03 Thread Jerry Krinock

On 2010 Mar 03, at 13:52, Keith Blount wrote:

> So, here is my error-setting:



Assuming this code is in your -readFromURL:ofType:error: implementation, it 
looks OK to me, except that I'd suggest you give that error a nonempty domain 
and a nonzero code.  For the former, [[NSBundle mainBundle] bundleIdentifier] 
is a quick hack.  But I have no reason to believe that this will work any 
better.

> That works okay, except that the failure reason doesn’t get displayed.

Well Keith, what do you expect from a free implementation :))   I agree; the 
NSError presentation built into Cocoa is too way too wimpy.  Failure to display 
the failure reason is probably one of the many reasons why I wrote my own.

> The documentation clearly states that you can tell NSDocument not to present 
> an error by setting its domain to NSCocoaErrorDomain and its code to 
> NSUserCancelledError:

Yes, that is true.

> However, this simply doesn’t work for NSDocument’s -readFromURL:ofType:error: 
> I have tried to set outError as follows:
> 
> if (outError)
> *outError = [NSError errorWithDomain:NSCocoaErrorDomain 
> code:NSUserCancelledError userInfo:nil];

I'm not sure where you've put that code, but it's probably wrong.  Here is what 
works for me.  I subclass NSDocumentController and put the following override 
in that subclass.

- (NSError *)willPresentError:(NSError*)error {
[SSYAlert alertError:error] ;
return [NSError errorWithDomain:NSCocoaErrorDomain
   code:NSUserCancelledError
   userInfo:nil]  ;
}

In the above, SSYAlert is my alert class.  In this case, since the document 
failed to be created, there is no window to attach a sheet to, so it produces a 
dialog.

I suppose the idea is that, even though, according to "Message Flow in the 
Document Architecture", "The NSDocument object reads the contents of the file 
by sending the readFromURL:ofType:error: message to itself", the failed 
NSDocument instance fails to initialize and returns the error down the call 
stack to -[NSDocumentController initWithType:error:].

> I could put all of the information into NSLocalizedDescriptionKey, but this 
> looks horrible as it’s all in bold

Ah, yes.  That's another reason why I don't use Cocoa's error presentation.  I 
hate that boldface crap.

___

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

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

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

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


Core Data: UITableView moveRowAtIndexPath

2010-03-03 Thread PCWiz
I have an iPhone app and I'm trying to implement table row reordering and to 
still have it work with Core Data.

Here's my code:

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath 
*)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
if (fromIndexPath.section == toIndexPath.section) {
NSMutableArray *objectArray = [[[self fetchedResultsController] 
fetchedObjects] mutableCopy];
NSManagedObjectContext *context = [[self 
fetchedResultsController] managedObjectContext];
NSFetchedResultsController *frc = [self 
fetchedResultsController];
NSManagedObject *objectToMove = [[objectArray 
objectAtIndex:fromIndexPath.row] retain];
[objectArray removeObjectAtIndex:fromIndexPath.row];
[objectArray insertObject:objectToMove atIndex:toIndexPath.row];
[objectToMove release];

for (int i=0; i<[objectArray count]; i++)
{
[(NSManagedObject *)[objectArray objectAtIndex:i] 
setValue:[NSNumber numberWithInt:i] forKey:@"displayOrder"];
}
[objectArray release];

NSError *error;
BOOL success = [context save:&error];
if (!success)
{
UIAlertView *errorAlert = [[[UIAlertView alloc] 
initWithTitle:@"Error encountered while retrieving data." message:nil 
delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil] autorelease];
[errorAlert show];
NSLog(@"Unresolved error %@, %@", error, [error 
userInfo]);
}

success = [frc performFetch:&error];
if (!success)
{
UIAlertView *errorAlert = [[[UIAlertView alloc] 
initWithTitle:@"Error encountered while retrieving data." message:nil 
delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil] autorelease];
[errorAlert show];
NSLog(@"Unresolved error %@, %@", error, [error 
userInfo]);
}
}

I have an integer attribute in my entity called "displayOrder" that keeps track 
of the order in which the items should appear, and I have it set to sort using 
that key. In the above method I just update the displayOrder attribute for all 
objects, save the context, and perform a fetch again (to make sure that 
internally, everything is ordered the way the user rearranged the items)

The issue is that the above code doesn't seem to work at all. I move a row, and 
all sorts of UI chaos occurs. The row before the row I move disappears, the row 
I move takes its place, and everything just messes up altogether. What am I 
doing wrong here?

Thanks


___

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

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

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

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


Re: NSImageRep simple code

2010-03-03 Thread Martin Beroiz
Oh, thanks! I was missing that, now it works ok. I'll keep playing with this 
toy code.

M.

On Mar 3, 2010, at 11:02 PM, Graham Cox wrote:

> 
> On 04/03/2010, at 3:54 PM, Martin Beroiz wrote:
> 
>> bitsPerSample:8 
> 
>>  pixels[0] = 1;
>>  pixels[1] = 0;
>>  pixels[2] = 0;
>>  pixels[3] = 0;
> 
>> The docs say that NSDeviceWhiteColorSpace has pure white at 1.0, so I'm 
>> guessing that pixels[0] = 1 will set a white pixel, am I wrong?
> 
> 
> Yes. Because you're setting the pixel buffer values directly, you need to set 
> the 8 bits you asked for. So value 0 is one end, value 255 is the other. 
> Pixels are not expressed directly as values in a colour space.
> 
> --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


Sorting contents of an NSCollectionView

2010-03-03 Thread Eli Bach
I have a core-data app, with a view that shows a managed object, along with an 
NSCollectionView displaying related managed objects in 1 column, all hooked 
together primarily with bindings.

This works fine (selecting different objects automatically updates the 
collectionview and I can add/edit/delete related objects).

However, I would like to present the related records in the same order each 
time, as well as have new objects appear in a predicable location (namely, at 
one 'end' of the collectionview.  I have an 'order' attribute, with NSInteger16 
values, that I want to sort on.

Just adding a NSSortDescriptor to the NSArrayController that the 
NSCollectionView gets it's managed objects from only partially works:

1) it ONLY does the sort if I have a button that changes the sort AFTER the 
array is fully populated.  Setting the sortDescriptor on the NSArrayController 
when the view loads, or even as the root managed object is changed, doesn't 
result in the collectionview being sorted

2) adding or deleting a related record [removing/adding objects for the 
collectionview] randomizes the order of the objects presented in the 
collectionview [either by calling add: on the NSArrayController or directly 
creating a new NSManagedObject for the relation].  The object is 
presented/removed, but the order is always rearranged randomly.

I've even tried (programmatically):
-add/delete record
-clear sort descriptor
-set sort descriptor

and it does do the sort.  It only applies the sort if I hit a button that 
changes the sortDescriptor on the NSArrayController AFTER the collectionview 
gets fully populated.

Any ideas on the best way to keep the nsarraycontroller and/or the 
nscollectionview sorted all the time?

Eli


___

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

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

Help/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: NSImageRep simple code

2010-03-03 Thread Graham Cox

On 04/03/2010, at 3:54 PM, Martin Beroiz wrote:

> bitsPerSample:8 

>   pixels[0] = 1;
>   pixels[1] = 0;
>   pixels[2] = 0;
>   pixels[3] = 0;

> The docs say that NSDeviceWhiteColorSpace has pure white at 1.0, so I'm 
> guessing that pixels[0] = 1 will set a white pixel, am I wrong?


Yes. Because you're setting the pixel buffer values directly, you need to set 
the 8 bits you asked for. So value 0 is one end, value 255 is the other. Pixels 
are not expressed directly as values in a colour space.

--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: Responding to kill signals with the run loop

2010-03-03 Thread Jamie Hardt
Thanks!

On Mar 3, 2010, at 7:28 PM, Ken Ferry wrote:

> In 10.6 you can also do this by setting a dispatch queue on which you want a 
> block invoked when a signal comes in.  If you give it the main dispatch 
> queue, that's like installing on the runloop of the main thread.
> 
> See .  
> 
> This is also nice because it's in _addition_ to signal handlers, not a 
> replacement for signal handlers, and more than one thing can register to be 
> notified about the signal.  
> 
> You still have to register a signal handler to avoid having the signal kill 
> your app.
> 
> -Ken
> 
> On Wed, Mar 3, 2010 at 6:13 PM, Dave Keck  wrote:
> This can be done using kevents. See the
> InstallHandleSIGTERMFromRunLoop function, here:
> 
>
> http://developer.apple.com/mac/library/samplecode/PreLoginAgents/listing2.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/kenferry%40gmail.com
> 
> This email sent to kenfe...@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


NSImageRep simple code

2010-03-03 Thread Martin Beroiz
Hello everyone,

I'm trying to understand how NSImageRep works, so I read the docs and came up 
with this simple code that seems to... do something. 

I'm confused about what's actually doing, I only see a big black block in my 
custom view. 

My intention is to make a 2x2 pixels image with different grayscale colors. For 
example one pixel black, the other white, etc, so I can see if it actually 
draws the array I'm passing in to NSImageRep.

I'm guessing that the 2x2 pixel image will scale to fit the entire view so I 
will see the pixels as big squares in the view.

Here's the relevant code:

@implementation PixelsView

- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
pixels = (unsigned char *)malloc(4*sizeof(*pixels));
aSimpleBitmap = [[NSBitmapImageRep alloc] 
initWithBitmapDataPlanes:&pixels 

  pixelsWide:2 

  pixelsHigh:2

   bitsPerSample:8 

 samplesPerPixel:1 

hasAlpha:NO 

isPlanar:NO 

  colorSpaceName:NSDeviceWhiteColorSpace 

 bytesPerRow:2

bitsPerPixel:8];
pixels[0] = 1;
pixels[1] = 0;
pixels[2] = 0;
pixels[3] = 0;

}
return self;
}

- (void)drawRect:(NSRect)dirtyRect {
NSRect bounds = [self bounds];
[NSGraphicsContext saveGraphicsState];  
[aSimpleBitmap drawInRect:bounds];  
[NSGraphicsContext restoreGraphicsState];
}
@end

The docs say that NSDeviceWhiteColorSpace has pure white at 1.0, so I'm 
guessing that pixels[0] = 1 will set a white pixel, am I wrong?

Xcode is not throwing any errors, but the view is not displaying what I expect. 
Since I don't fully understand bitmap images, is there anything obvious that 
I'm missing?



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: Responding to kill signals with the run loop

2010-03-03 Thread Ken Ferry
In 10.6 you can also do this by setting a dispatch queue on which you want a
block invoked when a signal comes in.  If you give it the main dispatch
queue, that's like installing on the runloop of the main thread.

See .

This is also nice because it's in _addition_ to signal handlers, not a
replacement for signal handlers, and more than one thing can register to be
notified about the signal.

You still have to register a signal handler to avoid having the signal kill
your app.

-Ken

On Wed, Mar 3, 2010 at 6:13 PM, Dave Keck  wrote:

> This can be done using kevents. See the
> InstallHandleSIGTERMFromRunLoop function, here:
>
>
> http://developer.apple.com/mac/library/samplecode/PreLoginAgents/listing2.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/kenferry%40gmail.com
>
> This email sent to kenfe...@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


Debugging problem

2010-03-03 Thread Laurent Daudelin
I'm trying to debug a problem where an NSOutlineView, as part of a drag, tries 
to create an instance of NSURL using "- (id)initWithString:(NSString 
*)URLString relativeToURL:(NSURL *)baseURL" with a nil string and get the 
following error:

*** Ignoring exception 'NSInvalidArgumentException' (reason '*** -[NSURL 
initWithString:relativeToURL:]: nil string parameter') raised by 
 during a dragging session

It happens *after* I write the dragging items to a NSFilesPromisePboardType 
pasteboard type. I have no idea where this NSURL is created.

I have tried to create a subclass of NSURL and make that class to pose as NSURL 
but then, I'm getting all kind of unknown messages sent to instances of various 
classes like:

-[NSCFString absoluteURL]: unrecognized selector sent to instance 0x30e940
or
-[%NSURL length]: unrecognized selector sent to instance 0x503930

I also set a future break on [NSException raise] but it's doesn't break on that 
call.

How can I find where this initWithString:relativeToURL: comes from? The problem 
is that it doesn't always happen. I tried to reproduce it but so far, I'm not 
sure what I'm doing different that will trigger the bug. The drag is from my 
app to the Finder. If I drag from within my app, the error never occurs. It 
really seems to be with the NSFilesPromisePboardType pasteboard type that this 
happens.

Anybody have any suggestion?

Thanks in advance!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

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

Help/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: Responding to kill signals with the run loop

2010-03-03 Thread Dave Keck
This can be done using kevents. See the
InstallHandleSIGTERMFromRunLoop function, here:


http://developer.apple.com/mac/library/samplecode/PreLoginAgents/listing2.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


Responding to kill signals with the run loop

2010-03-03 Thread Jamie Hardt
Is there a straightforward way, or a way through the Cocoa API, to treat 
signals like SIGTERM and SIGHUP as run loop sources and to handle them as 
events in the run loop?  Right now I install signal handlers during 
initialization and these just set flags that are tested on every spin thru the 
run loop, but this isn't perfect.___

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

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

Help/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: Click in Table [More Pilot Error]

2010-03-03 Thread David Blanton

The NSComBox was 'selectable' and  'editable'

turned that off and behaviour is correct

On Mar 3, 2010, at 6:06 PM, David Blanton wrote:


I have a window with an NSComboBox and anNSTableView

When first displayed the NSComboBox has focus

When I click in the NSTableView the NSComboBox action is called  
followed by should select row and selection changed delegate methods  
for the table being called


This does not seem correct to me

So, where might I be in error ?

-db
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.net




___

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

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

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

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


Re: Click in Table

2010-03-03 Thread Fritz Anderson
On 3 Mar 2010, at 7:06 PM, David Blanton wrote:

> When first displayed the NSComboBox has focus
> 
> When I click in the NSTableView the NSComboBox action is called followed by 
> should select row and selection changed delegate methods for the table being 
> called
> 
> This does not seem correct to me

Nothing you say seems surprising, so I have no impression of what you mean by, 
"This does not seem correct to me."

Which part does not seem correct? What did you expect? How does it affect what 
you meant to do? What did you mean to do?

You should have that '.' key repaired.

— F

___

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

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

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

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


Click in Table

2010-03-03 Thread David Blanton

I have a window with an NSComboBox and anNSTableView

When first displayed the NSComboBox has focus

When I click in the NSTableView the NSComboBox action is called  
followed by should select row and selection changed delegate methods  
for the table being called


This does not seem correct to me

So, where might I be in error ?

-db
___

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

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

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

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


Uninitialized rectangle??

2010-03-03 Thread slasktrattena...@gmail.com
Hi,

I once noticed that this code caused an assertion failure when placed
in awakeFromNib.

NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [[statusBar statusItemWithLength:26] retain];
NSRect frameRect = [[statusItem view] frame];
MyStatusItemView *theView = [[MyStatusItemView alloc] initWithFrame:frameRect];
[theView setDelegate:self];
[statusItem setView:theView];
[theView release];

I didn't think much about it then - I simply moved the code to
applicationDidFinishLaunching and everything was fine. But now I'm
told the app is crashing nevertheless, AFAIK under 10.5.8 only:

3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
-[MyStatusItemView initWithFrame:],
/SourceCache/AppKit/AppKit-949.54/AppKit.subproj/NSView.m:1099
3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
[View initWithFrame:].
3/2/10 3:13:38 PM com.apple.launchd[115]
([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt

It's definitely related to the app/nib not being up and ready to go.
I'm displaying a dialog on first run in awakeFromNib. When the dialog
is displayed (delaying the execution of this code), it works fine. On
second launch it's a no go.

How can the system status bar not be initialized at this point? It's
not even part of the nib...

F.
___

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

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

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

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


Re: Uninitialized rectangle??

2010-03-03 Thread Jens Alfke


On Mar 3, 2010, at 3:00 PM, fabian wrote:

Thanks for your replies. I understand that the -frame message is  
returning

garbage. What I don't understand is why statusBar, statusItem or the
statusItem's view is nil during (but not after) the unarchiving of  
the nib,

or (on 10.5.8) even shortly after NSApp is fully loaded. Or is it?


By the time -applicationDidFinishLaunching is called, everything  
should be up and running. During -awakeFromNib (of the main nib),  
things are iffier. You know that your outlets have been initialized,  
but you don't know that every other object's -awakeFromNib method has  
run yet.



It's definitely related to the app/nib not being up and ready to go.
I'm displaying a dialog on first run in awakeFromNib. When the dialog




Putting up a dialog from within an -awakeFromNib method is a really,  
really, bad idea. (If it's a modal dialog, add three or four more  
"really"s.) You should either do the check later, or a delayed-perform  
so the dialog is only displayed after the app is initialized.


—Jens___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Ken Ferry
On Wed, Mar 3, 2010 at 8:50 AM, Eric Gorr  wrote:

>
> >> So, how certain is it that it will _only_ be called if the user presses
> the close (red) button?
> >
> > It's also called if the user chooses the Close menu command or presses
> Cmd-W.
>
> Good to know.


You should also consider AppleScript and assistive applications.

-Ken
___

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

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

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

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


Re: Uninitialized rectangle??

2010-03-03 Thread fabian
Thanks for your replies. I understand that the -frame message is returning
garbage. What I don't understand is why statusBar, statusItem or the
statusItem's view is nil during (but not after) the unarchiving of the nib,
or (on 10.5.8) even shortly after NSApp is fully loaded. Or is it? If I
can't know for sure that NSApp really did finish launching when this
delegate method is called, what's the point of having it at all? What I'd
like is a -applicationReallyTrulyDidFinishLaunchingNoKidding notification,
so I can instantiate the status bar item without having to worry about it
mysteriously being nil at the time.

So, I don't know. Should I put a timer in -applicationDidFinishLaunching and
create the status bar item after a short delay? If so, how long? Is 1 second
enough? Two seconds? It seems all I can do is guess, as there is no
mentioning of any of this in the docs.

Or should I go with Steven's advice, and feed the status item with a dummy
view first? What difference would it make?


On Wed, Mar 3, 2010 at 9:14 PM, Ken Thomases  wrote:

> On Mar 3, 2010, at 1:23 PM, fabian wrote:
>
> > I once noticed that this code caused an assertion failure when placed
> > in awakeFromNib.
> >
> > NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
> > statusItem = [[statusBar statusItemWithLength:26] retain];
> > NSRect frameRect = [[statusItem view] frame];
> > MyStatusItemView *theView = [[MyStatusItemView alloc]
> > initWithFrame:frameRect];
> > [theView setDelegate:self];
> > [statusItem setView:theView];
> > [theView release];
> >
> > I didn't think much about it then - I simply moved the code to
> > applicationDidFinishLaunching and everything was fine. But now I'm
> > told the app is crashing nevertheless, AFAIK under 10.5.8 only:
> >
> > 3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
> > -[MyStatusItemView initWithFrame:],
> > /SourceCache/AppKit/AppKit-
> > 949.54/AppKit.subproj/NSView.m:1099
> > 3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
> > [View initWithFrame:].
> > 3/2/10 3:13:38 PM com.apple.launchd[115]
> > ([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt
> >
> > It's definitely related to the app/nib not being up and ready to go.
> > I'm displaying a dialog on first run in awakeFromNib. When the dialog
> > is displayed (delaying the execution of this code), it works fine. On
> > second launch it's a no go.
> >
> > How can the system status bar not be initialized at this point? It's
> > not even part of the nib...
>
> Probably, the -frame message is being sent to nil.  That could happen if
> statusBar, statusItem, or the statusItem's view is unavailable at the point
> where you're trying to access it.
>
> For some messages, messaging nil gives you a well-defined result (0).  But
> for messages which return a struct, you get ill-defined results (garbage).
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW7
>
> Regards,
> Ken
>
>
___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Scott Ribe
> However, this did not seem to work as I might have expected. My window
> controller no longer receives the window will close notification, for example.

You're taking over the close button's responsibilities, but not doing
everything it does.

Start with:

NSButton *b = [[self window] standardWindowButton: NSWindowCloseButton];
closeSel = [b action];
closeTarget = [[b target] retain];
[b setAction: @selector( loggedClose: )];
[b setTarget: self];

Then in your close handler:

// do whatever you need to do in addition to the normal close here
NSButton *b = [[self window] standardWindowButton: NSWindowCloseButton];
[b setAction: closeSel];
[b setTarget: closeTarget];
[[self window] performClose: sender];
[closeTarget autorelease];

It's generally an awful thing to do, but I had to debug some issues around
window closing...

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


Returning a useful error from NSDocument's -readFromURL:...

2010-03-03 Thread Keith Blount
Hello,

Okay, I know this comes up a lot, but I can't find a single page with a 
satisfactory solution. Please feel free to post nothing but a link with the 
solution if I have missed the bloomin’ obvious, of course - this question has 
been asked here before and in other places, and it seems as though it should be 
simple, but nothing I try is entirely satisfactory:

My app overrides NSDocument's -readFromURL:ofType:error: to load its data. For 
the different circumstances in which the load might fail, I want to present to 
the user an alert panel explaining the reason for the failure. This, as I 
understand it, is the entire purpose of NSError, except that in this 
circumstance it seems to be doing more harm than good and just doesn't work as 
it should.

First, let's say I want to say to the user, "Invalid XML Data". And underneath 
that, in smaller, message text, I want it to say something like, "The document 
cannot be loaded because the XML file contained invalid characters." So, here 
is my error-setting:

if (outError)
{
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
[userInfo setObject:NSLocalizedString(@"Invalid XML Data", @"") 
forKey:NSLocalizedDescriptionKey];
[userInfo setObject:NSLocalizedString(@"The document cannot be loaded because 
the XML file contained invalid characters.",nil) forKey: 
NSLocalizedFailureReasonErrorKey];

*outError = [NSError errorWithDomain:@"" code:0 userInfo:userInfo];
}

That works okay, except that the failure reason doesn’t get displayed.

I read somewhere that if you want the reason to appear, you have to use 
NSLocalizedRecoverySuggestionErrorKey instead of 
NSLocalizedFailureReasonErrorKey, and you have to call -presentError: directly 
in order for it to appear, and just cancel the error that would normally get 
displayed. And I’m sure this used to work, too, but it no longer seems to 
(possibly since 10.6, but I haven’t checked on an earlier system yet).

But even if calling -presentError: did work and I could use it to display the 
information I want, I would still have to cancel the error that would otherwise 
get displayed - and there doesn’t seem to be a way of doing this. A perfect 
solution for me would be to tell NSDocument not to display an error at all, and 
then I could display my own using NSRunAlertPanel(), adding any title and 
description I wanted. (Well, not “perfect” - perfect would be getting 
NSDocument to present a nice error that explains to the user what is wrong 
rather than keeping the information I give it to itself.)

The documentation clearly states that you can tell NSDocument not to present an 
error by setting its domain to NSCocoaErrorDomain and its code to 
NSUserCancelledError:

“he Application Kit presents errors through the NSApplication implementations 
of the presentError: and 
presentError:modalForWindow:delegate:didPresentSelector:contextInfo: methods 
declared by NSResponder. Those implementations silently ignore errors whose 
domain is NSCocoaErrorDomain and whose code is NSUserCancelledError.”

(This is from the “Error Handling in the Document Architecture” section of the 
Document-Based Applications Overview: 
http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Documents/Articles/ErrorHandling.html)

However, this simply doesn’t work for NSDocument’s -readFromURL:ofType:error: I 
have tried to set outError as follows:

if (outError)
*outError = [NSError errorWithDomain:NSCocoaErrorDomain 
code:NSUserCancelledError userInfo:nil];

But that results in an alert panel coming up saying nothing more than “Alert” - 
it still displays an error panel.

(I have also tried overriding -presentError: - even though the docs say you 
shouldn’t need to - but it seems this isn’t called in this case, which is 
unsurprising as the docs do say that NSApplication’s implementation is called.)

What is the correct way of handling this? It’s bad enough that the user has to 
see an error message at all (although on some occasions it may be used to tell 
the user that the project needs updating to a newer format, which is more 
common than genuine errors), without the error messages seeming unprofessional 
or unforthcoming in the information they provide. Of course, I could put all of 
the information into NSLocalizedDescriptionKey, but this looks horrible as it’s 
all in bold, and would then be one stream of text without a title. Really it 
should have a title telling the user succinctly that there has been an error an 
then some message text explaining more about the error and possibly what to do 
about it.

Suggestions/solutions/pointers/RTFM links much appreciated.

Many thanks in advance and 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.appl

Re: How a window was closed?

2010-03-03 Thread Graham Cox

On 04/03/2010, at 3:50 AM, Eric Gorr wrote:

>  Unfortunately, that knowledge won't help me solve the problem in front of me

But it might help if you told us what the problem in front of you actually was. 
A simple and obvious solution might then become clear.

> nor would I be able to do anything about it at this time, if true.

You never know.

Reading this thread it definitely sounds like a very strange thing to need to 
do. Sometimes there is a 'wood for the trees' situation where a programmer has 
become so fixated on a hack they've missed the bigger picture, which is likely 
to have a far more straightforward and simple solution that won't be difficult 
to implement.

Put it this way: apps don't typically need to know why a window is being 
closed. More generally, object methods shouldn't need to know who called them. 
The reason you're finding it awkward/difficult to do is because it's 
unnecessary.

--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: xcode-debug style toolbar above editor area

2010-03-03 Thread Mazen M. Abdel-Rahman
Thanks for the quick reply.  My understanding was that NSToolBar is 
specifically meant for windows - i.e. it would get attached to an NSWindow.  
The "tool bar" I am referring to in xcode is either a view or attached to a 
view - and not to a window.  At least that's what it seems like to me.

Thanks,
Mazen

On Mar 3, 2010, at 1:17 PM, Abhinay Kartik Reddyreddy wrote:

> Look for NSToolbar in Interface Builder...
> 
> 
> On Mar 3, 2010, at 2:01 PM, Mazen M. Abdel-Rahman wrote:
> 
>> Hi All,
>> 
>> Thanks to everyone for helping me with my previous question.  I had another 
>> one though.
>> 
>> When in a debugging session in xcode - but not in the main debug view - a 
>> small "toolbar" appears above the editor.  In my case it's between the 
>> editor and the the file name list, and contains debug command buttons (step 
>> into, step through, etc.) as well as one button to open the debugger view 
>> and another to open the debugger console.
>> 
>> My question is what is the best way to copy this style?  Is it simply a 
>> custom NSView with the background set (in code) to grey?  That is my 
>> assumption but I thought I would ask.
>> 
>> Thanks!
>> Mazen Abdel-Rahman
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
>> 
>> This email sent to karthikredd...@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


NSBrowser + Core Data Woes

2010-03-03 Thread Karl Moskowski
I'm manually populating an in-memory CD store with a hierarchy of objects and 
binding them to a NSBrowser via a NSTreeController. Everything displays fine, 
but now I'm trying to get at the underlying managed object; I use a custom 
NSBrowserCell that has a checkbox next to the name, and the MO has a state 
attribute that corresponds to it.

I've implemented
- (void) browser:(NSBrowser *)sender 
willDisplayCell:(CleanupBrowserCell *)cell
atRow:(NSInteger)row column:(NSInteger)column;
in my delegate. I have a fetch request in my CD model to get the objects for a 
given path. However, [sender path] is never found - I'm not sure, but it looks 
like that's UTF-16 internally, but the MO stores its path as UTF-8 and there's 
never a match.

I've also tried using the various selection methods in the NSTreeController, 
but they don't seem to return anything useful.

Once populated, I won't be doing any modifications to the tree of objects. It's 
just for choosing a number of objects on which to do further work.

Any pointers would be appreciated. Thanks.


Karl Moskowski 
Voodoo Ergonomics Inc. 



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

Uninitialized rectangle??

2010-03-03 Thread slasktrattena...@gmail.com
Hi,

I once noticed that this code caused an assertion failure when placed
in awakeFromNib.

NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [[statusBar statusItemWithLength:26] retain];
NSRect frameRect = [[statusItem view] frame];
MyStatusItemView *theView = [[MyStatusItemView alloc] initWithFrame:frameRect];
[theView setDelegate:self];
[statusItem setView:theView];
[theView release];

I didn't think much about it then - I simply moved the code to
applicationDidFinishLaunching and everything was fine. But now I'm
told the app is crashing nevertheless, AFAIK under 10.5.8 only:

3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
-[MyStatusItemView initWithFrame:],
/SourceCache/AppKit/AppKit-949.54/AppKit.subproj/NSView.m:1099
3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
[View initWithFrame:].
3/2/10 3:13:38 PM com.apple.launchd[115]
([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt

It's definitely related to the app/nib not being up and ready to go.
I'm displaying a dialog on first run in awakeFromNib. When the dialog
is displayed (delaying the execution of this code), it works fine. On
second launch it's a no go.

How can the system status bar not be initialized at this point? It's
not even part of the nib...

F.
___

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

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

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

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


Re: xcode-debug style toolbar above editor area

2010-03-03 Thread Abhinay Kartik Reddyreddy
Look for NSToolbar in Interface Builder...


On Mar 3, 2010, at 2:01 PM, Mazen M. Abdel-Rahman wrote:

> Hi All,
> 
> Thanks to everyone for helping me with my previous question.  I had another 
> one though.
> 
> When in a debugging session in xcode - but not in the main debug view - a 
> small "toolbar" appears above the editor.  In my case it's between the editor 
> and the the file name list, and contains debug command buttons (step into, 
> step through, etc.) as well as one button to open the debugger view and 
> another to open the debugger console.
> 
> My question is what is the best way to copy this style?  Is it simply a 
> custom NSView with the background set (in code) to grey?  That is my 
> assumption but I thought I would ask.
> 
> Thanks!
> Mazen Abdel-Rahman
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/karthikreddy09%40gmail.com
> 
> This email sent to karthikredd...@gmail.com

___

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

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

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

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


Re: Uninitialized rectangle??

2010-03-03 Thread Ken Thomases
On Mar 3, 2010, at 1:23 PM, fabian wrote:

> I once noticed that this code caused an assertion failure when placed
> in awakeFromNib.
> 
> NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
> statusItem = [[statusBar statusItemWithLength:26] retain];
> NSRect frameRect = [[statusItem view] frame];
> MyStatusItemView *theView = [[MyStatusItemView alloc]
> initWithFrame:frameRect];
> [theView setDelegate:self];
> [statusItem setView:theView];
> [theView release];
> 
> I didn't think much about it then - I simply moved the code to
> applicationDidFinishLaunching and everything was fine. But now I'm
> told the app is crashing nevertheless, AFAIK under 10.5.8 only:
> 
> 3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
> -[MyStatusItemView initWithFrame:],
> /SourceCache/AppKit/AppKit-
> 949.54/AppKit.subproj/NSView.m:1099
> 3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
> [View initWithFrame:].
> 3/2/10 3:13:38 PM com.apple.launchd[115]
> ([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt
> 
> It's definitely related to the app/nib not being up and ready to go.
> I'm displaying a dialog on first run in awakeFromNib. When the dialog
> is displayed (delaying the execution of this code), it works fine. On
> second launch it's a no go.
> 
> How can the system status bar not be initialized at this point? It's
> not even part of the nib...

Probably, the -frame message is being sent to nil.  That could happen if 
statusBar, statusItem, or the statusItem's view is unavailable at the point 
where you're trying to access it.

For some messages, messaging nil gives you a well-defined result (0).  But for 
messages which return a struct, you get ill-defined results (garbage).
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocObjectsClasses.html#//apple_ref/doc/uid/TP30001163-CH11-SW7

Regards,
Ken

___

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

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

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

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


Re: Uninitialized rectangle??

2010-03-03 Thread Steven Degutis
In this line:

NSRect frameRect = [[statusItem view] frame];

the method -view is returning nil, and thus so is -frame, which means
frameRect contains garbage (or NSZeroRect if you're lucky).

Create a dummy view and give it to the status item before asking for the
frame. Keep in mind, you will only get a value relative to the view's
superview, so that'll be useless too.

-Steven

On Wed, Mar 3, 2010 at 2:23 PM, fabian  wrote:

> Hi,
>
> I once noticed that this code caused an assertion failure when placed
> in awakeFromNib.
>
> NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
> statusItem = [[statusBar statusItemWithLength:26] retain];
> NSRect frameRect = [[statusItem view] frame];
> MyStatusItemView *theView = [[MyStatusItemView alloc]
> initWithFrame:frameRect];
> [theView setDelegate:self];
> [statusItem setView:theView];
> [theView release];
>
> I didn't think much about it then - I simply moved the code to
> applicationDidFinishLaunching and everything was fine. But now I'm
> told the app is crashing nevertheless, AFAIK under 10.5.8 only:
>
> 3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
> -[MyStatusItemView initWithFrame:],
> /SourceCache/AppKit/AppKit-
> 949.54/AppKit.subproj/NSView.m:1099
> 3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
> [View initWithFrame:].
> 3/2/10 3:13:38 PM com.apple.launchd[115]
> ([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt
>
> It's definitely related to the app/nib not being up and ready to go.
> I'm displaying a dialog on first run in awakeFromNib. When the dialog
> is displayed (delaying the execution of this code), it works fine. On
> second launch it's a no go.
>
> How can the system status bar not be initialized at this point? It's
> not even part of the nib...
>
> 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/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.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


Uninitialized rectangle??

2010-03-03 Thread fabian
Hi,

I once noticed that this code caused an assertion failure when placed
in awakeFromNib.

NSStatusBar *statusBar = [NSStatusBar systemStatusBar];
statusItem = [[statusBar statusItemWithLength:26] retain];
NSRect frameRect = [[statusItem view] frame];
MyStatusItemView *theView = [[MyStatusItemView alloc]
initWithFrame:frameRect];
[theView setDelegate:self];
[statusItem setView:theView];
[theView release];

I didn't think much about it then - I simply moved the code to
applicationDidFinishLaunching and everything was fine. But now I'm
told the app is crashing nevertheless, AFAIK under 10.5.8 only:

3/2/10 3:12:49 PM MyProcess[13261] *** Assertion failure in
-[MyStatusItemView initWithFrame:],
/SourceCache/AppKit/AppKit-
949.54/AppKit.subproj/NSView.m:1099
3/2/10 3:12:49 PM MyProcess[13261] Uninitialized rectangle passed to
[View initWithFrame:].
3/2/10 3:13:38 PM com.apple.launchd[115]
([0x0-0x104104].my.process[13261]) Exited abnormally: Interrupt

It's definitely related to the app/nib not being up and ready to go.
I'm displaying a dialog on first run in awakeFromNib. When the dialog
is displayed (delaying the execution of this code), it works fine. On
second launch it's a no go.

How can the system status bar not be initialized at this point? It's
not even part of the nib...

Thanks.
___

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

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

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

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


Re: running javascript from obj-C

2010-03-03 Thread Ryan Wilcox

On 3/3/10 at 7:14 PM, sweetpproducti...@gmail.com (Russell Gray) wrote:


And I was thinking of taking the approach, of feeding a javascript function to 
Safari:

function hide_elements(id)
{
document.getElementById(id).style.display="none";

}

where id would be fed to the script from the adblock list(An 
NSArray of NSStrings).  I don't know javascript, so need to 
figure out how to do this also)


What I was wanting to know, is how do I apply the javascript to Safari?
any help would be appreciated.


I wrote a series of blog articles on it. I was accessing WebKit 
from C++ at the time, and maybe the Objective-C wrappers have 
gotten better since I lasted looked at this (2007!), but here 
you go:


Calling JS functions from C++ with WebKit: 
Calling JS functions from C++ with WebKit Part 2: 

Getting/Setting JS Variables from C++ with WebKit: 


Hopefully these point you in the right direction, or helps you 
find the new/right API


Hope this helps,
_Ryan Wilcox
--
Wilcox Development Solutions:   
Providing People with Solutions   PGP: 0x2F4E9C31

___

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

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

Help/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: Trying to achieve aperture PopUp buttons

2010-03-03 Thread Gustavo Pizano
Hehehe,.. Im not that expert, when he has done its quite a nice expertise I 
wish I can reach in the mid term, so far, I will keep subclassing what I can 
and give my apps the proper Look and feel, depending on reqs.

G.

On Mar 3, 2010, at 5:39 PM, Sean McBride wrote:

> On 3/3/10 10:10 AM, Gustavo Pizano said:
> 
>> Hello Sean. I checked brandos framework, its impressive what he did, but
>> unfortunately  the menu its still aqua not lack, I will try asking a radar..
> 
> I agree BWToolKit is impressive, and so if he failed to do it, I suspect
> it's pretty hard.  Perhaps you could two could brainstorm together. :)
> 
> --
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com
> Mac Software Developer  Montréal, Québec, Canada
> 
> 

___

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

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

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

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


Re: running javascript from obj-C

2010-03-03 Thread Matt Neuburg
On Wed, 3 Mar 2010 11:14:01 +1100, Russell Gray
 said:
>What I was wanting to know, is how do I apply the javascript to Safari?

Safari implements an AppleScript command "do JavaScript". So you can do this
by sending Safari an Apple event. Operators are waiting to take your call.
:) m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

Help/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: Messaging Cocoa apps through Terminal

2010-03-03 Thread Matt Neuburg
On Wed, 3 Mar 2010 16:17:13 +, Ulai Beekam 
said:

>get the point. Just so the user (but mainly the developer for testing purposes)
>can somehow make the app do things that cannot be done in the UI.

This might be a reason to build some scriptability (AppleScript-type) into
the app. In fact, it is the usual reason. Granted, it might also be overkill
for your app. But it's a very good way to build in some "hidden"
preferences.

On the other hand if you are just saying you want to automate the choosing
of a certain menu item or pushing of a certain button 100 times, you could
use GUI scripting without bothering to make your app scriptable at all. GUI
scripting is a very good "poor man's" way to automate interface testing, and
on Cocoa apps it just works, out of the box, for most interfaces. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

Help/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: Help Book Icon in Xcode 3.2

2010-03-03 Thread Kyle Sluder
On Mar 3, 2010, at 10:34 AM, Gabriel Fernandez  
 wrote:


why don't YOU read that documentation and try it out? I wouldn't  
have asked if I didn't already search the archives, and oh yeah,  
forgot about GOOGLE! Smart-guy.


You made no indication that you had tried anything at all. If you  
can't find the answer in the documentation, or if you have followed  
the documentation and it isn't working, please mention that.


Perhaps I should have linked you to whathaveyoutried.com instead. Have  
you in fact followed the instructions in "Specifying a Help Book Icon?"


This list sustains too many fire-and-forget questions as it is. It is  
a very high-traffic list, and it is appreciated that people do their  
research before asking and show evidence they have done so, to  
eliminate unnecessary chatter.


--Kyle Sluder

My mistake on the lists - didn't realize there was such  
specialization.


On Mar 3, 2010, at 1:19 PM, Kyle Sluder wrote:


On Wed, Mar 3, 2010 at 7:18 AM, Gabriel Fernandez
 wrote:

How do you specify the Help Book Icon in Xcode 3.2?


This is cocoa-dev. If you have Xcode questions, they belong on
xcode-users. If you have help questions, they belong on
apple-help-authoring. Or you could just read the documentation.
http://lmgtfy.com/?q=help+book+icon+site%3Adeveloper.apple.com

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


xcode-debug style toolbar above editor area

2010-03-03 Thread Mazen M. Abdel-Rahman
Hi All,

Thanks to everyone for helping me with my previous question.  I had another one 
though.

When in a debugging session in xcode - but not in the main debug view - a small 
"toolbar" appears above the editor.  In my case it's between the editor and the 
the file name list, and contains debug command buttons (step into, step 
through, etc.) as well as one button to open the debugger view and another to 
open the debugger console.

My question is what is the best way to copy this style?  Is it simply a custom 
NSView with the background set (in code) to grey?  That is my assumption but I 
thought I would ask.

Thanks!
Mazen Abdel-Rahman
___

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

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

Help/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: Help Book Icon in Xcode 3.2

2010-03-03 Thread Matt Neuburg
On Wed, 3 Mar 2010 10:18:43 -0500, Gabriel Fernandez
 said:
>How do you specify the Help Book Icon in Xcode 3.2?

Did you read the docs? Search at Apple's site for "help book icon".

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

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

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


Arrow keys not working in NSTabView

2010-03-03 Thread David Alter
I have dynamically created a NSTabView and added NSTabViewItems to it. It
works with the exception of if the NSTabView has the focus I can not use the
right and left arrow keys to navigate to the other tabs. The arrow keys work
if I create the tab view with IB. I'm not sure what is different. I suspect
I did not turn on some setting when I instantiated my instance of NSTabView.
I'm having a hard time identifying what that setting might be. Does anyone
know why this might not be working?

To test this you need to set System Preference -> Keyboard -> "All
Controls". That allows all the control to get the focus.

thanks for the help
-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: Help Book Icon in Xcode 3.2

2010-03-03 Thread Kyle Sluder
On Wed, Mar 3, 2010 at 7:18 AM, Gabriel Fernandez
 wrote:
> How do you specify the Help Book Icon in Xcode 3.2?

This is cocoa-dev. If you have Xcode questions, they belong on
xcode-users. If you have help questions, they belong on
apple-help-authoring. Or you could just read the documentation.
http://lmgtfy.com/?q=help+book+icon+site%3Adeveloper.apple.com

--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: Messaging Cocoa apps through Terminal

2010-03-03 Thread has
Ulai Beekam wrote:

> How can I send messages to my Cocoa app through the terminal? Say something 
> like
> MyGreatMp3Player.app --sendAdvancedMessageThatIsNotInTheUI 
> create100EmptyPlaylists

I think the simplest way would be to write yourself a simple command line tool 
that uses Distributed Objects. I do this to control one of my own Cocoa-based 
apps from the command line. See:


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html

DO is no panacea, mind; e.g. see:


http://jens.mooseyard.com/2009/07/the-subtle-dangers-of-distributed-objects/

but if you understand and can work within its limitations, it's a very quick 
and easy way to get 'low-level' access to the known innards of Cocoa apps.

HTH

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Eric Gorr

On Mar 3, 2010, at 11:43 AM, Jens Alfke wrote:

> 
> On Mar 3, 2010, at 7:20 AM, Eric Gorr wrote:
> 
>>> Otherwise, you can make your class implement the NSWindow delegate method 
>>> -windowShouldClose:, which will also be called when the user tries to close 
>>> the window. 
>> 
>> This method is called after I press the close (red) button. My only concern 
>> here is that the method does not necessarily lend itself to be exclusively 
>> called at this time and it would be a problem if it was ever called if the 
>> window was being closed for any other reason.
> 
> No offense, but why do you need to distinguish between these? It might be a 
> bad user interface design — for example, have you considered that some 
> disabled users have trouble with precise gestures and use keyboard 
> equivalents whenever possible?

It is entirely possible that the general design of the code is poor. 
Unfortunately, that knowledge won't help me solve the problem in front of me 
nor would I be able to do anything about it at this time, if true. I suppose we 
could turn this into a discussion of the general design, but I was hoping to 
avoid that as it would simply not be practical to alter it at this time, but 
then, such things can be generally useful for future reference.

> I can assure you that -windowShouldClose: is only called in response to 
> direct user interaction, and is often used to put up a confirmation sheet.

This is good news. 

>> So, how certain is it that it will _only_ be called if the user presses the 
>> close (red) button?
> 
> It's also called if the user chooses the Close menu command or presses Cmd-W.

Good to know.

___

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

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

Help/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: running javascript from obj-C

2010-03-03 Thread Jens Alfke

On Mar 2, 2010, at 4:14 PM, Russell Gray wrote:

> And I was thinking of taking the approach, of feeding a javascript function 
> to Safari:
> 
> function hide_elements(id)
> {
> document.getElementById(id).style.display="none";
> }

You can do the same thing by calling the DOM API from Objective-C. WebFrame has 
an accessor to get the DOMDocument and you can then make the identical calls on 
that.

It's also possible to send JavaScript to a frame as a string, but that has more 
overhead since it has to be parsed and interpreted.

—Jens___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Jens Alfke

On Mar 3, 2010, at 7:20 AM, Eric Gorr wrote:

>> Otherwise, you can make your class implement the NSWindow delegate method 
>> -windowShouldClose:, which will also be called when the user tries to close 
>> the window. 
> 
> This method is called after I press the close (red) button. My only concern 
> here is that the method does not necessarily lend itself to be exclusively 
> called at this time and it would be a problem if it was ever called if the 
> window was being closed for any other reason.

No offense, but why do you need to distinguish between these? It might be a bad 
user interface design — for example, have you considered that some disabled 
users have trouble with precise gestures and use keyboard equivalents whenever 
possible?

I can assure you that -windowShouldClose: is only called in response to direct 
user interaction, and is often used to put up a confirmation sheet.

> So, how certain is it that it will _only_ be called if the user presses the 
> close (red) button?

It's also called if the user chooses the Close menu command or presses Cmd-W.

> With the old toolbox, one would receive a mouse down event and be able to 
> determine what window and what part of the window it belonged to. One of 
> these parts was "inGoAway". I just need the same information with the same 
> reliability.

You could examine [NSApp currentEvent] and see if it's a mouse event, if you 
really need to know.

—Jens___

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

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

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

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


Re: Trying to achieve aperture PopUp buttons

2010-03-03 Thread Sean McBride
On 3/3/10 10:10 AM, Gustavo Pizano said:

>Hello Sean. I checked brandos framework, its impressive what he did, but
>unfortunately  the menu its still aqua not lack, I will try asking a radar..

I agree BWToolKit is impressive, and so if he failed to do it, I suspect
it's pretty hard.  Perhaps you could two could brainstorm together. :)

--

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


___

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

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

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

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


Re: Messaging Cocoa apps through Terminal

2010-03-03 Thread Ken Thomases
On Mar 3, 2010, at 10:17 AM, Ulai Beekam wrote:

> How can I send messages to my Cocoa app through the terminal? Say something 
> like
> MyGreatMp3Player.app --sendAdvancedMessageThatIsNotInTheUI 
> create100EmptyPlaylists
> I suppose it's hard to do this on the .app since it's just a directory, but 
> you get the point. Just so the user (but mainly the developer for testing 
> purposes) can somehow make the app do things that cannot be done in the UI.
> In the example above, the app is being asked to create 100 empty playlists, 
> which could be useful to make sure that, say, the scrollbars are working 
> well, etc.
> How could I do something like this? First: How do I send messages to the app? 
> And second: How do I make my app detect these messages? Could I somehow do 
> this with NSNotificationCenter?

You _could_ use NSDistributedNotificationCenter from a custom-built Foundation 
tool, but that's not really the right way to go about it.

What you need to do is make your app scriptable.
http://developer.apple.com/documentation/Cocoa/Conceptual/Scriptability/

Once it's scriptable, you can run an AppleScript script from the command line 
using osascript.
http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/osascript.1.html

Cheers,
Ken

___

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

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

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

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


Messaging Cocoa apps through Terminal

2010-03-03 Thread Ulai Beekam

How can I send messages to my Cocoa app through the terminal? Say something like
MyGreatMp3Player.app --sendAdvancedMessageThatIsNotInTheUI 
create100EmptyPlaylists
I suppose it's hard to do this on the .app since it's just a directory, but you 
get the point. Just so the user (but mainly the developer for testing purposes) 
can somehow make the app do things that cannot be done in the UI.
In the example above, the app is being asked to create 100 empty playlists, 
which could be useful to make sure that, say, the scrollbars are working well, 
etc.
How could I do something like this? First: How do I send messages to the app? 
And second: How do I make my app detect these messages? Could I somehow do this 
with NSNotificationCenter?
Thanks, U.
_
Hotmail: Powerful Free email with security by Microsoft.
https://signup.live.com/signup.aspx?id=60969___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Eric Gorr
On Mar 3, 2010, at 10:41 AM, Glenn L. Austin wrote:

> On Mar 3, 2010, at 7:20 AM, Eric Gorr wrote:
> 
>> 
>> On Mar 2, 2010, at 6:42 PM, Jens Alfke wrote:
>> 
>>> 
>>> On Mar 2, 2010, at 3:32 PM, Eric Gorr wrote:
>>> 
 Is there any way to determine how a window was closed?
 I need to base what I do on whether or not a window will be closed by the 
 user pressing the close (red) button or some other way.
>>> 
>>> If you have an NSWindow subclass, you can override -performClose:, which is 
>>> called when the user takes action to close the window.
>> 
>> I tried this, but performClose: was not called after I pressed the close 
>> (red) button. The intent of this method seems to be to simulate the click, 
>> not respond to it.
>> 
>>> Otherwise, you can make your class implement the NSWindow delegate method 
>>> -windowShouldClose:, which will also be called when the user tries to close 
>>> the window. 
>> 
>> This method is called after I press the close (red) button. My only concern 
>> here is that the method does not necessarily lend itself to be exclusively 
>> called at this time and it would be a problem if it was ever called if the 
>> window was being closed for any other reason. So, how certain is it that it 
>> will _only_ be called if the user presses the close (red) button?
>> 
>> With the old toolbox, one would receive a mouse down event and be able to 
>> determine what window and what part of the window it belonged to. One of 
>> these parts was "inGoAway". I just need the same information with the same 
>> reliability.
>> 
>> Now, I suppose I could attach a carbon event handler to my window and ask 
>> for kEventClassWindow / kEventWindowClickCloseRgn events, but I was hoping 
>> to avoid this and am surprised that there isn't something as clear in Cocoa. 
> 
> Well, if you're trying to determine whether your window was closed by the 
> user and when it was closed by your code, you could simply set a flag in your 
> window delegate when you close the window by code.

Yes, a global variable could be used to track this as well, but was hoping to 
avoid that as it would be difficult to catch every possible location in the 
code which might close the window.

> If there's supposed to be a difference when your code closes the window, then 
> your code is going to have to do the extra work to notify the receiver.


Ok. I am still hoping this isn't true, but have now filed a bug report - 
rdar://7711380

Oh, the reason why I cannot use kEventClassWindow / kEventWindowClickCloseRgn 
is because according to the documentation,

Note that this event is
not sent for composited windows; the window close button view
handles the mouse-down event directly. To intercept a close
region click in a composited window, install a kEventControlClick
handler on the window’s close button view

So, now the question becomes how / if I can get a view from a NSButton onto 
which I could install this carbon event.

I suppose what might work is simply installing a generic click event on the 
window and then determining whether or not it was in the close button...






___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Glenn L. Austin
On Mar 3, 2010, at 7:20 AM, Eric Gorr wrote:

> 
> On Mar 2, 2010, at 6:42 PM, Jens Alfke wrote:
> 
>> 
>> On Mar 2, 2010, at 3:32 PM, Eric Gorr wrote:
>> 
>>> Is there any way to determine how a window was closed?
>>> I need to base what I do on whether or not a window will be closed by the 
>>> user pressing the close (red) button or some other way.
>> 
>> If you have an NSWindow subclass, you can override -performClose:, which is 
>> called when the user takes action to close the window.
> 
> I tried this, but performClose: was not called after I pressed the close 
> (red) button. The intent of this method seems to be to simulate the click, 
> not respond to it.
> 
>> Otherwise, you can make your class implement the NSWindow delegate method 
>> -windowShouldClose:, which will also be called when the user tries to close 
>> the window. 
> 
> This method is called after I press the close (red) button. My only concern 
> here is that the method does not necessarily lend itself to be exclusively 
> called at this time and it would be a problem if it was ever called if the 
> window was being closed for any other reason. So, how certain is it that it 
> will _only_ be called if the user presses the close (red) button?
> 
> With the old toolbox, one would receive a mouse down event and be able to 
> determine what window and what part of the window it belonged to. One of 
> these parts was "inGoAway". I just need the same information with the same 
> reliability.
> 
> Now, I suppose I could attach a carbon event handler to my window and ask for 
> kEventClassWindow / kEventWindowClickCloseRgn events, but I was hoping to 
> avoid this and am surprised that there isn't something as clear in Cocoa. 

Well, if you're trying to determine whether your window was closed by the user 
and when it was closed by your code, you could simply set a flag in your window 
delegate when you close the window by code.

If you're trying to determine the difference between closing the window using 
the close box and when using the menu item, choose the option that gives you 
the most "control" (e.g. set the menu item's target) and set a flag there.

In reality, it probably shouldn't really matter *why* the window is being 
closed, only that it's being closed.  If there's supposed to be a difference 
when your code closes the window, then your code is going to have to do the 
extra work to notify the receiver.

-- 
Glenn L. Austin, Computer Wizard and Race Car Driver <><

___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Eric Gorr

On Mar 3, 2010, at 10:20 AM, Eric Gorr wrote:

> 
> On Mar 2, 2010, at 6:42 PM, Jens Alfke wrote:
> 
>> 
>> On Mar 2, 2010, at 3:32 PM, Eric Gorr wrote:
>> 
>>> Is there any way to determine how a window was closed?
>>> I need to base what I do on whether or not a window will be closed by the 
>>> user pressing the close (red) button or some other way.
>> 
>> If you have an NSWindow subclass, you can override -performClose:, which is 
>> called when the user takes action to close the window.
> 
> I tried this, but performClose: was not called after I pressed the close 
> (red) button. The intent of this method seems to be to simulate the click, 
> not respond to it.
> 
>> Otherwise, you can make your class implement the NSWindow delegate method 
>> -windowShouldClose:, which will also be called when the user tries to close 
>> the window. 
> 
> This method is called after I press the close (red) button. My only concern 
> here is that the method does not necessarily lend itself to be exclusively 
> called at this time and it would be a problem if it was ever called if the 
> window was being closed for any other reason. So, how certain is it that it 
> will _only_ be called if the user presses the close (red) button?
> 
> With the old toolbox, one would receive a mouse down event and be able to 
> determine what window and what part of the window it belonged to. One of 
> these parts was "inGoAway". I just need the same information with the same 
> reliability.
> 
> Now, I suppose I could attach a carbon event handler to my window and ask for 
> kEventClassWindow / kEventWindowClickCloseRgn events, but I was hoping to 
> avoid this and am surprised that there isn't something as clear in Cocoa. 

Looks like I spoke to soon and should have tried the carbon event handler 
first. This does not work - the event is not generated.

___

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

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

Help/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: NSXMLDocument and threads

2010-03-03 Thread Jeff Johnson
On Mar 3, 2010, at 12:56 AM, Jens Alfke wrote:

> On Mar 2, 2010, at 10:18 PM, Jeff Johnson wrote:
> 
>> Thus, Apple's documentation gives every reason to believe that it is safe to 
>> use NSXMLDocument off the main thread, but libxml's documentation gives 
>> every reason to believe that it is not safe.
> 
> Treat NSXMLDocument as a black box and follow the docs. It's safe to use on 
> non-main threads. Have you run into actual problems with it?
> 
> —Jens

I haven't run into problems yet, but thread bugs are often subtle and difficult 
to reproduce.

I'm not comfortable with the black box attitude. There are thousands of known 
bugs in Cocoa. There are also a large number of known inaccuracies and 
omissions in the documentation. Thus, given what libxml says about thread 
safety, the fact that Apple's documentation does not warn about using 
NSXMLDocument on the main thread gives me little assurance, especially since 
NSXML classes are nowhere mentioned by name in the thread safety summary, 
unlike many other classes both safe and unsafe.

-Jeff

___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Eric Gorr

On Mar 2, 2010, at 6:42 PM, Jens Alfke wrote:

> 
> On Mar 2, 2010, at 3:32 PM, Eric Gorr wrote:
> 
>> Is there any way to determine how a window was closed?
>> I need to base what I do on whether or not a window will be closed by the 
>> user pressing the close (red) button or some other way.
> 
> If you have an NSWindow subclass, you can override -performClose:, which is 
> called when the user takes action to close the window.

I tried this, but performClose: was not called after I pressed the close (red) 
button. The intent of this method seems to be to simulate the click, not 
respond to it.

> Otherwise, you can make your class implement the NSWindow delegate method 
> -windowShouldClose:, which will also be called when the user tries to close 
> the window. 

This method is called after I press the close (red) button. My only concern 
here is that the method does not necessarily lend itself to be exclusively 
called at this time and it would be a problem if it was ever called if the 
window was being closed for any other reason. So, how certain is it that it 
will _only_ be called if the user presses the close (red) button?

With the old toolbox, one would receive a mouse down event and be able to 
determine what window and what part of the window it belonged to. One of these 
parts was "inGoAway". I just need the same information with the same 
reliability.

Now, I suppose I could attach a carbon event handler to my window and ask for 
kEventClassWindow / kEventWindowClickCloseRgn events, but I was hoping to avoid 
this and am surprised that there isn't something as clear in Cocoa. 




___

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

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

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

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


Help Book Icon in Xcode 3.2

2010-03-03 Thread Gabriel Fernandez
How do you specify the Help Book Icon in Xcode 3.2?



Gabriel Fernandez
Wheel Software

___

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

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

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

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


Re: How a window was closed?

2010-03-03 Thread Eric Gorr

On Mar 2, 2010, at 6:39 PM, Mike Abdullah wrote:

> 
> On 2 Mar 2010, at 23:32, Eric Gorr wrote:
> 
>> Is there any way to determine how a window was closed?
>> 
>> I need to base what I do on whether or not a window will be closed by the 
>> user pressing the close (red) button or some other way.
>> 
>> One thing I did try was:
>> 
>>  NSButton *closeButton = [[self window] 
>> standardWindowButton:NSWindowCloseButton];
>>  
>>  fCloseButtonTarget  = [[closeButton target] retain];
>>  fCloseButtonAction  = [closeButton action];
>>  
>>  [closeButton setTarget:self];
>>  [closeButton setAction:@selector(closeInterceptor:)];
>> 
>> basically, got the close button and attempted to insert my own close action 
>> selector which was implemented as:
>> 
>> - (void) closeInterceptor:(id)sender
>> {
>>  // my stuff here
>> 
>>  [NSApp sendAction:fCloseButtonAction to:fCloseButtonTarget 
>> from:sender]; 
>> }
> 
> Ack, horrible technique, not a good idea!

I agree, but I needed to try something. 

So, what is?

>> However, this did not seem to work as I might have expected. My window 
>> controller no longer receives the window will close notification, for 
>> example.
>> 
>> Any other thoughts?
> 
> What other ways of closing the window are you trying to distinguish it from?

Doing so directly with code.


___

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

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

Help/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: NSBezierPath EXC_BAD_ACCESS issues.

2010-03-03 Thread Graham Cox

On 04/03/2010, at 12:14 AM, Billy Flatman wrote:

> I'm new to Objective-C as you've probably gathered and am not 100% about how 
> the memory management works. Will I be causing a memory leek with the line:
> path = [[NSBezierPath alloc] bezierPath];
> within my initialiseBezierPath method?
> 


Well, it won't work because -bezierPath isn't an instance method of 
NSBezierPath, it's a class method.

Take a step back, read this. And then again. Until it clicks.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html

--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: NSBezierPath EXC_BAD_ACCESS issues.

2010-03-03 Thread Billy Flatman
Hi Graham,

Thanks for your help, I've implemented your suggestions and it's working great, 
I just have one quick question if you don't mind.

I'm new to Objective-C as you've probably gathered and am not 100% about how 
the memory management works. Will I be causing a memory leek with the line:
path = [[NSBezierPath alloc] bezierPath];
within my initialiseBezierPath method?

Thanks for your help,

Billy.

On 3 Mar 2010, at 12:48, Graham Cox wrote:

> Your setBezierPath method is making a new, autoreleased path, it isn't using 
> the one you created at initialisation. That is then autoreleased leaving 
>  stale, hence the crash. You're also leaking the first path you made.
> 
> If setBezierPath is there to simply set up the bezier path, it shouldn't make 
> another path, you already made it, but also it shouldn't be named 
> set... as it's not setting anything. Call it initialiseBezierPath 
> for example.
> 
> 
> --Graham
> 
> 
> 
> On 03/03/2010, at 11:34 PM, Billy Flatman wrote:
> 
>> Hi all,
>> 
>> I have a shape class containing an
>> 
>> attribute: 
>> NSBezierPath *path;
>> 
>> initialisation: 
>> path = [[NSBezierPath alloc] init];
>> [self setBezierPath];
>> 
>> setBezierPath:
>> path = [NSBezierPath bezierPath];
>> then add the paths and close path.
>> 
>> paint:
>> [path setLineWidth: 1];
>> [path fill];
>> 
>> It all worked well when I had the setBezierPath method called from paint, 
>> but since only calling setBezierPath in an update method and during 
>> initialisation, I've started getting a exc_bad_access exception when path is 
>> called in the paint method.
>> 
>> Any help would be greatly appreciated.
> 

Billy Flatman
b.flat...@googlemail.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: NSBezierPath EXC_BAD_ACCESS issues.

2010-03-03 Thread Graham Cox
Your setBezierPath method is making a new, autoreleased path, it isn't using 
the one you created at initialisation. That is then autoreleased leaving  
stale, hence the crash. You're also leaking the first path you made.

If setBezierPath is there to simply set up the bezier path, it shouldn't make 
another path, you already made it, but also it shouldn't be named 
set... as it's not setting anything. Call it initialiseBezierPath 
for example.


--Graham



On 03/03/2010, at 11:34 PM, Billy Flatman wrote:

> Hi all,
> 
> I have a shape class containing an
> 
> attribute: 
> NSBezierPath *path;
> 
> initialisation: 
> path = [[NSBezierPath alloc] init];
> [self setBezierPath];
> 
> setBezierPath:
> path = [NSBezierPath bezierPath];
> then add the paths and close path.
> 
> paint:
> [path setLineWidth: 1];
> [path fill];
> 
> It all worked well when I had the setBezierPath method called from paint, but 
> since only calling setBezierPath in an update method and during 
> initialisation, I've started getting a exc_bad_access exception when path is 
> called in the paint method.
> 
> Any help would be greatly 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


NSBezierPath EXC_BAD_ACCESS issues.

2010-03-03 Thread Billy Flatman
Hi all,

I have a shape class containing an

attribute: 
NSBezierPath *path;

initialisation: 
path = [[NSBezierPath alloc] init];
[self setBezierPath];

setBezierPath:
path = [NSBezierPath bezierPath];
then add the paths and close path.

paint:
[path setLineWidth: 1];
[path fill];

It all worked well when I had the setBezierPath method called from paint, but 
since only calling setBezierPath in an update method and during initialisation, 
I've started getting a exc_bad_access exception when path is called in the 
paint method.

Any help would be greatly appreciated.

Cheers,

Billy___

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

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

Help/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: Trying to achieve aperture PopUp buttons

2010-03-03 Thread Gustavo Pizano
Hello Sean. I checked brandos framework, its impressive what he did, but 
unfortunately  the menu its still aqua not lack, I will try asking a radar.. 

Regards
Gustavo


On Mar 2, 2010, at 10:49 PM, Sean McBride wrote:

> On 3/2/10 9:28 PM, Gustavo Pizano said:
> 
>> Have somebody used aperture? well if so, in the filter panel, the PopUp
>> buttons that appear there are black, and the background of the menu is
>> black as well.
> 
> 1) File a radar asking Apple to provide these HUD style controls.
> 
> 2) See if BWToolKit does what you need:
> 
> 
> --
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com
> Mac Software Developer  Montréal, Québec, Canada
> 
> 

___

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

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

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

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