Creating an NSSocketPort on an available port?

2008-03-11 Thread Mac QA
Hi,

I have a little program that creates an NSSocketPort for use in
Distributed Objects, and also advertises itself over Bonjour. So,
something like this...

// This server will wait for responses on port 3121
receivePort = [[NSSocketPort alloc] initWithTCPPort:3121];
connection = [NSConnection connectionWithReceivePort:receivePort sendPort:nil];
...
// Create Bonjour Advertisement
netService = [[NSNetService alloc] initWithDomain:@"local"
 type:@"_myapp._tcp."
 name:hostName
 port:3121];

This all works OK, except when I run, quit, and run the app quickly.
The port 3121 isn't yet available again on the second run of the
program because the socket is still in the TIME_WAIT period from the
first run of the program. So, what I would like to do is be dynamic
and listen on a random port that is available, and make my Bonjour
advertisement for that port. Yet I am having difficulty figuring out
how to accomplish that.

// Create a generic receivePort
receivePort = [[NSSocketPort alloc] init];
connection = [NSConnection connectionWithReceivePort:receivePort sendPort:nil];
...
// Create Bonjour Advertisement
// How do I figure out the (unsigned int) value for the port to pass here???
netService = [[NSNetService alloc] initWithDomain:@"local"
 type:@"_myapp._tcp."
 name:hostName
 port:???];

The NSSocketPort class doesn't seem to have a way to get the port when
you just alloc & init like this. So How can you advertise over Bonjour
for a generic dynamically determined port selected at runtime?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating an NSSocketPort on an available port?

2008-03-11 Thread Kyle Sluder
On Tue, Mar 11, 2008 at 3:14 AM, Mac QA <[EMAIL PROTECTED]> wrote:
>  The NSSocketPort class doesn't seem to have a way to get the port when
>  you just alloc & init like this. So How can you advertise over Bonjour
>  for a generic dynamically determined port selected at runtime?

Grab the underlying socket's fd using -[NSSocketPort socket], and then
use getsockname(2) to get at its sockaddr structure.

--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 [EMAIL PROTECTED]


Re: Creating an NSSocketPort on an available port?

2008-03-11 Thread Jean-Daniel Dupas
Addind those lines after your port creation should alow you to reuse  
it after a quick restart:


int yes = 1;
setsockopt([receivePort socket], SOL_SOCKET, SO_REUSEADDR, (void  
*)&yes, sizeof(yes));


else you will have to get the socket adress after it's creation and  
extract port from it. You may have to check the port family before  
doing this to ensure that this is an IPv4 socket (PF_INET or  
PF_INET6). For IPv6, you will have to use 'struct sockaddr_in6'  
instead of 'struct sockaddr_in'.

  UInt8 port = 0;
  struct sockaddr_in* addr4;
  NSData *data = [receivePort address];
  if (data) {
addr4 = (struct sockaddr_in *)[data bytes];
port = ntohs(addr4->sin_port);
  }

Le 11 mars 08 à 08:14, Mac QA a écrit :

Hi,

I have a little program that creates an NSSocketPort for use in
Distributed Objects, and also advertises itself over Bonjour. So,
something like this...

// This server will wait for responses on port 3121
receivePort = [[NSSocketPort alloc] initWithTCPPort:3121];
connection = [NSConnection connectionWithReceivePort:receivePort  
sendPort:nil];

...
// Create Bonjour Advertisement
netService = [[NSNetService alloc] initWithDomain:@"local"
type:@"_myapp._tcp."
name:hostName
port:3121];

This all works OK, except when I run, quit, and run the app quickly.
The port 3121 isn't yet available again on the second run of the
program because the socket is still in the TIME_WAIT period from the
first run of the program. So, what I would like to do is be dynamic
and listen on a random port that is available, and make my Bonjour
advertisement for that port. Yet I am having difficulty figuring out
how to accomplish that.

// Create a generic receivePort
receivePort = [[NSSocketPort alloc] init];
connection = [NSConnection connectionWithReceivePort:receivePort  
sendPort:nil];

...
// Create Bonjour Advertisement
// How do I figure out the (unsigned int) value for the port to pass  
here???

netService = [[NSNetService alloc] initWithDomain:@"local"
type:@"_myapp._tcp."
name:hostName
port:???];

The NSSocketPort class doesn't seem to have a way to get the port when
you just alloc & init like this. So How can you advertise over Bonjour
for a generic dynamically determined port selected at runtime?
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa way to get list of user accounts?

2008-03-11 Thread Jean-Daniel Dupas
As far as I know, the only reliable way to get users accounts is to  
use DirectoryServices but Apple do not provide Obj-C API for Directory  
Services.
There is an obj-C wrapper in the DSTools project of Darwin (http://www.opensource.apple.com/darwinsource/ 
), so you may have a look at it.
Anyway, do not try to parse system files, you result will be wrong.  
For example, you think you users are stored in /etc/passwd, so you  
probably don't know /var/db/dslocal ;-) and you also have to be aware  
that the local user list storage has change between 10.4 and 10.5



Le 11 mars 08 à 07:00, Mac QA a écrit :


Hi,

I am seeking the nice clean Cocoa way of getting a list of user
accounts on the local system. Ultimately in the form of an NSArray of
NSStrings of user account short names. There must be a way without
parsing obscure system files, or spawning off NSTasks and parsing
output, right? Any and all suggestions greatly appreciated. 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/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa way to get list of user accounts?

2008-03-11 Thread Mac QA
On 3/11/08, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote:
> As far as I know, the only reliable way to get users accounts is to
>  use DirectoryServices ... you also have to be aware
>  that the local user list storage has change between 10.4 and 10.5

Thanks for the info. Sounds none too convenient. I just realized I
could just list the /Users directory and filter out the Shared entry.
Granted, someone could have created a folder there that isn't really a
valid user, but seems like an OK 95% solution. :-)

users = [[NSFileManager defaultManager] directoryContentsAtPath:@"/Users/"];
___

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

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

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

This email sent to [EMAIL PROTECTED]


warning: assignment from distinct Objective-C type

2008-03-11 Thread Stuart Malin

I have a line of code:

xmppStream = [[XMPPStream alloc] initWithDelegate:self];

That when compiled, receives a warning:

warning: assignment from distinct Objective-C type

Now, what's odd to me, is if I change the source code to this:

xmppStream = [XMPPStream alloc];
[xmppStream initWithDelegate:self];

It compiles without any warning.

The interface for the XMPPStream initializer is:

- (XMPPStream*) initWithDelegate:(id)initialDelegate;

And, in the file that is allocating and initializing, the xmppStream  
variable is defined as:


XMPPStream  *xmppStream;

So I don't see any reason that I should get the warning.
Any clues about why this happens would be appreciated.
I'm sure I must be overlooking something obvious...

This is happening with Xcode 2.4.1

[I have posted to both Cocoa and Xcode because I have no idea which  
list would be better for this]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Ron Fleckner


On 11/03/2008, at 7:19 PM, Stuart Malin wrote:


I have a line of code:

xmppStream = [[XMPPStream alloc] initWithDelegate:self];

That when compiled, receives a warning:

warning: assignment from distinct Objective-C type


Not sure of the actual reason, but if you both forward declare the  
class in your header like:


@class XMPPStream;

and then import the XMPPStream.h in the implementation file of the  
class in which you use *xmppStream, like:


#import "XMPPStream.h"

then the warning will go away in my experience.

HTH,
Ron
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Stuart Malin

Ron -- thanks for the quick reply.

I do have the XMPPStream class declared in the .h file where the  
variable is declared.

And the .m does import the XMPPStream header file.  
After all, without those, I'd get outright errors :-)


On Mar 10, 2008, at 10:42 PM, Ron Fleckner wrote:



On 11/03/2008, at 7:19 PM, Stuart Malin wrote:


I have a line of code:

xmppStream = [[XMPPStream alloc] initWithDelegate:self];

That when compiled, receives a warning:

warning: assignment from distinct Objective-C type


Not sure of the actual reason, but if you both forward declare the  
class in your header like:


@class XMPPStream;

and then import the XMPPStream.h in the implementation file of the  
class in which you use *xmppStream, like:


#import "XMPPStream.h"

then the warning will go away in my experience.

HTH,
Ron


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa way to get list of user accounts?

2008-03-11 Thread Jean-Daniel Dupas

Le 11 mars 08 à 09:51, Andrew Farmer a écrit :


On 11 Mar 08, at 01:01, Mac QA wrote:

On 3/11/08, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote:

As far as I know, the only reliable way to get users accounts is to
use DirectoryServices ... you also have to be aware
that the local user list storage has change between 10.4 and 10.5


Thanks for the info. Sounds none too convenient. I just realized I
could just list the /Users directory and filter out the Shared entry.
Granted, someone could have created a folder there that isn't  
really a

valid user, but seems like an OK 95% solution. :-)

users = [[NSFileManager defaultManager] directoryContentsAtPath:@"/ 
Users/"];


Fails spectacularly in some networked environments, though - user  
home directories aren't necessarily in /Users.




Even on certain local environment. In Leopard, there is an option in  
the preference pane to move your local folder. (in advanced options),  
and before that, it was already possible to move the home directory (I  
do that since 10.2 to store my profile on a secondary hrad drive)___


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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Julien Jalon
1) All init methods should return (id) not a specific class2) your
initWithDelegate: is likely too generic as a name and its signature
conflicts with an other one.

Since [XMPPStream alloc] is typed id, the compiler might not be sure of what
method signature you want to use for -initWithDelegate:

In the second case, the compiler knows you are using -[XMPPStream
initWithDelegate:]

I tend to remember that the compiler warning was more specific before
Leopard, maybe a regression.

Nonetheless, good coding style should lead you to rename your method to:

- (id)initXMPPStreamWithDelegate:(id)aDelegate;

instead of:

- (XMPPStream *)initWithDelegate:(id)aDelegate;

-- 
Julien

On Tue, Mar 11, 2008 at 9:19 AM, Stuart Malin <[EMAIL PROTECTED]> wrote:

> I have a line of code:
>
>xmppStream = [[XMPPStream alloc] initWithDelegate:self];
>
> That when compiled, receives a warning:
>
> warning: assignment from distinct Objective-C type
>
> Now, what's odd to me, is if I change the source code to this:
>
>xmppStream = [XMPPStream alloc];
>[xmppStream initWithDelegate:self];
>
> It compiles without any warning.
>
> The interface for the XMPPStream initializer is:
>
>- (XMPPStream*) initWithDelegate:(id)initialDelegate;
>
> And, in the file that is allocating and initializing, the xmppStream
> variable is defined as:
>
>XMPPStream  *xmppStream;
>
> So I don't see any reason that I should get the warning.
> Any clues about why this happens would be appreciated.
> I'm sure I must be overlooking something obvious...
>
> This is happening with Xcode 2.4.1
>
> [I have posted to both Cocoa and Xcode because I have no idea which
> list would be better for this]
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Moderator] iPhone discussion here - RETRACTION

