Re: Accessing Variables from Multiple NIBs

2010-01-16 Thread Jon Buys
Well, before this goes any further, I'm going to go ahead and answer my own 
question here.

The problem is that in the code below, I'm actually instantiating two 
AppController objects, one in each NIB.  So, one AppController doesn't have any 
idea about the other AppController, and can't get to it's string.

The solution I've come up with is to replace my window controller class with a 
simple call to NSBundle to load the NIB, setting AppController as the owner of 
the second NIB.  Then, in IB, I set the identity of File's Owner to 
AppController, delete the NSObject, and bind the button to the IBAction in the 
File's Owner.  

It's great to solve my own problems, I just wish I'd do it before sending out 
to Cocoa-Dev for help!

-- Jon


On Jan 16, 2010, at 6:45 PM, Jonathan Buys wrote:

> Hello,
> 
> I have an AppController that looks like this:
> 
> AppController.h:
> #import 
> @class PostController;
> 
> @interface AppController : NSObject 
> {
>   PostController *postController;
>   NSString *theString;
> }
> 
> - (IBAction)setString:(id)sender;
> - (IBAction)viewString:(id)sender;
> 
> - (void)processString;
> 
> @end
> 
> AppController.m:
> 
> #import "AppController.h"
> #import "PostController.h"
> 
> @implementation AppController
> 
> 
> - (IBAction)setString:(id)sender
> {
>   // Is postController nil?
>   if (!postController) {
>   //  NSLog(@"Post Controller was nil.");
>   postController = [[PostController alloc] init];
>   }
>   
>   //  NSLog(@"Showing %@", postController);
>   [postController showWindow:self];
>   
>   theString = @"The String";
>   
>   NSLog(@"Current Selected Site: %@", theString); 
>   [self processString];
> }
> 
> - (IBAction)viewString:(id)sender
> {
>   NSLog(@"viewString Method: %@", theString);
>   [self processString];
> }
> 
> - (void)processString
> {
>   NSLog(@"processString Method: %@", theString);
> }
> 
> 
> @end
> 
> I have two XIB files, MainMenu and NewPost.  I've dragged an NSObject into 
> each XIB, and set it's class to AppController.  In MainMenu, I have two 
> buttons, one bound to the setString action, and one set to the processString 
> action.  In MainMenu XIB, I can see theString in the NSLog output.  In the 
> NewPost XIB, I have one button bound to the processString method, but from 
> this XIB, every time I run the processString method, theString is  null.  
> 
> How can I define a variable (like NSString) in one XIB, and be able to access 
> it from methods triggered from another XIB?
> 
> I've got a simple Xcode project that shows this problem, if it would help 
> with explaining it.
> 
> Thanks,
> 
> Jon
> 
> PS.  Here is the PostController too, just in case:
> 
> #import 
> 
> 
> @interface PostController : NSWindowController 
> {
> }
> 
> @end
> 
> 
> #import "PostController.h"
> #import "AppController.h"
> 
> 
> @implementation PostController
> 
> - (id)init
> {
>   if (![super initWithWindowNibName:@"NewPost"])
>   return nil;
>   
>   return self;
> }
> 
> 
> - (void)windowDidLoad
> {
>   NSLog(@"Nib file is loaded!");
> }
> 
> @end
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jonbuys%40me.com
> 
> This email sent to jonb...@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: Clipping subview drawing to arbitrary path or image (iPhone)

2010-01-16 Thread David Duncan
On Jan 15, 2010, at 5:07 PM, Rick Mann wrote:

> Hmm. I tried some experiments with your suggestion, and seemed to be getting 
> masking with the inverse of what I specified. So I looked at the docs for the 
> mask property, and there's this note: "iPhone OS Note: As a performance 
> consideration, iPhone OS does not support the mask property."

I'm not certain where you see that comment, but it is incorrect (with respect 
to iPhone OS 3.x – the mask property did not exist on 2.x).