2008-03-11 Thread Gustavo Eulalio
That`s funny, because in the iPhone SDK intro videos we're instructed
to get more information here, in this list. I wish they'd make up
their mind.

-- 
Gustavo Eulalio
[EMAIL PROTECTED]


On Mon, Mar 10, 2008 at 7:45 PM, Scott Anguish <[EMAIL PROTECTED]> wrote:
> Apparently there has been some miscommunication somewhere.
>
>  While I was told to allow discussion here, I've now been told that
>  discussion should not be allowed here.
>
>  So we're back to the 'no iPhone discussion is allowed' state of things.
>
>  Sorry for the confusion.
>
>  Scott Anguish
>
>  ___
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  Please do not post admin requests or moderator comments to the list.
>  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>  Help/Unsubscribe/Update your Subscription:
>  http://lists.apple.com/mailman/options/cocoa-dev/guga.emc%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Quit application when window closes

2008-03-11 Thread Felipe Monteiro de Carvalho
Hello,

How can I implement the behavior that the application closes when my
window closes?

The application contains no nib files and doesn't use the interface
builder, it's every thing done by code.

thanks,
-- 
Felipe Monteiro de Carvalho
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa way to get list of user accounts?

2008-03-11 Thread Andrew Farmer

On 11 Mar 08, at 01:01, Mac QA wrote:

On 3/11/08, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote:

As far as I know, the only reliable way to get users accounts is to
use DirectoryServices ... you also have to be aware
that the local user list storage has change between 10.4 and 10.5


Thanks for the info. Sounds none too convenient. I just realized I
could just list the /Users directory and filter out the Shared entry.
Granted, someone could have created a folder there that isn't really a
valid user, but seems like an OK 95% solution. :-)

users = [[NSFileManager defaultManager] directoryContentsAtPath:@"/ 
Users/"];


Fails spectacularly in some networked environments, though - user home  
directories aren't necessarily in /Users.

___

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

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

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

This email sent to [EMAIL PROTECTED]


shared NSImage from bundle

2008-03-11 Thread Torsten Curdt

While I know I can load an image like this

 image = [[NSImagealloc] initWithContentsOfFile: 
[[NSBundlemainBundle] pathForResource:@"someimage" ofType:@"PNG"]];


all my NSDocument should be OK to share the same instance. Creating  
class level singleton accessors seem a little too much work. Is there  
a class level init that could be used to fill class level variables?  
Forgive me my blasphemy but something along the lines of...


 public class MyDocument extends NSDocument {

   private final static NSImage image;
   private final static NSImage image2 = ...;

   static {
 image = ...
   }
   ...
 }

How do people usually do this? Sorry, if this turns out to be more a  
Objective-C question than a Cocoa question.


cheers
--
Torsten
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: shared NSImage from bundle

2008-03-11 Thread Jean-Daniel Dupas

The method your looking for is

+ (void)initialize { }

Warning: This method can be called more than once (if a subclass does  
not override it) so you should do something like this.


@implementation Foo

+ (void)initialize {
if ([Foo class] == self) {
// load your images here.
}
}

...


Le 11 mars 08 à 11:12, Torsten Curdt a écrit :


While I know I can load an image like this

image = [[NSImagealloc] initWithContentsOfFile:[[NSBundlemainBundle]  
pathForResource:@"someimage" ofType:@"PNG"]];


all my NSDocument should be OK to share the same instance. Creating  
class level singleton accessors seem a little too much work. Is  
there a class level init that could be used to fill class level  
variables? Forgive me my blasphemy but something along the lines of...


public class MyDocument extends NSDocument {

  private final static NSImage image;
  private final static NSImage image2 = ...;

  static {
image = ...
  }
  ...
}

How do people usually do this? Sorry, if this turns out to be more a  
Objective-C question than a Cocoa question.


cheers
--
Torsten
___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quit application when window closes

2008-03-11 Thread Ron Fleckner


On 11/03/2008, at 9:22 PM, Felipe Monteiro de Carvalho wrote:


Hello,

How can I implement the behavior that the application closes when my
window closes?

The application contains no nib files and doesn't use the interface
builder, it's every thing done by code.

thanks,
--  
Felipe Monteiro de Carvalho


Make your application's main controller class a delegate of  
NSApplication and implement - (BOOL) 
applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) 
theApplication and return YES


Ron
___

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

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

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

This email sent to [EMAIL PROTECTED]


Pragmatic use of private framework class (in this case OSADictionary)

2008-03-11 Thread [EMAIL PROTECTED]

Hello

I had previously posted the excerpt below with regard to browsing  
AppleScript dictionaries from within cocoa apps:


Are OSADictionaryView and OSADictionaryController as featured in the  
IB 3 Open Scripting Kit plug-in viable in cocoa?
The OSAKit header contains no interface for these classes, though  
OSADictionaryView exists as a nib within the OSAKit framework bundle.



Unable to make progress with this I fired up the F-script browser and  
discovered OSADictionary. Intuition lead me to the following:


@interface OSADictionary: NSObject
+ (void)chooseDictionary;
@end

- (void)showDictionary:(id)sender
{   
[OSADictionary chooseDictionary];
}


This seems to work well when linked against the OSAKit framework,  
displaying the familiar Script Editor dictionary browser.
The Script Editor is itself scriptable, but seems to offer no  
dictionary methods.


I am aware of the caveats with regard to using any private API code  
(lack of support, future mutation etc).


My question is more general:

Is it anyway common in cocoa to utilise, in a pragmatic sense (ie:  
when all else seems to fail), such private classes?

Or should I not be tempted.

Regards

Jonathan

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: CIImage (TIFFRepresentation) memory leak

2008-03-11 Thread slasktrattenator
Thanks a bunch! That worked great. No more leaking.

On Tue, Mar 11, 2008 at 4:46 AM, Rob Keniger <[EMAIL PROTECTED]> wrote:
>  I had problems with this too, and I use a workaround I found somewhere
>  where you render to a CGImageRef in the context of the current window.
>  Here's a dump of the code:
>
>  //theImage is an existing NSImage
>  CIImage *outputImage = [CIImage imageWithData:[theImage
>  TIFFRepresentation]];
>
>  //to draw the image processed by Core Image, we need to draw into an
>  on-screen graphics context
>  //this works around a bug in CIImage where drawing in off-screen
>  graphics contexts causes a huge memory leak
>
>  //get the current window's graphics context so that we have an on-
>  screen context
>  //usually we would use any view's window but generically you can just
>  ask for the main window
>  CIContext *ciContext = [[[NSApp mainWindow] graphicsContext] CIContext];
>  if(ciContext == nil)
>  {
> NSLog(@"The CIContext of the main window could not be accessed.
>  Bailing out of the image creation process.");
> return;
>  }
>
>  CGAffineTransform transform;
>  transform = CGAffineTransformMakeTranslation(0.0,[outputImage
>  extent].size.height);
>  transform = CGAffineTransformScale(transform, 1.0, -1.0);
>  outputImage = [outputImage imageByApplyingTransform:transform];
>
>  //render the CIIimage into a CGImageRef in the on-screen context
>  CGImageRef cgImage = [ciContext createCGImage:outputImage fromRect:
>  [outputImage extent]];
>  // Draw the CGImageRef into the current context
>  if (cgImage != NULL)
>  {
> CGContextDrawImage ([[NSGraphicsContext currentContext]
>  graphicsPort], [outputImage extent], cgImage);
> CGImageRelease (cgImage);
>  }
>
>  HTH
>
>  --
>  Rob Keniger
>
>
> ___
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  Please do not post admin requests or moderator comments to the list.
>  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>  Help/Unsubscribe/Update your Subscription:
>  http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%40gmail.com
>
>  This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: shared NSImage from bundle

2008-03-11 Thread Torsten Curdt

Thanks!! Perfect

On 11.03.2008, at 11:17, Jean-Daniel Dupas wrote:


The method your looking for is

+ (void)initialize { }

Warning: This method can be called more than once (if a subclass  
does not override it) so you should do something like this.


@implementation Foo

+ (void)initialize {
if ([Foo class] == self) {
// load your images here.
}
}

...


Le 11 mars 08 à 11:12, Torsten Curdt a écrit :


While I know I can load an image like this

image = [[NSImagealloc] initWithContentsOfFile: 
[[NSBundlemainBundle] pathForResource:@"someimage" ofType:@"PNG"]];


all my NSDocument should be OK to share the same instance.  
Creating class level singleton accessors seem a little too much  
work. Is there a class level init that could be used to fill class  
level variables? Forgive me my blasphemy but something along the  
lines of...


public class MyDocument extends NSDocument {

  private final static NSImage image;
  private final static NSImage image2 = ...;

  static {
image = ...
  }
  ...
}

How do people usually do this? Sorry, if this turns out to be more  
a Objective-C question than a Cocoa question.


cheers
--
Torsten
___

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

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

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


This email sent to [EMAIL PROTECTED]





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Moderator] iPhone discussion here - RETRACTION

2008-03-11 Thread I. Savant

On Mar 11, 2008, at 6:31 AM, Gustavo Eulalio wrote:


That`s funny, because in the iPhone SDK intro videos we're instructed
to get more information here, in this list. I wish they'd make up
their mind.


  Though I made the joke that I blame Scott, it's just that - a joke.  
Keep in mind that he's only the messenger ...


On Mar 11, 2008, at 12:11 AM, Jacob Bandes-Storch wrote:

So are we or are we not getting a specialized (password-protected,  
probably) discussion area for the iPhone SDK?


  Nothing about the retraction suggests to me that they've "canceled"  
the plans to introduce the iPhone discussion area Scott mentioned.


--
I.S.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Check box cell in NSTableView

2008-03-11 Thread Ivan C Myrvold
I can not get my check boxes in an NSTableColumn to show the mixed  
state.
The first time I click an empty check box, it shows as if it is  
checked, it should have been mixed.

The next time I click it, it still shows checked, this time correct.
The third time I click it, it is shown unchecked, also correct.
Then it starts over again as checked, checked, unchecked...

I have checked the Mixed button in IB.

What have I missed here?

Ivan
___

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

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

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

This email sent to [EMAIL PROTECTED]


Is CoreData dead?

2008-03-11 Thread Greg Robertson
Not sure if this is the best place to post this question but here goes.

I am thinking about developing a Mac and iPhone app that would use CoreData
to store application data. Personally I like CoreData and its rapid
development on the Mac side of XCode/Interface Builder.

When I gave the iPhone SDK a spin and went thru the documentation I noticed
that CoreData is not mentioned although SQLite as a data store is. Does this
mean that CoreData is not supported on the iPhone and may eventually be
phased out?

Perhaps it is too early to speculate since Interface Builder (and the lack
of it in the iPhone SDK) may be linked to CoreData support but the data
store method can significantly affect some of the planning aspects of my app
and I would like to identify which data store method would be best.

Can anyone offer advice related to this? If there is a better place to post
this question please let me know as well.

Thanks

Greg
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Is CoreData dead?

2008-03-11 Thread I. Savant
>  When I gave the iPhone SDK a spin and went thru the documentation I noticed
>  that CoreData is not mentioned although SQLite as a data store is. Does this
>  mean that CoreData is not supported on the iPhone and may eventually be
>  phased out?

1 - We're not allowed to "speculate" about the iPhone SDK here.
2 - Just because some features aren't available in Cocoa Touch doesn't
mean they're being 'phased out' elsewhere.
3 - Core Data is very much alive, as evidenced by the major upgrade it
received from Tiger (where it was introduced) to Leopard (where it has
some important new features).

--
I.S.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Moderator] iPhone discussion here - RETRACTION

2008-03-11 Thread Hamish Allan
On Tue, Mar 11, 2008 at 12:56 AM, has <[EMAIL PROTECTED]> wrote:

>  #1 - The first rule of iPhone SDK is, you do not talk about iPhone SDK.
>
>  #2 - The second rule of iPhone SDK is, you DO NOT talk about iPhone SDK.

The one-and-a-halfth rule of iPhone SDK is, you are welcome to talk
about iPhone.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLDownload and userInfo

2008-03-11 Thread Trygve Inda
> Or, yet another solution:
> Just subclass NSURLConnection (say MyUserInfoURLConnection), add a
> userInfo ivar, drop in some accessors, and you are good to go. :)
> [userInfoConnection userInfo];


My code is:

NSURLRequest*urlRequest = [NSURLRequest requestWithURL:theURL
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];

NSURLDownload*urlDownload = [[NSURLDownload alloc]
initWithRequest:urlRequest delegate:self];

[urlDownload setDestination:path allowOverwrite:YES];

Where then can I specify that it use a custom NSURLConnection class? This is
why my initial approach was to use a custom NSURLDownload class.

Trygve


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Is CoreData dead?

2008-03-11 Thread Mark Dawson
You can't talk about the iPhone SDK publicly -- you have to ask Apple directly 
(the developer relations people).

You could probably ask for Core Data; however I'm sure that Core Data being 
gone is no more indicative of it being gone (for everything) than Ethernet is 
because it wasn't in the MacBook Air -- just that some platforms just don't 
provide the full suite that you're used to.

On Tuesday, March 11, 2008, at 06:04AM, "Greg Robertson" <[EMAIL PROTECTED]> 
wrote:
>Not sure if this is the best place to post this question but here goes.
>
>I am thinking about developing a Mac and iPhone app that would use CoreData
>to store application data. Personally I like CoreData and its rapid
>development on the Mac side of XCode/Interface Builder.
>
>When I gave the iPhone SDK a spin and went thru the documentation I noticed
>that CoreData is not mentioned although SQLite as a data store is. Does this
>mean that CoreData is not supported on the iPhone and may eventually be
>phased out?
>
>Perhaps it is too early to speculate since Interface Builder (and the lack
>of it in the iPhone SDK) may be linked to CoreData support but the data
>store method can significantly affect some of the planning aspects of my app
>and I would like to identify which data store method would be best.
>
>Can anyone offer advice related to this? If there is a better place to post
>this question please let me know as well.
No.  There is no public place suitable to post this --talk to developer 
relations 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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Is CoreData dead?

2008-03-11 Thread Stephane Sudre


On Mar 11, 2008, at 14:01, Greg Robertson wrote:


Not sure if this is the best place to post this question but here goes.

...


If there is a better place to post this question please let me know as 
well.


Bug Reporter > Enhancement request


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread Stephane Sudre


On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote:

I can not get my check boxes in an NSTableColumn to show the mixed 
state.
The first time I click an empty check box, it shows as if it is 
checked, it should have been mixed.


A mixed state can not be determined by a click.