As for the masking operation, it multiplies the alpha from the layer's contents 
against the layer to be masked, so if you have a mask filled with 0.75 alpha, 
then the layer's contents will be multiplied against 0.75. I suppose if you 
expect 0.75 to pass 25% of the image through, then yes it is opposite of what 
you expect :).

> It's clearly doing something, but it's not clear that it's doing what I want. 
> Oh. It's working in the simulator, I bet it won't work on the phone, and it 
> still causes a problem: it doesn't make the masked-out areas transparent.


I tested on an iPod Touch 2nd Gen and it works fine there, but keep in mind 
that the masking layer needs to be in the same coordinate space as the layer 
masked. Simplest way to do this is to assign the masking layer's frame the 
value of the layer to be mask's frame.
--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


How to show progress indicator for background job

2010-01-16 Thread Grant Christensen
Hi, apologies for having a wrong topic, replied instead of created a new 
message.

On 16/01/2010, at 11:25 PM, Grant Christensen wrote:

> Hi all,
> 
> Somewhat new to cocoa (Mac even) development, and I have a UI  layout 
> question that I am hoping to get some opinions on.
> 
> I have a single window application that contains both a toolbar and a bottom 
> bar.  The application periodically goes off and reads some data from a remote 
> server.  This is a process that may take up to five seconds, and I don't want 
> to make the user pause while it is occuring, so don't want to pop up a sheet 
> with a status or similar.
> 
> My first thought was to put a label in the bottom bar saying something like: 
> retrieving from server xxx, and also have a progress indicator.  However the 
> apple UI guidelines state not to use any controls in the bottom bar.
> 
> Can you think of any other Mac standard ways to show progress in a non 
> obtrusive mannor?  Just the status label alone may not be sufficient as there 
> would be no way to see if the process has stalled.
> 
> Thanks for any suggestions
> 
> Grant Christensen___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/grantch%40bigpond.net.au
> 
> This email sent to gran...@bigpond.net.au


---
Grant Christensen




___

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

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

Help/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: NSTextField sendActionOn:

2010-01-16 Thread Brad Stone
I tried that (textDidBeginEditing) but it fires only after the user hits a key 
to begin typing, not when they first enter the field (i.e. the action that 
makes the focus ring show up).  I want to be notified as soon as the user 
clicks in the field to get the cursor in there.  I was able to capture the 
mouseDown event in the field but only in a subclass which is causing me 
problems elsewhere.

On Jan 16, 2010, at 3:08 PM, Matthew Lindfield Seager wrote:

> On Sunday, January 17, 2010, Brad Stone  wrote:
>> The best I can do for the NSTextField is bind an action and in, IB, in the 
>> TextFieldAttributes set "Action" to "Sent on End Editing"  which sends the 
>> action after the first character is type.  I want the action sent as soon as 
>> the field gains focus.
> 
> Googling "nstextfield begin editing notification" without the quotes
> takes one straight to the fine manual. See textDidBeginEditing in
> particular.
> 
> Hope that is what you are after.
> 
> Regards,
> Matt

___

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

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

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

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


Accessing Variables from Multiple NIBs

2010-01-16 Thread Jonathan Buys
Hello,

I have an AppController that looks like this:

AppController.h:
#import 
@class PostController;

@interface AppController : NSObject 
{
PostController *postController;
NSString *theString;
}

- (IBAction)setString:(id)sender;
- (IBAction)viewString:(id)sender;

- (void)processString;

@end

AppController.m:

#import "AppController.h"
#import "PostController.h"

@implementation AppController


- (IBAction)setString:(id)sender
{
// Is postController nil?
if (!postController) {
//  NSLog(@"Post Controller was nil.");
postController = [[PostController alloc] init];
}

//  NSLog(@"Showing %@", postController);
[postController showWindow:self];

theString = @"The String";

NSLog(@"Current Selected Site: %@", theString); 
[self processString];
}

- (IBAction)viewString:(id)sender
{
NSLog(@"viewString Method: %@", theString);
[self processString];
}

- (void)processString
{
NSLog(@"processString Method: %@", theString);
}


@end