What a click should do:

Unchecked -> Checked

Mixed -> Checked

Checked -> Unchecked

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Moderator] iPhone discussion here - RETRACTION

2008-03-11 Thread Brady Duga


On Mar 11, 2008, at 3:31 AM, Gustavo Eulalio wrote:


That`s funny, because in the iPhone SDK intro videos we're instructed
to get more information here, in this list. I wish they'd make up
their mind.


Presumably they did not want to make two sets of videos, one for the  
beta instructing them that it is a beta and they shouldn't discuss it  
openly and one for the final release. Since a beta is designed to test  
the final functionality of an entire product (including its  
documentation) modifying or withholding the videos would have been a  
mistake.


--Brady

___

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

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

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

This email sent to [EMAIL PROTECTED]


Is CoreData dead? [RESOLVED]

2008-03-11 Thread Greg Robertson
This issue has been resolved using
Bug Reporter > Enhancement request
at developer.apple.com

Thanks

Greg
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLDownload and userInfo

2008-03-11 Thread Jens Alfke


On 10 Mar '08, at 8:06 PM, Ben Lachman wrote:

I don't know if I agree with the working with the APIs bit.  I think  
it's obvious that the APIs expect a single delegate to be able to  
handle multiple objects using it concurrently, thus the passing of  
the object that is delegating to the delegate.


It's an API design rule that delegate/data-source APIs should allow  
the same delegate to work with multiple delegatees.


But that doesn't mean you should always do things that way. Sometimes  
it's appropriate, sometimes not. If you have to resort to setting up  
dictionaries to associate state with the objects, I think that's an  
indication that you haven't factored your design correctly.


Creating 15 delegate objects over and over again (in my case every  
time a user does a search, submit, etc.) doesn't seem to be a very  
clean solution as it spreads your networking code out.  You'd  
basically have to have a class that starts your connections and then  
have another class that is the connection's delegate and then  
possibly have one of those two classes, or another one, handle  
cleaning up or whatever


Not really — I'd do it with one "Downloader" class that downloads one  
resource. Its -init method creates an NSURLConnection, makes itself  
the delegate, and starts it. The class has instance variables for all  
of the state associated with the download. When the download finishes  
it cleans up, and either posts a notification or sets an observable  
property.


I've implemented this pattern so many times I've lost count :) The  
NSOperation class in Leopard is basically a generalization of the  
skeleton of this.


How to divide a program into objects/classes is a subjective matter,  
to be sure. But I've been doing it for a very long time [I started  
using Smalltalk-80 as a summer intern at Xerox in 1984], and the most  
common mistake I see people make in their code is to shove too much  
stuff into a single class. When one object instance starts to  
represent a bunch of different conceptual objects, it's good to think  
about splitting it.


—Jens

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 [EMAIL PROTECTED]

Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Keary Suska
on 3/11/08 1:50 AM, [EMAIL PROTECTED] purportedly said:

> Ron -- thanks for the quick reply.
> 
> I do have the XMPPStream class declared in the .h file where the
> variable is declared.
> And the .m does import the XMPPStream header file. 
> After all, without those, I'd get outright errors :-)
> 
> 
> On Mar 10, 2008, at 10:42 PM, Ron Fleckner wrote:
> 
>> 
>> On 11/03/2008, at 7:19 PM, Stuart Malin wrote:
>> 
>>> I have a line of code:
>>> 
>>> xmppStream = [[XMPPStream alloc] initWithDelegate:self];
>>> 
>>> That when compiled, receives a warning:
>>> 
>>> warning: assignment from distinct Objective-C type

Are xmppStream and the object returned by -initWithDelegate: defined to be
of the *exact* same class?

Best,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread Ivan C Myrvold

It doesn't matter if I do the

[myCheckBox setState:NSMixedState];

the result is the same, the checkbox is shown as checked.

If I however use the same code (or even click all the three states) in  
an ordinary check box (not cell), everything works as I expect it to do.


This makes me suspect this to be a bug.

Ivan

Den 11. mars. 2008 kl. 14:42 skrev Stephane Sudre:



On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote:

I can not get my check boxes in an NSTableColumn to show the mixed  
state.
The first time I click an empty check box, it shows as if it is  
checked, it should have been mixed.


A mixed state can not be determined by a click.

What a click should do:

Unchecked -> Checked

Mixed -> Checked

Checked -> Unchecked




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa way to get list of user accounts?

2008-03-11 Thread Dave Camp

On Mar 10, 2008, at 11:00 PM, Mac QA wrote:


I am seeking the nice clean Cocoa way of getting a list of user
accounts on the local system. Ultimately in the form of an NSArray of
NSStrings of user account short names. There must be a way without
parsing obscure system files, or spawning off NSTasks and parsing
output, right? Any and all suggestions greatly appreciated. Thanks!


On Leopard, the new Identity Services API might be what you are  
looking for.



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 [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread stephane


On Mar 11, 2008, at 3:58 PM, Ivan C Myrvold wrote:


It doesn't matter if I do the

[myCheckBox setState:NSMixedState];

the result is the same, the checkbox is shown as checked.

If I however use the same code (or even click all the three states)  
in an ordinary check box (not cell), everything works as I expect it  
to do.


This makes me suspect this to be a bug.


IIRC, I had to state in the code that mixed state. was allowed for a  
NSButtonCell inside a NSTableView. The Data Cell was created  
dynamically (not through IB) so by default it was set to NO.


It could be worth checking if it works better after you've called:

[myCell  setAllowsMixedState:YES];

in the awakeFromNib.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread Mike Abdullah
I suspect here that you need to learn a little more about how  
NSTableView works. There is NOT one cell per row, so call -setState:  
basically does nothing. instead, NSTableView creates copies of the  
cell, sets the properties, and uses that to draw.


How are you supplying data to the table - data source or bindings?

Mike.

On 11 Mar 2008, at 14:58, Ivan C Myrvold wrote:


It doesn't matter if I do the

[myCheckBox setState:NSMixedState];

the result is the same, the checkbox is shown as checked.

If I however use the same code (or even click all the three states)  
in an ordinary check box (not cell), everything works as I expect it  
to do.


This makes me suspect this to be a bug.

Ivan

Den 11. mars. 2008 kl. 14:42 skrev Stephane Sudre:



On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote:

I can not get my check boxes in an NSTableColumn to show the mixed  
state.
The first time I click an empty check box, it shows as if it is  
checked, it should have been mixed.


A mixed state can not be determined by a click.

What a click should do:

Unchecked -> Checked

Mixed -> Checked

Checked -> Unchecked




___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread [EMAIL PROTECTED]
I recently put together a sequence of interlinked NSTableViews using  
checkbox cells.

It displays the mixed state without problem. So no bug I think.

I used a datasource in this case, as below.

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

{

// for the checkbox column

if ([scriptHandler count] == [scriptHandler publishedCount]) {
state = NSOnState;
} else if ([scriptHandler publishedCount] > 0) {
state = NSMixedState;
} else {
state = NSOffState;
}

return [NSNumber numberWithInt:state];

}



It doesn't matter if I do the

[myCheckBox setState:NSMixedState];

the result is the same, the checkbox is shown as checked.

If I however use the same code (or even click all the three states) in
an ordinary check box (not cell), everything works as I expect it to  
do.


This makes me suspect this to be a bug.

Ivan

Den 11. mars. 2008 kl. 14:42 skrev Stephane Sudre:

>
> On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote:
>

>> I can not get my check boxes in an NSTableColumn to show the mixed
>> state.
>> The first time I click an empty check box, it shows as if it is
>> checked, it should have been mixed.

>
> A mixed state can not be determined by a click.
>
> What a click should do:
>
> Unchecked -> Checked
>
> Mixed -> Checked
>
> Checked -> Unchecked
>
>

___

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

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

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

This email sent to [EMAIL PROTECTED]


[MEET]: Los Angeles CocoaHeads Thursday March 13th 7:30pm

2008-03-11 Thread Rob Ross

Howdy LA CocoaHeads!

Gautam Godse will be giving us a presentation on XCode 3 and how it  
compares to XCode 2.


We may also spend a little time talking about ZFS, gossiping about  
the iPhone SDK, and whatever else we can come up with :)



We meet on Thursday at the offices of E! Entertainment at 7:30pm.

Our meeting location is

5750 Wilshire Blvd
Los Angeles, CA 90036.

Here's a google map of the location:

http://www.google.com/maps?f=q&hl=en&q=5750+Wilshire+Blvd,+Los+Angeles 
+CA+90036&ie=UTF8&z=15&om=1&iwloc=addr


Free street parking is available. I'd suggest trying Masselin Ave,  
which is one block East of Courtyard Place.


We meet near the lobby of the West building at 5750 Wilshire Blvd, on  
the West side of Courtyard Place. There are picknick tables in front  
of the lobby and we'll gather there starting at 7:00pm. From there we  
go inside and up to conference room 3A at 7:30.


If you arrive late, please ask the building security personnel in the  
lobby to direct you to the E! Security office, and they will be able  
to contact the group in conference room 3A and send someone down to  
meet you.


If you have any questions, please email Rob Ross at rross  
removethisAt eentertainment dottyDotDot com.





Rob Ross, Lead Software Engineer
E! Networks

---
"Beware of he who would deny you access to information, for in his  
heart he dreams himself your master." -- Commissioner Pravin Lal


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating an NSSocketPort on an available port?

2008-03-11 Thread Mac QA
On 3/11/08, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote:
>   struct sockaddr_in* addr4;
>   NSData *data = [receivePort address];
>   if (data) {
> addr4 = (struct sockaddr_in *)[data bytes];
> port = ntohs(addr4->sin_port);
>   }

Any clue why something like this would produce an "error:
dereferencing pointer to incomplete type" on the "addr4->sin_port"
line even though I have #include ?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating an NSSocketPort on an available port?

2008-03-11 Thread Jean-Daniel Dupas


Le 11 mars 08 à 17:30, Mac QA a écrit :

On 3/11/08, Jean-Daniel Dupas <[EMAIL PROTECTED]> wrote:

 struct sockaddr_in* addr4;
 NSData *data = [receivePort address];
 if (data) {
   addr4 = (struct sockaddr_in *)[data bytes];
   port = ntohs(addr4->sin_port);
 }


Any clue why something like this would produce an "error:
dereferencing pointer to incomplete type" on the "addr4->sin_port"
line even though I have #include ?


#include 


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Button on a button

2008-03-11 Thread Erik Buck
There is this example of buttons on a button:
http://www.stepwise.com/Articles/Technical/NSCell.html

But from your description, I suspect you want Core Animation Layers:
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.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 [EMAIL PROTECTED]


cross development ppc intel problem

2008-03-11 Thread vinay
I'm fairly new to XCode and mac development and am trying build a universal
binary that I started designing on leopard intel.
When I finally got my hands on a ppc tiger machine to test the UI looks
completely different. The main issue is that the icons for my buttons are
"zoomed in" on the ppc(probably same issue on tiger regardless of arch) and
I'm unable to figure out why -- and I'm not able to select another icon file
in Interface builder. What I mean here is that the entire icon shows on
leopard on the face of the button while on tiger/ppc a subset of it shows
because it's zoomed in and covers the whole face of the button. As a result
the app looks horrible because the icons look meaningless. I'm using .icns
files.

I then saved my project to XCode 2.4 and also downgraded the NIB to
2.x(after resolving some small issues) and building on the ppc machine
using
XCode 2.5 produced the same problem.

The app generally works but is more unstable that I need to debug and test
and the behaviour is also slightly different but I'm sure that may be
inherent issues that surface on the other architecture that I just need to
debug through.
___

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

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

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

This email sent to [EMAIL PROTECTED]


To unmount a volume

2008-03-11 Thread Nick Rogers

Hi,
How can I unmount a volume knowing its POSIX path (/dev/rdisk1) and  
knowing its mounted name (Volumes/TREK)?


Is there any API to do that in cocoa?

Wishes,
Nick
___

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

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

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

This email sent to [EMAIL PROTECTED]


Working with large files and Memory

2008-03-11 Thread Carl E. McIntosh
Can you please give advice about handling large data files with memory  
management techniques? I am attempting to read three large files (1  
GB, 208 MB, 725 MB) sequentially and place the data into arrays for  
processing. Here is my psuedocode:


1) Import a file into NSString.
  NSString *aFileString = [NSString stringWithContentsOfFile:  
fileLocation];	// Convert file at path to myFileString text holder;


2) Use NSScanner pull out integers and floats
  NSScanner *aFileScanner = [[NSScanner alloc] initWithString:  
aFileString];


3) Store values into arrays.
  float myFloats [10][2000]; or
  float myInts [10][2000];

4) repeat three times with 3 different files.

This algorithm works for smaller files but chokes on the larger files  
and I get malloc errors. I've attempted to use NSZone's to the same  
failure.


Can you please give advice about handling large data files with memory  
management techniques?


I have 4 GB ram and can hog off 2 - 3 GBs for the process. I don't  
know how to explicitly allocate real memory. I'd rather not use  
virtual memory. Any references or examples would be appreciated.



Thank you.
Carl




___

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

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

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

This email sent to [EMAIL PROTECTED]


Where are the [hidden] nibs and other resources?

2008-03-11 Thread James Hober
In the Finder, when I open up my app's package, I find all my nib  
files and other resources.  If I open the package of an Apple app,  
some nibs and other resources are in there, but many are not.  Where  
are they?  Why aren't they there?  Can I hide my stuff, too?  Should  
I hide my stuff, too?

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: cross development ppc intel problem

2008-03-11 Thread Dave Hersey
You should run the IB compatibility check for the version of the OS  
you're targeting. It sounds like your button images are set to scale,  
which isn't supported prior to 10.5.


Open your nib and click the "info" button if you're using IB3. Then  
set the target OS. If you click on the entries, it will take you right  
to the source of the problems. If you're not using IB3, select  
"Compatibility Checking..." under the File menu.


But, basically, buttons can't scale images except on 10.5. You need to  
do it yourself for older versions. It probably makes sense to just pre- 
scale the images in a graphics program.


- d

On Mar 11, 2008, at 12:59 PM, vinay wrote:

I'm fairly new to XCode and mac development and am trying build a  
universal

binary that I started designing on leopard intel.
When I finally got my hands on a ppc tiger machine to test the UI  
looks
completely different. The main issue is that the icons for my  
buttons are
"zoomed in" on the ppc(probably same issue on tiger regardless of  
arch) and
I'm unable to figure out why -- and I'm not able to select another  
icon file
in Interface builder. What I mean here is that the entire icon shows  
on
leopard on the face of the button while on tiger/ppc a subset of it  
shows
because it's zoomed in and covers the whole face of the button. As a  
result
the app looks horrible because the icons look meaningless. I'm  
using .icns

files.

I then saved my project to XCode 2.4 and also downgraded the NIB to
2.x(after resolving some small issues) and building on the ppc machine
using
XCode 2.5 produced the same problem.

The app generally works but is more unstable that I need to debug  
and test

and the behaviour is also slightly different but I'm sure that may be
inherent issues that surface on the other architecture that I just  
need to

debug through.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working with large files and Memory

2008-03-11 Thread Clark Cox
On Tue, Mar 11, 2008 at 9:54 AM, Carl E. McIntosh <[EMAIL PROTECTED]> wrote:
> Can you please give advice about handling large data files with memory
>  management techniques? I am attempting to read three large files (1
>  GB, 208 MB, 725 MB) sequentially and place the data into arrays for
>  processing. Here is my psuedocode:
>
>  1) Import a file into NSString.
>NSString *aFileString = [NSString stringWithContentsOfFile:
>  fileLocation];  // Convert file at path to myFileString text holder;

Depending on the encoding of the file itself, this could end up
allocating a block of memory twice the size of the file.

>  2) Use NSScanner pull out integers and floats
>NSScanner *aFileScanner = [[NSScanner alloc] initWithString:
>  aFileString];

This has the potential of copying the passed in string (not likely to
be a problem, as you string is immutable, but is still something to
keep in mind).

>
>  3) Store values into arrays.
>float myFloats [10][2000]; or
>float myInts [10][2000];

Again, *another* huge block of memory.

>  4) repeat three times with 3 different files.

Depending on how this is done (how tight your autorelease pools are,
etc.), the old string may not have been deallocated yet.

>  This algorithm works for smaller files but chokes on the larger files
>  and I get malloc errors. I've attempted to use NSZone's to the same
>  failure.
>
>  Can you please give advice about handling large data files with memory
>  management techniques?

You'll have to use less memory. Remember, that on a 32-bit machine,
you will never be able to allocate more than 4GB of memory in your
address space. On top of that, much of that memory is already used by
the system's frameworks (usually between 1 and 2 GB).

>  I have 4 GB ram and can hog off 2 - 3 GBs for the process. I don't
>  know how to explicitly allocate real memory. I'd rather not use
>  virtual memory. Any references or examples would be appreciated.

Memory doesn't work like that (i.e you cannot allocate "real" memory).
The closest that you can get is to allocate memory and to "wire" it
down; however, this is a horrible idea for allocations this large
(you'll still run out of address space as before). Your best bet is to
change your algorithm to not have to load the entire file at once
(perhaps load it a line at a time, or in blocks of 4K or so).

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where are the [hidden] nibs and other resources?

2008-03-11 Thread matt . gough

Maybe you aren't looking in their localized resource folders?

Matt


On 11 Mar 2008, at 18:08, James Hober wrote:

In the Finder, when I open up my app's package, I find all my nib  
files and other resources.  If I open the package of an Apple app,  
some nibs and other resources are in there, but many are not.  Where  
are they?  Why aren't they there?  Can I hide my stuff, too?  Should  
I hide my stuff, too?

___


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working with large files and Memory

2008-03-11 Thread Jean-Daniel Dupas

Le 11 mars 08 à 17:54, Carl E. McIntosh a écrit :

Can you please give advice about handling large data files with  
memory management techniques? I am attempting to read three large  
files (1 GB, 208 MB, 725 MB) sequentially and place the data into  
arrays for processing. Here is my psuedocode:


1) Import a file into NSString.
 NSString *aFileString = [NSString stringWithContentsOfFile:  
fileLocation];	// Convert file at path to myFileString text holder;


2) Use NSScanner pull out integers and floats
 NSScanner *aFileScanner = [[NSScanner alloc] initWithString:  
aFileString];


3) Store values into arrays.
 float myFloats [10][2000]; or
 float myInts [10][2000];

4) repeat three times with 3 different files.

This algorithm works for smaller files but chokes on the larger  
files and I get malloc errors. I've attempted to use NSZone's to the  
same failure.


Can you please give advice about handling large data files with  
memory management techniques?


I have 4 GB ram and can hog off 2 - 3 GBs for the process. I don't  
know how to explicitly allocate real memory. I'd rather not use  
virtual memory. Any references or examples would be appreciated.


The first advice I can give you is "do not load the whole file into  
memory". Use read stream to read chunk of data and process them. (see  
NSInputStream or NSFileHandle).

Maybe other people on this list may have other advices too.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where are the [hidden] nibs and other resources?

2008-03-11 Thread Nathan Duran


On Mar 11, 2008, at 10:08 AM, James Hober wrote:

In the Finder, when I open up my app's package, I find all my nib  
files and other resources.  If I open the package of an Apple app,  
some nibs and other resources are in there, but many are not.  Where  
are they?  Why aren't they there?  Can I hide my stuff, too?  Should  
I hide my stuff, too?


Whatever it is you're looking for is probably either being created  
programatically or pulled out of another bundle.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where are the [hidden] nibs and other resources?

2008-03-11 Thread stephane


On Mar 11, 2008, at 6:08 PM, James Hober wrote:

In the Finder, when I open up my app's package, I find all my nib  
files and other resources.  If I open the package of an Apple app,  
some nibs and other resources are in there, but many are not.



Where are they?


Somewhere else : maybe these resources are parts of a framework  
(private or public) or plugins. For instance, Xcode package is  
relatively empty.


Nowhere: some nibs just miss some of their components because they are  
not required and it both prevents edition and reduce the size footprint.



 Why aren't they there?


See above


 Can I hide my stuff, too?


Yes. If you don't want your nib to be editable for instance (they  
would still be visible though).



Should I hide my stuff, too?


Generally, no.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: To unmount a volume

2008-03-11 Thread Randall Meadows

On Mar 11, 2008, at 11:03 AM, Nick Rogers wrote:


Hi,
How can I unmount a volume knowing its POSIX path (/dev/rdisk1) and  
knowing its mounted name (Volumes/TREK)?


Is there any API to do that in cocoa?


NSWorkspace -unmountAndEjectDeviceAtPath:?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Stuart Malin

Brilliant Julien!  Thank you!

I had always been curious why initializers returned id, since their  
return could be made specific to the class.


I've been doing what I've done in many classes, and some give me  
grief, and not others.


Both of your assessments are correct.

To validate #1, if I change the offending line of code to do a cast:

xmppStream = [(XMPPStream*)[XMPPStream alloc] initWithDelegate:self];

the warning goes away. Of course, that's ugly and I won't retain that  
code change because the deeper problem is exactly what you refer to  
in item #2 -- I do have more than one class with the same initializer  
signature. I'd thought the compiler would choose the right one  
because I'd naively presumed that [className alloc]  returned an  
instance in that class, not an object of type id.


This is  probably why I had to cast in my initializer:

- (XMPPStream*) initWithDelegate:(id)initialDelegate
{
self = (XMPPStream*)[super init];

If I change my initializer method name as you suggest  so that it has  
a unique signature,


- (XMPPStream*) initXMPPStreamWithDelegate:(id)initialDelegate;

and the creation of an instance accordingly:

xmppStream = [[XMPPStream alloc] initXMPPStreamWithDelegate:self];

all now compiles cleanly.

Now, the question is: is it bad to continue doing what I've been  
doing in having the initializer interface defined to not return id  
but an instance of the actual class?  Or would my continuing to do  
this merely be a non-conventional coding style?


--Stuart

On Mar 10, 2008, at 11:16 PM, Julien Jalon wrote:


1) All init methods should return (id) not a specific class
2) your initWithDelegate: is likely too generic as a name and its  
signature conflicts with an other one.


Since [XMPPStream alloc] is typed id, the compiler might not be  
sure of what method signature you want to use for -initWithDelegate:


In the second case, the compiler knows you are using -[XMPPStream  
initWithDelegate:]


I tend to remember that the compiler warning was more specific  
before Leopard, maybe a regression.


Nonetheless, good coding style should lead you to rename your  
method to:


- (id)initXMPPStreamWithDelegate:(id)aDelegate;

instead of:

- (XMPPStream *)initWithDelegate:(id)aDelegate;

--
Julien

On Tue, Mar 11, 2008 at 9:19 AM, Stuart Malin  
<[EMAIL PROTECTED]> wrote:

I have a line of code:

   xmppStream = [[XMPPStream alloc] initWithDelegate:self];

That when compiled, receives a warning:

warning: assignment from distinct Objective-C type

Now, what's odd to me, is if I change the source code to this:

   xmppStream = [XMPPStream alloc];
   [xmppStream initWithDelegate:self];

It compiles without any warning.

The interface for the XMPPStream initializer is:

   - (XMPPStream*) initWithDelegate:(id)initialDelegate;

And, in the file that is allocating and initializing, the xmppStream
variable is defined as:

   XMPPStream  *xmppStream;

So I don't see any reason that I should get the warning.
Any clues about why this happens would be appreciated.
I'm sure I must be overlooking something obvious...

This is happening with Xcode 2.4.1

[I have posted to both Cocoa and Xcode because I have no idea which
list would be better for this]



___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Displaying at appropriate time after text layout...?

2008-03-11 Thread Steve Shepard
Hi Keith,
I saw this same behavior on Leopard (but not on Tiger). My memory of the
specific details is a little vague, but I believe there is a bug where the
view hierarchy does not recognize needsDisplay when the view is invalidated
during background layout.

I was able to work around the problem by adding a flag (_forceDisplay) to my
addPage routine and then adding the following code
to layoutManager:didCompleteLayoutForTextContainer:atEnd:

if (layoutFinishedFlag && _forceDisplay) {
STPageView *pagesView = [scrollView documentView];
if ([pagesView needsDisplay]) {
 [pagesView display];
}
_forceDisplayForBug = NO;
}

This is obviously not optimal.

Doug/Aki: I'll try to get a reproducible case for you and file a bug.

Regards,

-Steve

On Sun, Mar 9, 2008 at 1:42 PM, Keith Blount <[EMAIL PROTECTED]> wrote:

> Hello,
>
> I have a multiple-page text view, much like the one in TextEdit, except
> that mine has a custom clip view that draws a shadow around the view it
> contains and the page view gets different text storages swapped in and out
> of it (using NSTextStorage's -addLayoutManager:). All of which makes it a
> little more complicated, of course.
>
> Any way, I have a really odd (to me) problem with the display not getting
> updated properly. Basically, when text gets added to my multiple page view,
> an -addPage: method gets called from the NSLayoutManager delegate method,
> -layoutManager:didCompleteLayoutForTextContainer:atEnd:, all exactly the
> same as in TextEdit. At this point, obviously, the frame gets recalculated,
> -setNeedsDisplay: gets called, and also, I post a notification that the page
> number has changed and use -setStringValue: on an NSTextField that displays
> the number of pages.
>
> The -drawRect: method of my pages view deals with drawing the page
> backgrounds, and, as I say, my custom clip view (NSClipView subclass) deals
> with drawing a shadow around its document view as an extra visual touch.
>
> The problem, however, is that sometimes the display only seems to get
> updated for the first page - so that even though there may be two or three
> pages (or more) present - with the frame set accordingly - the background
> only draws one page, the clip view only draws the shadow around the document
> frame as it was when the multiple page view only had one page, and my text
> field only displays "1 page". If I NSLog just before and after
> -setStringValue: on my text field, it shows that the value I am setting is
> correct, it is just that the text field is not getting updated. Obviously, I
> can call -display on the text field (-setNeedsDisplay: does nothing in this
> situation, for some reason), but I can't do the same for my multiple text
> view, as that reeks havoc with the layout and can cause more pages than
> necessary to be laid out.
>
> In short, I can't find exactly where I need to call either -display or
> -setNeedsDisplay: without causing redrawing problems (where I have called
> -display successfully, it has thickened the text as though it is being drawn
> twice).
>
> If anyone has any ideas about what I might be doing wrong here, or why the
> display might not get updated properly in this situation, I would be very
> grateful. What is really odd is that the frame is getting set accordingly,
> which should really cause the clip view to redraw, and my frame
> recalculation methods also call -setNeedDisplay: on the multi-page view -
> but all with no effect.
>
> Thanks in advance and all the best,
> Keith
>
>
>
>
>  
> 
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steveshep%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quit application when window closes

2008-03-11 Thread Kevin Dixon
Your window controller will need the method

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*)inSender
{
return YES;
}

and then you need to specify the window controller as the delegate for the
application

[NSApp setDelegate:self];

I do that in awakeFromNib, but you may have to find a different solution,
since you're not using Nib files. Hope that helps,

-Kevin

>
> Message: 12
> Date: Tue, 11 Mar 2008 07:22:17 -0300
> From: "Felipe Monteiro de Carvalho"
>   <[EMAIL PROTECTED]>
> Subject: Quit application when window closes
> To: "Cocoa-dev list" 
> Message-ID:
>   <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hello,
>
> How can I implement the behavior that the application closes when my
> window closes?
>
> The application contains no nib files and doesn't use the interface
> builder, it's every thing done by code.
>
> thanks,
> --
> Felipe Monteiro de Carvalho

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Core Data MOM configurations and renaming...

2008-03-11 Thread Martin Linklater

On 7 Mar 2008, at 23:13, Martin Linklater wrote:

Hi - I'm having some problems with MOM configurations. I have been  
playing about with some data models and have duplicated and renamed  
one. When I initialise the MOM using the datamodel name I get  
results that don't make sense. Here's a snippet of my code:




I'll reply to my own thread just in case someone is as stupid as me  
and finds the original post in the archives. The configurations are of  
course defined in the Data Modelling tool within XCode (Spanner icon  
at the right, defied per entity), and not by the filename of  
the .xcdatamodel file. Doh.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Julien Jalon
It depends on what you mean by "bad"... it is clearly bad Cocoa coding style
(*). It also lead to a lot of typing problems when subclassing you classes.
If the compiler can't decide which methods your code is referring to, it can
end up use the wrong signature producing incorrect code.
For example, suppose you have the two following methods:

- (id)initWithValue:(float)value;

- (id)initWithValue:(int)value;

If the compiler uses the wrong method, the underlying method implementation
will be called with a float parameter while expecting a int or vice-versa.

-- 
Julien

Note that this coding style exists mainly to work-around the ObjC
declaration limitations.

On Tue, Mar 11, 2008 at 7:03 PM, Stuart Malin <[EMAIL PROTECTED]> wrote:

> Brilliant Julien!  Thank you!
> I had always been curious why initializers returned id, since their return
> could be made specific to the class.
>
> I've been doing what I've done in many classes, and some give me grief,
> and not others.
>
> Both of your assessments are correct.
>
> To validate #1, if I change the offending line of code to do a cast:
>
> xmppStream = [(XMPPStream*)[XMPPStream alloc] initWithDelegate:self];
>
> the warning goes away. Of course, that's ugly and I won't retain that code
> change because the deeper problem is exactly what you refer to in item #2 --
> I do have more than one class with the same initializer signature. I'd
> thought the compiler would choose the right one because I'd
> naively presumed that [className alloc]  returned an instance in that
> class, not an object of type id.
>
> This is  probably why I had to cast in my initializer:
>
> - (XMPPStream*) initWithDelegate:(id)initialDelegate
> {
> self = (XMPPStream*)[super init];
>
> If I change my initializer method name as you suggest  so that it has a
> unique signature,
>
> - (XMPPStream*) initXMPPStreamWithDelegate:(id)initialDelegate;
>
> and the creation of an instance accordingly:
>
> xmppStream = [[XMPPStream alloc] initXMPPStreamWithDelegate:self];
>
> all now compiles cleanly.
>
> Now, the question is: is it bad to continue doing what I've been doing in
> having the initializer interface defined to not return id but an instance of
> the actual class?  Or would my continuing to do this merely be a
> non-conventional coding style?
>
> --Stuart
>
> On Mar 10, 2008, at 11:16 PM, Julien Jalon wrote:
>
> 1) All init methods should return (id) not a specific class2) your
> initWithDelegate: is likely too generic as a name and its signature
> conflicts with an other one.
>
> Since [XMPPStream alloc] is typed id, the compiler might not be sure of
> what method signature you want to use for -initWithDelegate:
>
> In the second case, the compiler knows you are using -[XMPPStream
> initWithDelegate:]
>
> I tend to remember that the compiler warning was more specific before
> Leopard, maybe a regression.
>
> Nonetheless, good coding style should lead you to rename your method to:
>
> - (id)initXMPPStreamWithDelegate:(id)aDelegate;
>
> instead of:
>
> - (XMPPStream *)initWithDelegate:(id)aDelegate;
>
> --
> Julien
>
> On Tue, Mar 11, 2008 at 9:19 AM, Stuart Malin <[EMAIL PROTECTED]>
> wrote:
>
> > I have a line of code:
> >
> >xmppStream = [[XMPPStream alloc] initWithDelegate:self];
> >
> > That when compiled, receives a warning:
> >
> > warning: assignment from distinct Objective-C type
> >
> > Now, what's odd to me, is if I change the source code to this:
> >
> >xmppStream = [XMPPStream alloc];
> >[xmppStream initWithDelegate:self];
> >
> > It compiles without any warning.
> >
> > The interface for the XMPPStream initializer is:
> >
> >- (XMPPStream*) initWithDelegate:(id)initialDelegate;
> >
> > And, in the file that is allocating and initializing, the xmppStream
> > variable is defined as:
> >
> >XMPPStream  *xmppStream;
> >
> > So I don't see any reason that I should get the warning.
> > Any clues about why this happens would be appreciated.
> > I'm sure I must be overlooking something obvious...
> >
> > This is happening with Xcode 2.4.1
> >
> > [I have posted to both Cocoa and Xcode because I have no idea which
> > list would be better for this]
> >
> >
> >
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > http://lists.apple.com/mailman/options/cocoa-dev/jjalon%40gmail.com
> >
> > This email sent to [EMAIL PROTECTED]
> >
>
>
>
___

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

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

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

This email 

Re: Core Animation Choppyness

2008-03-11 Thread Jonathan Dann


On 10 Mar 2008, at 22:40, Scott Anguish wrote:

if you stop the animation of the replaceSubview... is that no longer  
choppy?  This is one of the most expensive animations possible.


That fixed it, looks great now!  It was a flickering NSPopUpButton  
that was causing me grief.



also, are all your boundaries integral?


I assume they are as I've just created a bunch of custom views in IB  
and set their frames there.  Would there be a better way?  If they  
can't be resized by the user, is it worth calculating their values on  
startup and just caching them, even though I calculate the new frame  
before the animation?


Thanks very much Scott,

Jon

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 [EMAIL PROTECTED]

Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Chris Hanson

On Mar 11, 2008, at 1:19 AM, Stuart Malin wrote:


The interface for the XMPPStream initializer is:

- (XMPPStream*) initWithDelegate:(id)initialDelegate;


The canonical return type of an -init method is (id).  So the above  
should be:


- (id)initWithDelegate:(id)initialDelegate;

You probably have several different -initWithDelegate: method  
signatures visible to the compiler at that point in your code, with  
different return types, and since +alloc also returns (id) it can't  
necessarily guarantee the right signature will be chosen for the  
expression.  This is part of why Objective-C tends to avoid "generic"  
names like -initWith: or -initWithDelegate: in favor of slightly more  
verbose names that are less likely to overlap each other, for example - 
initWithStreamDelegate: for the above.


Also, once you've upgraded to Leopard and Xcode 3.0, with Objective-C  
2.0 you can mark methods in protocols as @required and @optional,  
which is extremely useful for delegates because (for example) Xcode  
can perform better code completion than if you define your delegate  
via an informal protocol (a category on NSObject).


So the above could be:

- (id)initWithStreamDelegate:(id )initialDelegate;

Hope this helps!

  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working with large files and Memory

2008-03-11 Thread Jens Alfke


On 11 Mar '08, at 10:18 AM, Jean-Daniel Dupas wrote:

The first advice I can give you is "do not load the whole file into  
memory".


Absolutely.

Use read stream to read chunk of data and process them. (see  
NSInputStream or NSFileHandle).


Or if the file is simple ascii text with newlines, you can use basic C  
stdio calls (fopen, fgets, fclose) to read a line at a time. You can  
either convert the line into an NSString, or just use something like  
sscanf to parse it.


In rare situations where you absolutely do have to load a huge file  
into memory, i.e. for an algorithm that requires random access, your  
best bet is to memory-map it. -[NSData  
dataWithContentsOfFile:options:] has an option flag to map the file.  
This will avoid a lot of copying, but it's still subject to the same  
address-space limit if your process is 32-bit, so don't expect to be  
able to load anything much over a gigabyte.


—Jens

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 [EMAIL PROTECTED]

Re: To unmount a volume

2008-03-11 Thread Mike Abdullah

Check out -[NSWorkspace unmountAndEjectDeviceAtPath:]

Mike.

On 11 Mar 2008, at 17:03, Nick Rogers wrote:


Hi,
How can I unmount a volume knowing its POSIX path (/dev/rdisk1) and  
knowing its mounted name (Volumes/TREK)?


Is there any API to do that in cocoa?

Wishes,
Nick
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSBundle wierdness in OCUnit target:

2008-03-11 Thread Chris Hanson

On Mar 10, 2008, at 6:57 PM, William Hunt wrote:

On Mar 10, 2008, at 6:29 PM, Chris Hanson wrote:

On Mar 10, 2008, at 4:44 PM, William Hunt wrote:

When I call:

NSLog( @"bundlePath: %@", [[NSBundle mainBundle] bundlePath] );




I get:

2008-03-10 16:41:18.565 otest[3819:80f] bundlePath: /Developer/Tools


This is expected behavior if your unit tests are being run by  
otest.  If you instead inject your tests into your application,  
then its main bundle will be returned instead (because the tests  
are actually run inside the application).




Ok, so it's the expected behavior.  Phooey!  I then have two  
questions:


1) How do I "inject [my] tests into [my] application?"


Set the "Test Host" build setting in your test bundle target to the  
path of the executable (not just the .app wrapper) you want to inject  
your tests into.


Then tests will be run by running your application with a special  
library inserted into it, which will in turn load your test bundle and  
run its contents, instead of by running them via otest.


2) Can I modify the ocunit target somehow so that the Bundle is  
where I'd expect it to be?


No, this isn't how bundles work.  +[NSBundle mainBundle] should always  
refer to the bundle for the executable that is actually running, not  
elsewhere.  If you follow the steps for #1 above you'll be fine.


I have more about this on my weblog  under "Unit Testing Cocoa  
Applications" at , and in  
other posts under the "unit testing" tag.


  -- Chris

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Check box cell in NSTableView

2008-03-11 Thread Ivan C Myrvold
I have worked with NSTableView code for more than 6 years, but I am  
sure I have not learned everything there is to learn.
Yes, I know there usually is 1 shared cell in NSTableColumn. You are  
wrong in stating that there can not be more than a shared cell in an  
NSTableColumn.


I am using binding., and 1 shared dataCell in the table column.

Ivan

Den 11. mars. 2008 kl. 16:21 skrev Mike Abdullah:

I suspect here that you need to learn a little more about how  
NSTableView works. There is NOT one cell per row, so call -setState:  
basically does nothing. instead, NSTableView creates copies of the  
cell, sets the properties, and uses that to draw.


How are you supplying data to the table - data source or bindings?

Mike.

On 11 Mar 2008, at 14:58, Ivan C Myrvold wrote:


It doesn't matter if I do the

[myCheckBox setState:NSMixedState];

the result is the same, the checkbox is shown as checked.

If I however use the same code (or even click all the three states)  
in an ordinary check box (not cell), everything works as I expect  
it to do.


This makes me suspect this to be a bug.

Ivan

Den 11. mars. 2008 kl. 14:42 skrev Stephane Sudre:



On Mar 11, 2008, at 13:15, Ivan C Myrvold wrote:

I can not get my check boxes in an NSTableColumn to show the  
mixed state.
The first time I click an empty check box, it shows as if it is  
checked, it should have been mixed.


A mixed state can not be determined by a click.

What a click should do:

Unchecked -> Checked

Mixed -> Checked

Checked -> Unchecked




___

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

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

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

This email sent to [EMAIL PROTECTED]





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Stuart Malin

Thanks Chris.

You are right on -- I had more than one method signature with the  
same, generic style name.


My rationale for departing from the canonical approach is because  
then I get a bit of extra type checking at compile time.


Given the canonical approach of returning id, one can define an  
interface for a class with an ivar:


classA  *aIvar

and in the implementation, assign any sort of object to it.

aIvar = [NSString stringWithString:@"OOPS"];

With my approach, when I define the interface for classA's  
initializer to be:


- (classA*) - initClassA ..

then if I inadvertently assign an allocation to the wrong ivar:

NSString*s;

// some code later ...

s = [[classA alloc] init];

the compiler will issue a warning. With the canonical approach of the  
initializer returning type id, it wouldn't.


Now, I know this catches a puny amount of possible errors, but that  
is the reason why I deviated from the ordinary practice.


Given this, I think it would have been beneficial if

[className alloc]

returned of the className type, rather than id. But I am certain  
there are numerous reasons against doing so, as otherwise it would  
likely have been implemented that way.


That aside, your suggestion to use protocol declaration for the  
delegate is something I had planned to investigate. Thanks for the  
further tips.



On Mar 11, 2008, at 10:42 AM, Chris Hanson wrote:


On Mar 11, 2008, at 1:19 AM, Stuart Malin wrote:


The interface for the XMPPStream initializer is:

- (XMPPStream*) initWithDelegate:(id)initialDelegate;


The canonical return type of an -init method is (id).  So the above  
should be:


- (id)initWithDelegate:(id)initialDelegate;

You probably have several different -initWithDelegate: method  
signatures visible to the compiler at that point in your code, with  
different return types, and since +alloc also returns (id) it can't  
necessarily guarantee the right signature will be chosen for the  
expression.  This is part of why Objective-C tends to avoid  
"generic" names like -initWith: or -initWithDelegate: in favor of  
slightly more verbose names that are less likely to overlap each  
other, for example -initWithStreamDelegate: for the above.


Also, once you've upgraded to Leopard and Xcode 3.0, with Objective- 
C 2.0 you can mark methods in protocols as @required and @optional,  
which is extremely useful for delegates because (for example) Xcode  
can perform better code completion than if you define your delegate  
via an informal protocol (a category on NSObject).


So the above could be:

	- (id)initWithStreamDelegate:(id ) 
initialDelegate;


Hope this helps!

  -- Chris



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Mike Abdullah


On 11 Mar 2008, at 21:09, Stuart Malin wrote:


Thanks Chris.

You are right on -- I had more than one method signature with the  
same, generic style name.


My rationale for departing from the canonical approach is because  
then I get a bit of extra type checking at compile time.


Given the canonical approach of returning id, one can define an  
interface for a class with an ivar:


classA  *aIvar

and in the implementation, assign any sort of object to it.

aIvar = [NSString stringWithString:@"OOPS"];

With my approach, when I define the interface for classA's  
initializer to be:


- (classA*) - initClassA ..

then if I inadvertently assign an allocation to the wrong ivar:

NSString*s;

// some code later ...

s = [[classA alloc] init];

the compiler will issue a warning. With the canonical approach of  
the initializer returning type id, it wouldn't.


Now, I know this catches a puny amount of possible errors, but that  
is the reason why I deviated from the ordinary practice.


Given this, I think it would have been beneficial if

[className alloc]

returned of the className type, rather than id. But I am certain  
there are numerous reasons against doing so, as otherwise it would  
likely have been implemented that way.


Well because you simply cannot do this. Somehow every single class  
would have to declare their own version of the +alloc method that  
returns an object of their specific type. Do you really want the  
hassle of having to do that every single time you create a subclass?  
This is not something that can be changed in the framework, but would  
have to be a change to the language/runtime.



That aside, your suggestion to use protocol declaration for the  
delegate is something I had planned to investigate. Thanks for the  
further tips.




___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTableView + delete button?

2008-03-11 Thread Kevin Dixon
I'm using an NSTableView, and I want to be able to remove items from the
list by pressing the delete key on the keyboard. What is the procedure to
receive a message when a key is pressed and the table view has focus?

Thanks,

-Kevin
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread j o a r


On Mar 11, 2008, at 3:03 PM, Kevin Dixon wrote:

I'm using an NSTableView, and I want to be able to remove items from  
the
list by pressing the delete key on the keyboard. What is the  
procedure to

receive a message when a key is pressed and the table view has focus?



Subclass NSTableView and override "-keyDown:". There should be several  
implementations of this online that you could take a look at.


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Launch Daemon Best Practices?

2008-03-11 Thread Karl Moskowski
I'm working on a utility that has to be running even if no one is  
logged in. A bit of research leads me to think I should implement it  
as a launch daemon, with a separate configuration UI.


Am I on the right track, or is there a better approach? Any pointers  
to sample code?


I assume I'm going to have to get the GUI to write settings to / 
Library/Preferences/, and notify the daemon of to reload changes via  
distributed objects. Is it possible to get NSUserDefaults to write  
there (instead of ~/Library/Preferences/)?


Thanks.

--Karl.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Stuart Malin

Thanks everybody who replied.
From the conversation, I now understand why the two line version  
didn't have the compiler warning while the one line version did: once  
the +alloc was assigned to an ivar, the compiler then knew which of  
the multiple -init methods to use. I thought I was adding value with  
my approach, but I know see the troubles I was causing...  Enough said.


On Mar 11, 2008, at 11:58 AM, Mike Abdullah wrote:

Well because you simply cannot do this. Somehow every single class  
would have to declare their own version of the +alloc method that  
returns an object of their specific type. Do you really want the  
hassle of having to do that every single time you create a  
subclass? This is not something that can be changed in the  
framework, but would have to be a change to the language/runtime.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Quincey Morris


On Mar 11, 2008, at 14:09, Stuart Malin wrote:

My rationale for departing from the canonical approach is because  
then I get a bit of extra type checking at compile time.


Personally I prefer the factory method approach, a la [NSArray array]  
etc:


In your header file:

+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate;

In the implementation:

- (id) initWithDelegate:(id)initialDelegate {...}
	+ (XMPPStream*) xmppStreamWithDelegate: (id)initialDelegate {return  
[[[XMPPStream alloc] initWithDelegate:initialDelegate] autorelease];}


Usage:

someStream = [XMPPStream xmppStreamWithDelegate:delegate];

This (a) gives you the compile time type check, (b) saves a few  
keystrokes of clutter wherever you actually create one of these, (c)  
forces creation of the object to use a designated initializer without  
chance of mistakes, and (d) allows you to use the proper (id) return  
type on your initializers.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread j o a r


On Mar 11, 2008, at 3:49 PM, Quincey Morris wrote:

Personally I prefer the factory method approach, a la [NSArray  
array] etc:



Note that factory class methods typically also return id for the same  
reason that init methods return id (NSArray, NSString, et.c.).


This in contrast to shared instances that are strongly typed  
(NSFileManager, NSHost, NSNull, et.c.).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread Quincey Morris


On Mar 11, 2008, at 15:12, j o a r wrote:


On Mar 11, 2008, at 3:03 PM, Kevin Dixon wrote:

I'm using an NSTableView, and I want to be able to remove items  
from the
list by pressing the delete key on the keyboard. What is the  
procedure to

receive a message when a key is pressed and the table view has focus?



Subclass NSTableView and override "-keyDown:". There should be  
several implementations of this online that you could take a look at.


j o a r


You can also do it by adding a "delete:" action method to the document  
or window controller that is in charge of the table view's window, and  
have that action do whatever is necessary (in the simplest case, send  
a "remove:" action to the NSArrayController controlling the table view).


The catch is that you may need to look at the window's first responder  
to check that the delete came from the table view and not somewhere  
else in the window.


But it's fairly easy to add refinements like confirmation dialogs if  
you use this approach.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Hamish Allan
On Tue, Mar 11, 2008 at 10:30 PM, Karl Moskowski
<[EMAIL PROTECTED]> wrote:

>  I assume I'm going to have to get the GUI to write settings to /
>  Library/Preferences/, and notify the daemon of to reload changes via
>  distributed objects.

Why not do it the other way round? Update settings via distributed
objects, and have the daemon write them to /Library/Preferences.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Window not showing

2008-03-11 Thread Mr. Gecko
Hello I am having trouble showing a window.  I am sure IBOutlet  
NSWindow *progressPanel; is connected to the window in interface  
builder, I am sure mine [progressPanel orderFront:self]; works because  
I did it for the main window at start up.  One thing I'm not sure  
about is my method to show it and the way I'm calling it with another  
class.

Here is the way I am calling it with my other class.
#import "Progress.h"

@implementation controller
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
   #pragma unused(notification)
   Progress *progress = [[Progress alloc] init];
   [progress showProgressPanel:NO title:@"Downloading" icon:[NSImage  
imageNamed:@"logo"] info:@"Downloading files"];

   [mainWindow orderFront:self];
}
@end

[mainWindow orderFront:self]; works I see the main window at launch  
even when I have visible at launch unchecked.


Here is my header for Progress.
#import 


@interface Progress : NSObject {
   IBOutlet NSProgressIndicator *progressIndicator;
   IBOutlet NSTextField *info;
   IBOutlet NSImageView *icon;
   IBOutlet NSWindow *progressPanel;
}
- (void)showProgressPanel:(BOOL)indeterminate title:(NSString *)title  
icon:(NSImage *)iconValue info:(NSString *)infoText;

@end

And here is the Progress class.
#import "Progress.h"


@implementation Progress
- (void)showProgressPanel:(BOOL)indeterminate title:(NSString *)title  
icon:(NSImage *)iconValue info:(NSString *)infoText {

   [icon setImage:iconValue];
   [info setStringValue:infoText];
   [progressPanel setTitle:title];
   [progressIndicator setIndeterminate:indeterminate];
   [progressIndicator startAnimation:self];
   [progressPanel orderFront:self];
}
@end
If someone can help me figure this out I'll be very grateful. Thanks,

Mr. Gecko
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Karl Moskowski


On 11-Mar-08, at 7:05 PM, Hamish Allan wrote:


On Tue, Mar 11, 2008 at 10:30 PM, Karl Moskowski
<[EMAIL PROTECTED]> wrote:


I assume I'm going to have to get the GUI to write settings to /
Library/Preferences/, and notify the daemon of to reload changes via
distributed objects.


Why not do it the other way round? Update settings via distributed
objects, and have the daemon write them to /Library/Preferences.



Good idea. Thanks, Hamish.

Do processes run by launchd automatically write their preference  
plists to /Library/Preferences/ using NSUserDefaults?



Karl Moskowski <[EMAIL PROTECTED]>
Voodoo Ergonomics Inc. 



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLDownload and userInfo

2008-03-11 Thread Ben Lachman

On Mar 11, 2008, at 10:42 AM, Jens Alfke wrote:

I don't know if I agree with the working with the APIs bit.  I  
think it's obvious that the APIs expect a single delegate to be  
able to handle multiple objects using it concurrently, thus the  
passing of the object that is delegating to the delegate.


It's an API design rule that delegate/data-source APIs should allow  
the same delegate to work with multiple delegatees.


But that doesn't mean you should always do things that way.  
Sometimes it's appropriate, sometimes not. If you have to resort to  
setting up dictionaries to associate state with the objects, I  
think that's an indication that you haven't factored your design  
correctly.


My point was just that doing things this way isn't really working  
against the API.  As you say yourself this is the API's design rule.   
I don't deny that it may be better in some cases to factor your code  
differently, just that it isn't counter to the API.


Creating 15 delegate objects over and over again (in my case every  
time a user does a search, submit, etc.) doesn't seem to be a very  
clean solution as it spreads your networking code out.  You'd  
basically have to have a class that starts your connections and  
then have another class that is the connection's delegate and then  
possibly have one of those two classes, or another one, handle  
cleaning up or whatever


Not really — I'd do it with one "Downloader" class that downloads  
one resource. Its -init method creates an NSURLConnection, makes  
itself the delegate, and starts it. The class has instance  
variables for all of the state associated with the download. When  
the download finishes it cleans up, and either posts a notification  
or sets an observable property.


This seems fair.  At some point when I'm a bit less busy I'll try it  
with my code. :-)


How to divide a program into objects/classes is a subjective  
matter, to be sure. But I've been doing it for a very long time [I  
started using Smalltalk-80 as a summer intern at Xerox in 1984],  
and the most common mistake I see people make in their code is to  
shove too much stuff into a single class. When one object instance  
starts to represent a bunch of different conceptual objects, it's  
good to think about splitting it.


Maybe I just don't have this problem too often.  I really dislike  
huge classes and tend to have more issues with ending up with  
multitude of small close to empty class files than the other way  
around.  I've only been seriously coding this century though, so  
we'll see what I have to say in another few decades.


Cheers,

->Ben

--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

[EMAIL PROTECTED]
740.590.0009

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTask and process group IDs

2008-03-11 Thread Hamish Allan
Hi,

I'm writing an app that uses an NSTask to spawn a long-lived process.
When my app is force-quit or otherwise SIGKILLed, the spawned process
gets re-parented and hangs around indefinitely. I was hoping to use
process groups to tackle this, but although setpgid() reports success,
it doesn't seem to have had any effect. Here is the code I am using:

myTask = [[NSTask alloc] init];

// ...snipped code for setting up path, args, pipes for
stdin/stdout/stderr, etc...

pid_t pgrp = setpgrp();
if (pgrp < 0)
{
NSLog(@"could not create new pgrp");
pgrp = getpgrp();
}

[myTask launch];

pid_t taskpid = [myTask processIdentifier];
int res = setpgid(taskpid, pgrp);
pid_t newpgrp = getpgid(taskpid);
NSLog(@"pgrp = %d, res = %d, newpgrd = %d", pgrp, res, newpgrp);

The call to setpgrp() is successful (the parent process has the same
pgid as its pid) and the NSLog reports "pgrp = 3166, res = 0, newpgrd
= 3166". However, "ps -xj" reports that the child process does not
have 3166 as its pgid (FWIW, it has pid/ppid/pgid 3167/3166/3167).

What am I missing here? Has anyone else had any success setting the
process group on a process spawned using NSTask?

Thanks,
Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Hamish Allan
On Tue, Mar 11, 2008 at 11:16 PM, Karl Moskowski
<[EMAIL PROTECTED]> wrote:

>  Do processes run by launchd automatically write their preference
>  plists to /Library/Preferences/ using NSUserDefaults?

If they're running as root, probably; but NSUserDefaults saves you
from having to care about such things.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quit application when window closes

2008-03-11 Thread Felipe Monteiro de Carvalho
Thanks for the answers, this indeed works very well. Delegates are
quite easy to work with!

But what if I wanted to have a "main window". i.e. the application
only closes when this window is closed? I did a small search, and I
see I can set a delegate for windowWillClose, but I wonder if this is
the best way to do this ...

thanks a lot =)
-- 
Felipe Monteiro de Carvalho
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask and process group IDs

2008-03-11 Thread Nir Soffer


On Mar 12, 2008, at 01:24, Hamish Allan wrote:


I'm writing an app that uses an NSTask to spawn a long-lived process.
When my app is force-quit or otherwise SIGKILLed, the spawned process
gets re-parented and hangs around indefinitely. I was hoping to use
process groups to tackle this, but although setpgid() reports success,
it doesn't seem to have had any effect. Here is the code I am using:

myTask = [[NSTask alloc] init];

// ...snipped code for setting up path, args, pipes for
stdin/stdout/stderr, etc...

pid_t pgrp = setpgrp();
if (pgrp < 0)
{
NSLog(@"could not create new pgrp");
pgrp = getpgrp();
}

[myTask launch];

pid_t taskpid = [myTask processIdentifier];
int res = setpgid(taskpid, pgrp);
pid_t newpgrp = getpgid(taskpid);
NSLog(@"pgrp = %d, res = %d, newpgrd = %d", pgrp, res, newpgrp);

The call to setpgrp() is successful (the parent process has the same
pgid as its pid) and the NSLog reports "pgrp = 3166, res = 0, newpgrd
= 3166". However, "ps -xj" reports that the child process does not
have 3166 as its pgid (FWIW, it has pid/ppid/pgid 3167/3166/3167).

What am I missing here? Has anyone else had any success setting the
process group on a process spawned using NSTask?


I also failed to do this :-)

My solution was to open a pipe to the child process, and have the  
child process read from the pipe in the background. When the parent  
process die, the pipe will be closed and the child can quit.



Best Regards,

Nir Soffer

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Chris Suter


On 12/03/2008, at 10:16 AM, Karl Moskowski wrote:


Why not do it the other way round? Update settings via distributed
objects, and have the daemon write them to /Library/Preferences.


Good idea. Thanks, Hamish.


I'm not so sure it's a good idea. The problem is that it relies on  
your daemon running which whilst might be true most of the time, it  
might not be—if it's restarting for example. I personally would write  
the defaults from the GUI application.


Do processes run by launchd automatically write their preference  
plists to /Library/Preferences/ using NSUserDefaults?


No I don't think they will. If you're running as root, preferences  
will get written to /var/root/Library/Preferences which is not what  
you want.


To write to /Library/Preferences I think you'll need to use  
CFPreferencesSetValue.


If you can get away with it you could just periodically check to see  
if the defaults have changed. A Cocoa application will periodically  
synchronise the defaults but you'll still have to check to see if  
anything has changed. If that doesn't work for you, you can use  
distributed objects as you've suggested or you can use any of the  
other IPC mechanisms available to you.


- Chris



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 [EMAIL PROTECTED]

Re: Launch Daemon Best Practices?

2008-03-11 Thread Hamish Allan
On Wed, Mar 12, 2008 at 12:18 AM, Chris Suter
<[EMAIL PROTECTED]> wrote:

>  I'm not so sure it's a good idea. The problem is that it relies on
>  your daemon running which whilst might be true most of the time, it
>  might not be—if it's restarting for example. I personally would write
>  the defaults from the GUI application.

That's fine as long as the background app is actually a user agent,
but Karl described it as a daemon. So whose defaults should the GUI
app write to? If it's going to write to /Library/Preferences, it's
going to need authorization -- though maybe it will need that anyway.

While the daemon is restarting, you can simply disable all controls
that could change the defaults. Whether or not it makes sense to allow
changes without asking the daemon depends on what sort of task the
daemon is performing.

>  No I don't think they will. If you're running as root, preferences
>  will get written to /var/root/Library/Preferences

True.

>  which is not what you want.

Probably not, but then again it may not be important.

>  To write to /Library/Preferences I think you'll need to use
>  CFPreferencesSetValue.

Or you could probably set up your own NSUserDefaults with only
NSGlobalDomain in its search list, instead of using
standardUserDefaults.

>  If you can get away with it you could just periodically check to see
>  if the defaults have changed.

If you don't care whether or not the GUI has the latest information
about the daemon, I really can't see that you'd care about something
like disabling the controls whilst the daemon is restarting.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread Kevin Dixon
>
> On Mar 11, 2008, at 3:03 PM, Kevin Dixon wrote:
>
>> I'm using an NSTableView, and I want to be able to remove items from
>> the
>> list by pressing the delete key on the keyboard. What is the
>> procedure to
>> receive a message when a key is pressed and the table view has focus?
>
>
> Subclass NSTableView and override "-keyDown:". There should be several
> implementations of this online that you could take a look at.
>
> j o a r

I have implemented -keyDown as such

if([theEvent type] == NSKeyDown) {
if([theEvent keyCode] == 51) {
//process 'delete' press
}
}

to catch the pressing of delete on the NSTableView. This works, but
reminds me of BASIC...Is there a better way to do this, to make sure I'm
getting the delete key, say even on international keyboards?

-Kevin
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSTask and process group IDs

2008-03-11 Thread Hamish Allan
On Tue, Mar 11, 2008 at 11:53 PM, Nir Soffer <[EMAIL PROTECTED]> wrote:

> My solution was to open a pipe to the child process, and have the child
> process read from the pipe in the background. When the parent process die,
> the pipe will be closed and the child can quit.

Good idea. I might attempt a category on NSTask to do this! If so,
I'll post it here.

Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread mmalc crawford


On Mar 11, 2008, at 3:59 PM, j o a r wrote:



On Mar 11, 2008, at 3:49 PM, Quincey Morris wrote:

Personally I prefer the factory method approach, a la [NSArray  
array] etc:


Note that factory class methods typically also return id for the  
same reason that init methods return id (NSArray, NSString, et.c.).
This in contrast to shared instances that are strongly typed  
(NSFileManager, NSHost, NSNull, et.c.).


Moreover, a problem with using the "factory method approach" is that  
they return autoreleased objects.
If you have a particular need to be concerned about performance (as  
you might especially in a resource-constrained environment), it is  
generally a Good Thing to avoid autorelease and instead use alloc/ 
release directly.


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 [EMAIL PROTECTED]


Re: NSTableView + delete button?

2008-03-11 Thread j o a r


On Mar 11, 2008, at 5:47 PM, Kevin Dixon wrote:






to catch the pressing of delete on the NSTableView. This works, but
reminds me of BASIC...Is there a better way to do this, to make sure  
I'm

getting the delete key, say even on international keyboards?



See "NSDeleteCharacter" and similar in NSText.h (and in the  
documentation).


j o a r


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread Quincey Morris


On Mar 11, 2008, at 17:56, mmalc crawford wrote:

Moreover, a problem with using the "factory method approach" is that  
they return autoreleased objects.
If you have a particular need to be concerned about performance (as  
you might especially in a resource-constrained environment), it is  
generally a Good Thing to avoid autorelease and instead use alloc/ 
release directly.


There's no reason why it can't be named "create..." and return a  
retained object, if that's what's needed in any given situation.


Perhaps I shouldn't have used the expression "factory method", since I  
didn't mean it had to be done exactly the way a frameworks factory  
method might.



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Karl Moskowski


On 11-Mar-08, at 8:18 PM, Chris Suter wrote:



On 12/03/2008, at 10:16 AM, Karl Moskowski wrote:


Why not do it the other way round? Update settings via distributed
objects, and have the daemon write them to /Library/Preferences.


Good idea. Thanks, Hamish.


I'm not so sure it's a good idea. The problem is that it relies on  
your daemon running which whilst might be true most of the time, it  
might not be—if it's restarting for example. I personally would  
write the defaults from the GUI application.


Do processes run by launchd automatically write their preference  
plists to /Library/Preferences/ using NSUserDefaults?


No I don't think they will. If you're running as root, preferences  
will get written to /var/root/Library/Preferences which is not what  
you want.


Why would that location be wrong?

To write to /Library/Preferences I think you'll need to use  
CFPreferencesSetValue.


If you can get away with it you could just periodically check to see  
if the defaults have changed. A Cocoa application will periodically  
synchronise the defaults but you'll still have to check to see if  
anything has changed. If that doesn't work for you, you can use  
distributed objects as you've suggested or you can use any of the  
other IPC mechanisms available to you.



After Hamish's original response, I thought the way to go would be to  
create a proxy object that behaves like NSUserDefaults (KVC- and KVO- 
compliant, so it can be wired up in IB) but really just interacts with  
a corresponding object in the daemon from DO. That way, the daemon's  
settings are fresh, and the UI always reflects the correct state.


(Anyway, I did find some Panther-era posts to cocoa-dev asking about  
writing to /Library/Preferences/. The response then was that  
CFPreferencesSetValue was the way to go, and requests for enhancement  
to NSUserDefaults had been filed. I was hoping they had been met and I  
was just missing something.)


BTW, which Xcode project template would be most appropriate for this  
type of launch daemon? CoreFoundation Tool or  CoreServices Tool?


--Karl.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Launch Daemon Best Practices?

2008-03-11 Thread Chris Suter


On 12/03/2008, at 12:39 PM, Karl Moskowski wrote:


Why would that location be wrong?


If your preferences aren't user specific, I don't think they should be  
there. You also shouldn't be running your daemon as root unless you  
absolutely have to.


After Hamish's original response, I thought the way to go would be  
to create a proxy object that behaves like NSUserDefaults (KVC- and  
KVO-compliant, so it can be wired up in IB) but really just  
interacts with a corresponding object in the daemon from DO. That  
way, the daemon's settings are fresh, and the UI always reflects the  
correct state.


As I said, I don't think it's a good idea to control your daemon  
directly from the UI. If your daemon isn't running, you can't use the  
UI to change the preferences. Likewise, if it crashes whilst you're  
trying to change something or if it's slow in responding you have to  
handle that. I personally think you'd be better off writing the  
preferences and then telling your daemon to refresh.


If you need to get state information out of your daemon, then  
distributed objects is one way of doing it, but I would put that kind  
of communication on a separate thread in case your daemon becomes  
unresponsive for whatever reason. If you just need to find out whether  
your daemon is running, you could just write a file containing the pid  
to /var/run like other daemons do. You can then trigger a refresh by  
sending SIGHUP. Doing things this way allows you to completely control  
your daemon from the command line which can be desirable for testing  
and server scenarios.


BTW, which Xcode project template would be most appropriate for this  
type of launch daemon? CoreFoundation Tool or  CoreServices Tool?


I don't know. I doubt there's much difference between the two. It's  
easy enough to add other frameworks as you need them.


Anyway, this is straying off Cocoa a bit so replies should probably be  
off-list.


Kind regards,

Chris



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 [EMAIL PROTECTED]

Controlling line tightening

2008-03-11 Thread John Stiles
I'm using line tightening in some of my dialogs and 99% of the time it 
works great, but there are a few aspects of it that don't work for my 
app. In particular, when line tightening kicks in, first it attempts to 
shrink the text to fit the box, which is awesome. But when it still 
doesn't fit even when shrunk, it disables tightening and appends an 
ellipsis, and this ellipsis is problematic for me.


I'd like to change it so that when the text doesn't fit, it just 
tightens it to the maximum tightness allowed and displays as much text 
as possible. Or at the very least, I'd like to disable the ellipsis.


I have a text field which in some circumstances can tighten, and that's 
by design. In very extreme circumstances it will still be too much text. 
(Before you say "increase the tightening threshold," well, that just 
makes the circumstances at which it will fail even more extreme.) This 
is not a big problem, but I don't want to see the ellipsis, since it 
ends up truncating even more text, meaning that instead of only losing 
one or two characters at the end of my string, I lose five or six… which 
suddenly turns a tiny problem into a big one.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Controlling line tightening

2008-03-11 Thread John Stiles

Whoops, this is easy!
   [myParagraphStyle setLineBreakMode:NSLineBreakByClipping];

I guess I didn't get enough sleep last night :)
I don't think this completely addresses my question—when the text field 
gets too full, it looks like it does lose its tightening—but it's good 
enough for my needs. The ellipsis was the big problem.



John Stiles wrote:
I'm using line tightening in some of my dialogs and 99% of the time it 
works great, but there are a few aspects of it that don't work for my 
app. In particular, when line tightening kicks in, first it attempts 
to shrink the text to fit the box, which is awesome. But when it still 
doesn't fit even when shrunk, it disables tightening and appends an 
ellipsis, and this ellipsis is problematic for me.


I'd like to change it so that when the text doesn't fit, it just 
tightens it to the maximum tightness allowed and displays as much text 
as possible. Or at the very least, I'd like to disable the ellipsis.


I have a text field which in some circumstances can tighten, and 
that's by design. In very extreme circumstances it will still be too 
much text. (Before you say "increase the tightening threshold," well, 
that just makes the circumstances at which it will fail even more 
extreme.) This is not a big problem, but I don't want to see the 
ellipsis, since it ends up truncating even more text, meaning that 
instead of only losing one or two characters at the end of my string, 
I lose five or six… which suddenly turns a tiny problem into a big one.


___

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

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

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

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Controlling line tightening

2008-03-11 Thread John Stiles

Gah, I spoke too soon.
This "solution" actually disables tightening entirely. So I'm back to 
square one. Please help!


John Stiles wrote:

Whoops, this is easy!
   [myParagraphStyle setLineBreakMode:NSLineBreakByClipping];

I guess I didn't get enough sleep last night :)
I don't think this completely addresses my question—when the text 
field gets too full, it looks like it does lose its tightening—but 
it's good enough for my needs. The ellipsis was the big problem.



John Stiles wrote:
I'm using line tightening in some of my dialogs and 99% of the time 
it works great, but there are a few aspects of it that don't work for 
my app. In particular, when line tightening kicks in, first it 
attempts to shrink the text to fit the box, which is awesome. But 
when it still doesn't fit even when shrunk, it disables tightening 
and appends an ellipsis, and this ellipsis is problematic for me.


I'd like to change it so that when the text doesn't fit, it just 
tightens it to the maximum tightness allowed and displays as much 
text as possible. Or at the very least, I'd like to disable the 
ellipsis.


I have a text field which in some circumstances can tighten, and 
that's by design. In very extreme circumstances it will still be too 
much text. (Before you say "increase the tightening threshold," well, 
that just makes the circumstances at which it will fail even more 
extreme.) This is not a big problem, but I don't want to see the 
ellipsis, since it ends up truncating even more text, meaning that 
instead of only losing one or two characters at the end of my string, 
I lose five or six… which suddenly turns a tiny problem into a big one.


___

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

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

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

This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Problem with NSDragPboard

2008-03-11 Thread Jamie Phelps
Hi, all. I am working on the Hillegass chapter that covers drag and  
drop, and I have the following method in my code.


- (void)writeStringToPasteboard:(NSPasteboard *)pb {
NSLog(@"Writing %@ to pasteboard [EMAIL PROTECTED]",self.string, pb);
// Copy string data to the pasteboard.
[pb setString:self.string
  forType:NSStringPboardType];
NSLog(@"%@",[pb stringForType:NSStringPboardType]);
}

Copy and paste work as expected, but drag and drop does not. It pastes  
a J every time. (The code handles only one character at a time.) When  
using drag and drop, the above code writes out the correct string to  
the console in the first NSLog call but the last one prints the J  
again. Can anyone offer any thoughts about where I might be going  
wrong in implementing my drag and drop code?


Thanks,
Jamie
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSURLDownload and userInfo

2008-03-11 Thread Adam Leonard

Hi,
Oh, sorry, replace everything in that message with NSURLDownload, same  
idea.
I agree with your original approach, especially if you just need to  
store an int (or an NSNumber in this case).


There is a reason almost every delegate method in Cocoa passes the  
delegate object as a parameter, and I am surprised NSURLDownload and  
NSURLRequest do not have userInfo ivars like many other Cocoa classes  
that do asynchronous operations (NSTimer for instance). In my opinion,  
subclassing is the simplest, most MVC compliant, and most Cocoa like  
solution.


While I agree that for more complicated situations, multiple classes  
might be the best solution, I do not think it should be done in this  
case. You don't have to search through an array to match a connection  
with data that is irrevocably tied to that connection. Also, one of  
the purposes of subclassing is to prevent having to create wrapper  
classes. The data is tied to the NSURLDownload object itself, and  
there is no need to do any extra work to get it in one of the delegate  
methods.



Adam Leonard


On Mar 11, 2008, at 6:37 AM, Trygve Inda wrote:


Or, yet another solution:
Just subclass NSURLConnection (say MyUserInfoURLConnection), add a
userInfo ivar, drop in some accessors, and you are good to go. :)
[userInfoConnection userInfo];



My code is:

NSURLRequest*urlRequest = [NSURLRequest requestWithURL:theURL
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];

NSURLDownload*urlDownload = [[NSURLDownload alloc]
initWithRequest:urlRequest delegate:self];

[urlDownload setDestination:path allowOverwrite:YES];

Where then can I specify that it use a custom NSURLConnection class?  
This is

why my initial approach was to use a custom NSURLDownload class.

Trygve



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Working with large files and Memory

2008-03-11 Thread Carl McIntosh
Thank you to both for your good advice. I will look into this.
Carl.
 
On Tuesday, March 11, 2008, at 04:49PM, "Jens Alfke" <[EMAIL PROTECTED]> wrote:
>
>On 11 Mar '08, at 10:18 AM, Jean-Daniel Dupas wrote:
>
>> The first advice I can give you is "do not load the whole file into  
>> memory".
>
>Absolutely.
>
>> Use read stream to read chunk of data and process them. (see  
>> NSInputStream or NSFileHandle).
>
>Or if the file is simple ascii text with newlines, you can use basic C  
>stdio calls (fopen, fgets, fclose) to read a line at a time. You can  
>either convert the line into an NSString, or just use something like  
>sscanf to parse it.
>
>In rare situations where you absolutely do have to load a huge file  
>into memory, i.e. for an algorithm that requires random access, your  
>best bet is to memory-map it. -[NSData  
>dataWithContentsOfFile:options:] has an option flag to map the file.  
>This will avoid a lot of copying, but it's still subject to the same  
>address-space limit if your process is 32-bit, so don't expect to be  
>able to load anything much over a gigabyte.
>
>?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 [EMAIL PROTECTED]


Prevent click through (Tiger and Leopard)

2008-03-11 Thread Marc Respass

Hi All,

I am confused about how to prevent click through. My document puts up  
a window when a button is clicked. I disable the button then display  
the other window. If the user clicks off the other window (it resigns  
key), then I close it and re-enable the button. But the main window  
becomes active and my button is enabled too soon. The button is  
disabled but if I click on it when it's disabled, it becomes enabled  
in time to receive the click. FWIW, Xcode exhibits this behavior with  
the "Show Editor" button in the toolbar. The button is disabled but  
clicking it still works.


Any tips? I need the app to work in Tiger and Leopard and I'm  
developing on Leopard.


Thanks a lot
Marc
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Problem with NSDragPboard

2008-03-11 Thread Dave Hersey
The only thing I can see is that the docs say that you need to send  
the pasteboard the "types" or "availableTypeFromArray:" selectors  
before sending "stringForType:", so maybe you're getting screwy log  
results without that. Does it change if you add a [pb types]; before  
the last NSLog?


- d

On Mar 11, 2008, at 11:13 PM, Jamie Phelps wrote:

Hi, all. I am working on the Hillegass chapter that covers drag and  
drop, and I have the following method in my code.


- (void)writeStringToPasteboard:(NSPasteboard *)pb {
   NSLog(@"Writing %@ to pasteboard [EMAIL PROTECTED]",self.string, pb);
   // Copy string data to the pasteboard.
   [pb setString:self.string
 forType:NSStringPboardType];
   NSLog(@"%@",[pb stringForType:NSStringPboardType]);
}

Copy and paste work as expected, but drag and drop does not. It  
pastes a J every time. (The code handles only one character at a  
time.) When using drag and drop, the above code writes out the  
correct string to the console in the first NSLog call but the last  
one prints the J again. Can anyone offer any thoughts about where I  
might be going wrong in implementing my drag and drop code?


Thanks,
Jamie

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Prevent click through (Tiger and Leopard)

2008-03-11 Thread Jens Alfke


On 11 Mar '08, at 9:36 PM, Marc Respass wrote:


I am confused about how to prevent click through.


I don't _think_ this is related to "click-through", as in buttons in  
inactive windows still responding to clicks. Click-through doesn't  
happen for buttons explicitly marked as disabled.


My document puts up a window when a button is clicked. I disable the  
button then display the other window. If the user clicks off the  
other window (it resigns key), then I close it and re-enable the  
button.


That's kind of a nonstandard UI. I would not expect a window to  
disappear just because I clicked in another window of the same app. I  
could see a user getting really frustrated by this behavior; are you  
sure it's what you want?


But the main window becomes active and my button is enabled too  
soon. The button is disabled but if I click on it when it's  
disabled, it becomes enabled in time to receive the click.


It sounds like the order of events is
- Click in main window causes it to activate
- Your code responds to the activation by closing the extra window and  
enabling the button
- Main window dispatches the click to the button, which handles it  
because it's now enabled.


If you really don't want this to happen, you could slightly delay the  
re-enabling of the button via a perform-after-delay, i.e. [self  
performSelector: @selector(reEnableTheButton) withObject: nil  
afterDelay: 0.0].


—Jens

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 [EMAIL PROTECTED]

Re: Problem with NSDragPboard

2008-03-11 Thread Jens Alfke


On 11 Mar '08, at 8:13 PM, Jamie Phelps wrote:


   // Copy string data to the pasteboard.
   [pb setString:self.string
 forType:NSStringPboardType];


You need to declare the type(s) on the pasteboard, before setting the  
data.


—Jens

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 [EMAIL PROTECTED]

Re: warning: assignment from distinct Objective-C type

2008-03-11 Thread mmalc crawford


On Mar 11, 2008, at 6:11 PM, Quincey Morris wrote:

Moreover, a problem with using the "factory method approach" is  
that they return autoreleased objects.
If you have a particular need to be concerned about performance (as  
you might especially in a resource-constrained environment), it is  
generally a Good Thing to avoid autorelease and instead use alloc/ 
release directly.


There's no reason why it can't be named "create..." and return a  
retained object, if that's what's needed in any given situation.


Following standard Cocoa conventions (), the name would be "new..." (and this is a pattern used in some  
recent code samples).
But the example you gave, and the most common case in the current  
frameworks, is to return an autoreleased object, and it's worth  
bringing this issue to others' attention.


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 [EMAIL PROTECTED]


  1   2   >