I have two XIB files, MainMenu and NewPost.  I've dragged an NSObject into each 
XIB, and set it's class to AppController.  In MainMenu, I have two buttons, one 
bound to the setString action, and one set to the processString action.  In 
MainMenu XIB, I can see theString in the NSLog output.  In the NewPost XIB, I 
have one button bound to the processString method, but from this XIB, every 
time I run the processString method, theString is  null.  

How can I define a variable (like NSString) in one XIB, and be able to access 
it from methods triggered from another XIB?

I've got a simple Xcode project that shows this problem, if it would help with 
explaining it.

Thanks,

Jon

PS.  Here is the PostController too, just in case:

#import 


@interface PostController : NSWindowController 
{
}

@end


#import "PostController.h"
#import "AppController.h"


@implementation PostController

- (id)init
{
if (![super initWithWindowNibName:@"NewPost"])
return nil;

return self;
}


- (void)windowDidLoad
{
NSLog(@"Nib file is loaded!");
}

@end

___

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

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

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

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


Re: needing help w/ asynchronous message problem, using YAMessageQueue

2010-01-16 Thread Grant Christensen
Hi all,

Somewhat new to cocoa (Mac even) development, and I have a UI  layout question 
that I am hoping to get some opinions on.

I have a single window application that contains both a toolbar and a bottom 
bar.  The application periodically goes off and reads some data from a remote 
server.  This is a process that may take up to five seconds, and I don't want 
to make the user pause while it is occuring, so don't want to pop up a sheet 
with a status or similar.

My first thought was to put a label in the bottom bar saying something like: 
retrieving from server xxx, and also have a progress indicator.  However the 
apple UI guidelines state not to use any controls in the bottom bar.

Can you think of any other Mac standard ways to show progress in a non 
obtrusive mannor?  Just the status label alone may not be sufficient as there 
would be no way to see if the process has stalled.

Thanks for any suggestions

Grant Christensen___

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

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

Help/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: NSDatePicker 24 hour clock (Daniel Wambold)

2010-01-16 Thread Wilfried Bernard
Hi,
I've read your post and in case you did not find a solution, this worked for me:
The trick is, you need to subclass NSDatePicker first like:

@interface TT24HourTimePicker : NSDatePicker {} @end

Then put the formatter in a new init phase of the implementation, like (use 
what ever format you like):

- (void)_init
{
NSLocale*   my24HourLocale = [[[NSLocale alloc] 
initWithLocaleIdentifier:@"uk"] autorelease];
NSDatePickerCell*   cell = [self cell];
[cell setLocale:my24HourLocale];
[cell setFormatter:[[[NSDateFormatter alloc] 
initWithDateFormat:@"%H:%M:%S" allowNaturalLanguage:NO] autorelease]];
[cell setTitle:@"00:00:00"];
}

...and if you want to load it in awakeFromNib call the new _init with:

- (id)initWithCoder:(NSCoder*)coder
{
self = [super initWithCoder:coder]; // NSDatePickerCell
if (!self) {
return nil;
}

// Common init
[self _init];

return self;
}

Hope this helps.

Cheers, Wilfried Bernard
On Jan 9, 2010, at 12:31 PM, cocoa-dev-requ...@lists.apple.com wrote:

> Hello. I have an NSDatePicker (NSTextFieldAndStepperDatePickerStyle) and I 
> need it to display time in a 24-hour time mode. After reading Apple's docs 
> and searching the Web, I can't seem to find a way to make this happen. I have 
> attached an NSDateFormatter in IB and specified 24-hour time (HH:MM), but the 
> program reverts back to a 12-hour clock. I changed my System Preferences to a 
> 24 hour clock, but the NSDatePicker refuses to change. I tried a programmatic 
> formatter:
> 
> NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
> [dateFormatter setDateFormat:@"HH:mm"];
> [myDatePicker setFormatter:dateFormatter];
> (Also tried [[myDatePicker cell] setFormatter:dateFormatter];)
> 
> In desperation, I set a loop trying every NSDatePickerElementFlags from 0 to 
> 513. Have I missed something, or is a 24-hour clock not allowed? The program 
> is for use in a location where 24-hour time is mandatory. Thanks for any 
> insight you might have.
> 
> Best Regards,
> Dan

___

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

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

Help/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: Adding to-many objects programmatically

2010-01-16 Thread mmalc Crawford

On Jan 16, 2010, at 12:17 am, Roland King wrote:

> Cast to the actual type before calling the method.
> Instead of [ managedObject method1 ]
> do
> [ (Employee*)managedObject method1 ]
> 
No; the OP stated, "I don't use custom classes", so this won't work.
Follow the pattern described in the documentation:



mmalc

___

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

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

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

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


NSURLRequest and NSOperationQueue

2010-01-16 Thread Dave DeLong
Hi everyone,

I'm building an object that communicates with a server.  For various reasons, 
I'd like to queue up all the NSURLRequests in an NSOperationQueue so that I 
never have more than one connection open at a time.

However, I'm running into a weird issue.  If I create my NSURLRequest and open 
an NSURLConnection directly, then the connection works and everything proceeds 
as expected.  However, if I create an NSInvocationOperation to delay the 
creation of the connection until the queue is idle, then the connection is 
created (and is non-nil), but the URLRequest never triggers any of its delegate 
methods.

After some investigation, I realized that the operation was executing on a 
different thread, so I scheduled the URLConnection on the mainRunLoop in the 
default mode (after unscheduling from the currentRunLoop).  I'm also retaining 
the URLConnection in an ivar, but it's still not firing any delegate methods 
(on any thread).

Any ideas why my URL connection isn't working?

Thanks,

Dave DeLong

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: [iphone] Load time and Nav View Controller.

2010-01-16 Thread Philip Vallone
Thanks Dave.

Great advise. I've made the change.

Regards.

Phil

On Jan 16, 2010, at 4:02 PM, Dave DeLong wrote:

> Ack.  You should never do UI stuff on secondary threads.  What you should be 
> doing is loading your large XML file on the second thread, and then once that 
> thread is done, make the activity indicator disappear (on the main thread).
> 
> Dave
> 
> On Jan 16, 2010, at 2:00 PM, Philip Vallone wrote:
> 
>> Hmmm Figured it out. I needed to run the activity indicator on another 
>> thread
>> 
>> [NSThread detachNewThreadSelector: @selector(showIndicator) toTarget:self 
>> withObject:nil];
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net
> 
> This email sent to philip.vall...@verizon.net

___

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

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

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

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


Re: [iphone] Load time and Nav View Controller.

2010-01-16 Thread Dave DeLong
Ack.  You should never do UI stuff on secondary threads.  What you should be 
doing is loading your large XML file on the second thread, and then once that 
thread is done, make the activity indicator disappear (on the main thread).

Dave

On Jan 16, 2010, at 2:00 PM, Philip Vallone wrote:

> Hmmm Figured it out. I needed to run the activity indicator on another 
> thread
> 
> [NSThread detachNewThreadSelector: @selector(showIndicator) toTarget:self 
> withObject:nil];


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: [iphone] Load time and Nav View Controller.

2010-01-16 Thread Philip Vallone
Hmmm Figured it out. I needed to run the activity indicator on another 
thread

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


Thanks,

On Jan 16, 2010, at 3:46 PM, Philip Vallone wrote:

> Hi, 
> 
> I have a Navigation Based iPhone Application. If I am going from one nav view 
> to another it may take about 3 seconds to view the next view. This is because 
> the the view loads a large xml file into a NSArray and then must render it. 
> My question is, how can I display a UIActivityIndicatorView while the view is 
> being loaded. if I add it right before the my method to load the second view, 
> it doesn't display until after the view loaded.
> 
> 
> // Add UIActiviatyIndicatorView here
> 
> PartViewController *thePartPage = [[PartViewController alloc] 
> initWithNibName:@"PartViewController" bundle:nil];
> [thePartPage setTitle:rowValue];
> [self.navigationController pushViewController:thePartPage animated:YES];
> 
> Thanks,
> 
> Phil
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net
> 
> This email sent to philip.vall...@verizon.net

___

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

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

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

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


[iphone] Load time and Nav View Controller.

2010-01-16 Thread Philip Vallone
Hi, 

I have a Navigation Based iPhone Application. If I am going from one nav view 
to another it may take about 3 seconds to view the next view. This is because 
the the view loads a large xml file into a NSArray and then must render it. My 
question is, how can I display a UIActivityIndicatorView while the view is 
being loaded. if I add it right before the my method to load the second view, 
it doesn't display until after the view loaded.


// Add UIActiviatyIndicatorView here

PartViewController *thePartPage = [[PartViewController alloc] 
initWithNibName:@"PartViewController" bundle:nil];
[thePartPage setTitle:rowValue];
[self.navigationController pushViewController:thePartPage animated:YES];

Thanks,

Phil

___

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

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

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

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


Re: NSTextField sendActionOn:

2010-01-16 Thread Matthew Lindfield Seager
On Sunday, January 17, 2010, Brad Stone  wrote:
> The best I can do for the NSTextField is bind an action and in, IB, in the 
> TextFieldAttributes set "Action" to "Sent on End Editing"  which sends the 
> action after the first character is type.  I want the action sent as soon as 
> the field gains focus.

Googling "nstextfield begin editing notification" without the quotes
takes one straight to the fine manual. See textDidBeginEditing in
particular.

Hope that is what you are after.

Regards,
Matt
___

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

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

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

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


NSTextField sendActionOn:

2010-01-16 Thread Brad Stone
I have an NSTextField and an NSDatePicker on a view.  As soon as the user 
clicks into either on (and before they type anything) I want to send an action. 
 I thought I'd use sendActionOn: but I can't get it to work.

The best I can do for the NSTextField is bind an action and in, IB, in the 
TextFieldAttributes set "Action" to "Sent on End Editing"  which sends the 
action after the first character is type.  I want the action sent as soon as 
the field gains focus.

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: needing help w/ asynchronous message problem, using YAMessageQueue

2010-01-16 Thread Ken Thomases
On Jan 15, 2010, at 10:04 PM, Shane wrote:

> I have a thread already where I use asynchronous messages to
> communicate (using YAMessageQueue). My main application thread sends
> messages to a task thread similar to the below line, but for some
> reason, when I'm sending from my task thread to the main application
> thread, I'm getting the following error (I do have other messages from
> my task thread to the main app thread that do work, just not this
> one).
> 
> 2010-01-15 21:28:50.483 myApp[16330:420b] YAMessageQueue caught "***
> -[NSCFArray insertObject:atIndex:]: attempt to insert nil" when
> invoking updateLoadedNetworkConfiguration:
> 
> [[clientQueue proxyForTarget:controller] updateLoadedNetworkConfiguration:nc];
> 
> I think it may have something to do w/ the class that I'm trying to
> pass to it (nc) which is my NetworkConfiguration class.

> There's a callback in the YAMessageQueue class where I see where the
> error is coming from, but don't quite understand what's going on or
> still, why this is happening.
> 
> static void
> rlsCallBack(void *info)
> {
>YAMessageQueue *queue = [(YAMessageQueue*)info retain];
>NSInvocation *invoc;
>do {
>invoc = nil;
>NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
>NS_DURING
>invoc = [queue dequeueInvocation];
>if (invoc)
>[invoc invoke];
>NS_HANDLER
>NSLog(@"YAMessageQueue caught \"%...@\" when invoking %s",
> localException, invoc ? (const char*)[invoc selector] :
> "dequeueInvocation");
>NS_ENDHANDLER
>[pool release];
>} while (invoc!=nil);
>[queue release];
> }

I've used YAMessageQueue before.  The issue you're seeing is not directly 
related to it, though.

YAMessageQueue has conveyed the invocation of 
-updateLoadedNetworkConfiguration: to the destination thread and invoked it 
there.  It is something within -updateLoadedNetworkConfiguration: which is 
throwing the original exception because there's been an attempt to insert a nil 
into an array.  YAMessageQueue is catching the exception and logging it, that's 
all.

If you can reproduce this issue, then you should do so while running your app 
in the debugger.  Tell Xcode to stop on Objective-C exceptions and you'll see 
the point of the original exception and can explore the backtrace to figure out 
what's going on.

Good luck,
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: If Array Controller is empty, how to populate pop-up list?

2010-01-16 Thread Ken Thomases
On Jan 14, 2010, at 4:09 PM, Jenny M wrote:

> I have an Array Controller whose objects are displayed in an NSPopUpButton.

> However, what can I do if the array controller becomes empty? If I delete all 
> the objects, or if the window starts up with an empty array controller, I'd 
> like for the list to then have a null element that says "No objects."  Once 
> an object is added, it should go away.


> But if I choose "Insert null placeholder" in the pop-up options, the null 
> placeholder is ALWAYS there, which is not good.

Well, this part is as expected.  That's what the null placeholder is for.  It's 
not a way to represent when the array controller has no objects.  It's a way 
for the pop-up to give the user the option of selecting none of the objects 
from the array controller.

> Is there a way to do this in IB, or is this a thing I should code? And if so, 
> how can I make sure the method is called whenever there is a change to the 
> array controller?

With some experimentation, I discovered the following:

I bound the pop-up's content to the array controller's arrangedObjects.  I 
bound its Selected Value or Selected Object (but not Selected Index) to the 
array controller's selection with an appropriate model key path.  For the 
content binding, I set a No Selection Placeholder string.  Then, whenever the 
array controller had no selection, the pop-up showed the placeholder string.

If the Selected Value binding's Conditionally Sets Enabled option is on (the 
default), then the pop-up is disabled when there's no selection in the array 
controller.  This is sort of bad if the controlled array is not empty but the 
array controller has no selection.  In that case, the pop-up shows the 
placeholder but is disabled, so the user can't access the other items in the 
pop-up.  However, the array controller won't have no selection if its Avoid 
Empty Selection property is enabled (again, the default).  With that property 
enabled, the pop-up shows the placeholder and is disabled only if there's 
nothing in the controlled array.  If there are objects in the array, then the 
array controller has a selection and the pop-up shows it and is enabled.

So, Conditionally Sets Enabled on the pop-up's Selected Value or Object 
binding, plus Avoids Empty Selection on the array controller works well.  
Turning both of those off makes for a functional but possibly strange 
interface; when the array is non-empty but the array controller has no 
selection, the pop-up shows the placeholder but is enabled and also contains 
the normal items.

I hope that helps.

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


Re: Bindings Problem

2010-01-16 Thread Ken Thomases
In addition to what mmalc pointed you to, there are other red flags in your 
description:

On Jan 14, 2010, at 5:11 PM, Carter R. Harrison wrote:

> My model is an NSMutableSet that contains NSMutableDictionaries.

I think this is asking for trouble.  A set of mutable dictionaries doesn't make 
much sense.

One of the defining characteristics of a set is that it can't have two equal 
objects in it at once.  However, mutable dictionaries can change whether they 
are equal when you mutate them.  "Equal" is determined by the -isEqual: and 
-hash methods, not by identity (memory location).

Sets are not implemented to a) be aware of when the contained objects change or 
b) cope with the change.

Quite aside from the question of whether two dictionaries become equal after 
being added to the set is the fact that they will change their hash value when 
mutated.  While the implementation of NSSet is private, it almost certainly 
depends on the hash value of the contained objects.  So, if you put a 
dictionary into the set, mutate it, and then ask the set if it contains the 
dictionary, it may very well say that it does not.  That's because its internal 
bookkeeping used the original hash to file the dictionary in its data 
structures, but uses the new hash to try to look it up.

The NSSet documentation says:

"Note that if mutable objects are stored in a set, either the hash method of 
the objects shouldn’t depend on the internal state of the mutable objects or 
the mutable objects shouldn’t be modified while they’re in the set (note that 
it can be difficult to know whether or not a given object is in a collection)."

A similar warning in the description of -[NSObject hash] specifically uses a 
mutable dictionary as an example of a mutable object which may change its hash 
when mutated.

I recommend using immutable dictionaries or instances of a custom class with 
proper properties and with semantics for -isEqual: and -hash that aren't 
affected by modifications to those properties.  The default semantics provided 
by NSObject, which is that equality is the same as object identity, are 
appropriate in the most common circumstances.  (It depends on whether your 
custom class is a "value object" or not.)


> I then have a NSTableView with several columns.  I want each column in the 
> table to display a value from each NSMutableDictionary.

NSArrayController is only documented as handling sets in the case when managing 
a relationship of a managed object.  I have no idea if it works in the general 
case.  I wouldn't bet on it.

Since a table view is an inherently ordered construct, I'd strongly recommend 
that you use an indexed collection (e.g. array) for your model.


> //This method is here for testing.  A button in the UI is connected to the 
> method.
> //When executed this method creates a new NSMutableDictionary.  Adds some 
> key/value
> //pairs to it then adds the NSMutableDictionary to the NSMutableSet (myset).
> - (IBAction)addValueToSet:(id)sender;

> - (IBAction)addValueToSet:(id)sender
> {
>   NSString *newString = @"New Value";
>   NSMutableDictionary *dict = [[[NSMutableDictionary alloc] 
> initWithCapacity:1] autorelease];
>   [dict setValue:newString forKey:@"Caption"];
>   [myset addObject:dict];
> }

This illustrates my concern about using a set.  In addition to the fact 
(alluded to by mmalc) that you're not mutating the set in a KVO-compliant 
manner, all of the dictionaries added by this method are equal.  Therefore, 
there's no reason to believe that myset is actually being changed by the 
-addObject: message.  If it already contains an equivalent dictionary, then 
-addObject: would do nothing. 

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: Trying to create an alias file by using the new NSURL methods available with Mac OS X 10.6 !

2010-01-16 Thread Ken Thomases
What others have suggested are good, but I also wanted to point out something:

On Jan 13, 2010, at 9:30 AM, rohan a wrote:

> Using the new NSURL methods available with Cocoa on Mac OS X 10.6, I am
> trying to create an alias file to a certain file. However, this method
> requires a NSURL data type. But I am writing a C program along with an
> objective-C program to accomplish this. The C program would accept the
> inputs as C strings. I would then convert them to NSString and then to NSURL
> strings. However, this is not working :(
> By hardcoding the NSURL strings the program works fine.

> #import 
> 
> int CreateAlias(const char *target, const char *aliasname)
> {
>   CFStringRef Ref1 = CFStringCreateWithCString(NULL, target,
> kCFStringEncodingASCII);
> 
>   CFStringRef Ref2 = CFStringCreateWithCString(NULL, aliasname,
> kCFStringEncodingASCII);
> 
>   if (Ref1 == NULL || Ref2 == NULL)
>   exit(1);
> 
>   NSString *Destination = (NSString *)Ref1;
>   NSString *Alias   = (NSString *)Ref2;
>   //NSURL *src =  [NSURL URLWithString:@"file:///Alias_dir/aliastext"];
>   //NSURL *dest = [NSURL URLWithString:@
> "file:///Alias_dir/aliastext.alias"];
> 
>   NSURL *src =  [NSURL URLWithString:Destination];
>   NSURL *dest = [NSURL URLWithString:Alias];

Are the strings file paths or URL strings?  It's important to recognize that 
those are not the same things.  In your commented-out literals, you are passing 
file URL strings, which is appropriate.  However, if target and aliasname (and 
thus Ref1 and Ref2) are not file URL strings but file paths, then you should be 
creating the NSURL objects with +fileURLWithPath: rather than +URLWithString:.  
(And, no, prepending "file://" to a file path does not make it a valid file URL 
string.  For example, file paths may have spaces in them, while that's not 
allowed for URL strings.)

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: Confused about setting selection in NSBrowser

2010-01-16 Thread Chris Idou


Yes, I'm doing 10.6. But I don't see anything about "item based" in 
NSBrowser.h, nor anything else that looks enlightening.





From: Corbin Dunn 
To: Keary Suska 
Cc: Chris Idou ; cocoa-dev@lists.apple.com
Sent: Sat, 16 January, 2010 3:17:00 AM
Subject: Re: Confused about setting selection in NSBrowser


On Jan 15, 2010, at 8:07 AM, Keary Suska wrote:

> On Jan 14, 2010, at 9:56 PM, Chris Idou wrote:
> 
>> I'm trying to set the selected item in an NSBrowser.
>> 
>> I don't want to use setPath: because the items I'm storing in the browser 
>> are not unique, so therefore paths are not unique.
>> 
>> I'm trying to use setIndexPath: but when I try the program throws an 
>> exception:
>> 
>> HIToolbox: ignoring exception 'setSelectionIndexPath: is not supported for 
>> browsers with matrix delegates.' that raised inside Carbon event dispatch
>> (
>> 0   CoreFoundation  0x7fff80322444 
>> __exceptionPreprocess + 180
>> 1   libobjc.A.dylib 0x7fff8055d0f3 
>> objc_exception_throw + 45
>> 2   AppKit  0x7fff8378e252 -[NSBrowser 
>> setSelectionIndexPath:] + 128
>> 
>> I don't understand what this exception means.
> 
> Are you building against 10.6 SDK?


Chris must be, otherwise he would have warnings.

Chris -- read up about the "item based" browser in the NSBrowser.h header.

corbin


  
__
See what's on at the movies in your area. Find out now: 
http://au.movies.yahoo.com/session-times/
___

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

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

Help/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: NSFileHandle weirdness on 10.5 ...

2010-01-16 Thread Ken Thomases
On Jan 12, 2010, at 12:46 PM, Heizer, Charles wrote:

> I'm hoping someone can help me out here. I'm trying to use IPC (Unix domain 
> socket AF_UNIX) to pass data between two applications.
> 
> I have a console application which is sending data to the socket path and a 
> Cocoa GUI app which is reading it using NSFileHandle. The problem I'm seeing 
> is on 10.5 systems I'm not getting all of the data. I'm only getting 502 
> characters, but on 10.6 i'm getting the whole thing.
> 
> Is there some kind of buffer size I can adjust, I'm not really sure what to 
> do?

You don't say what methods of NSFileHandle you're using to read the data.  In 
particular, some of the asynchronous methods require that you re-issue the 
request to keep reading.  For example, -readInBackgroundAndNotify will post an 
NSFileHandleReadCompletionNotification notification when it reads _some_ data.  
In your handler for that notification, you must repeat the 
-readInBackgroundAndNotify invocation to read more data.  You will know you've 
read to end-of-file (or closing of a communications channel) when you receive 
an empty data object in that notification.

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: Adding to-many objects programmatically

2010-01-16 Thread Roland King

Cast to the actual type before calling the method.

Instead of [ managedObject method1 ]

do

[ (Employee*)managedObject method1 ]



On 16-Jan-2010, at 14:57, Jenny M  wrote:


When I tried to use the getter/setter, I get a build warning that says
the NSManagedObject may not respond to that method. I noticed in the
documentation, they're referring to the entities themselves - Employee
and Department. I don't use custom classes, just the data model, so
I've been referring to them as NSManagedObjects the whole time,
though... how would I refer to them by their names?

The objects do load, I ran the program regardless of warnings and it
did set the categories and references. So, how would I get it to build
without those warnings?


On Jan 15, 10:13 pm, mmalc Crawford  wrote:
"Core Data automatically generates efficient public and primitive  
get and setaccessor methods for modeled properties (attributes and  
relationships) of managed object classes (see “Managed Object Acce 
ssor Methods”). When you access or modify properties of a managed  
object, you should use these methods directly."



___

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

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

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

This email sent to r...@rols.org

___

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

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

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

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