Re: Hard calculation crashes after 60Minutes

2008-08-31 Thread Nathan Vander Wilt

On Aug 30, 2008, at 8:08 PM, Mr. Gecko wrote:
Hello I am making a program that does a really hard calculation and  
it seems to crash after 60 Minutes. I don't really know why it does,  
I am guessing it is because I am using a for loop that takes awhile  
to run


If you can't find any leaks, it may be that autoreleased objects are  
not really "leaking", but your code does not give the framework- 
supplied autorelease pool a chance to release the objects it owns. You  
should create a pool of your own around the top and bottom of your  
loop's block:


for (long_time) {
NSAutoreleasePool* myPool = [NSAutoreleasePool new];
// do stuff
[myPool release];   // or you could use [myPool drain] if 
on 10.4+
}


hope this helps,
-natevw
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Target change problem

2008-08-31 Thread Caleb Strockbine

On Aug 30, 2008, at 12:30 AM, [EMAIL PROTECTED] wrote:


A program I have developed will not run on a PPC machine (G5
iMac) using OS 10.4.11. It was developed on Xcode 3.0 on an Intel
machine running OS 10.5.4. Initially the projects "Cross_Develop
Using Target SDK" was set to "Current Mac OS", so it's not surprising
that it wouldn't run on the G5 machine. When I changed the target SDK
to Mac OS 10.4 (Universal), "cleaned" the project, and rebuilt it,
the G5 PPC still would not run it.
  I suspect there is still some setting in XCode that I need to
change, but I don't see anything obvious. Other programs that I've
developed with the same system do run nicely on the G5. Their Target
SDK setting started out set to 10.4 (Universal).



James-

I don't have Xcode 3 available just now, so I'm not certain that my  
advice applies, but in Xcode 2 there's an "Architectures" build  
setting that by default is set to $(NATIVE_ARCH), which on your Intel  
machine will be 'i386'. You probably want to build a universal  
binary, so double-click the Architectures line and make sure that  
both PowerPC and Intel are selected. Once you dismiss that sheet, the  
value next to Architectures should be 'ppc i386'.


You may want to see the "Building a Universal Binary" document for  
more information:


http://developer.apple.com/documentation/MacOSX/Conceptual/ 
universal_binary/universal_binary_compiling/chapter_2_section_3.html


cheers,

Caleb
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Target change problem

2008-08-31 Thread Kyle Sluder
On Fri, Aug 29, 2008 at 7:23 PM, James Pengra <[EMAIL PROTECTED]> wrote:
> I suspect there is still some setting in XCode that I need to change,
> but I don't see anything obvious. Other programs that I've developed with
> the same system do run nicely on the G5. Their Target SDK setting started
> out set to 10.4 (Universal).

1) You need to change the target deployment architecture to include
ppc as well as x86.
2) Make sure you're compiling a Release build, not a Debug build.
Machines that don't have Xcode installed can't run Debug builds, even
if you've set the architecture correctly.

--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: (Newbie) How do Multiple NSWindowControllers find MyDocument?

2008-08-31 Thread Kyle Sluder
On Sat, Aug 30, 2008 at 10:47 PM, John Velman <[EMAIL PROTECTED]> wrote:
> Thanks.  I think the self.document method you describe will do it for me.
> This is part of the syntax (and a relation) that I'd missed.  So much
> to learn!

self.document is a dot-syntax accessor, which the compiler seamlessly
translates to [self document].  This is convenient when you do
something like self.document.myProperty, because it saves you two
levels of square brackets.  This is a new feature of Objective-C 2.0,
but is nothing more than syntactic sugar.

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


accessing netinfo db from cocoa?

2008-08-31 Thread Kieren Eaton

Hi,

I am trying to find a way to access the netinfo DB from cocoa.   
Specifically the sharing (AFP, SMB, etc).
know that server has the command line util 'sharing' for just this  
purpose.
unfortunately this command is not available in the Client version of  
os x :(


the reason i need this is because my app has a client side (on one  
mac) which passes a reference (the name) of a shared resource back to  
the server side (on another mac) where the shared resource is based/ 
shared from.
The server then sends update messages to the client that something has  
changed on the resource.


so the server side needs to find out what (if any) shared resources  
are available and their alias's and full paths.


Pointers or ideas are much appreciated.

Kieren

Olearia - Talking Books on the Mac
http://olearia.googlecode.com/




___

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

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

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

This email sent to [EMAIL PROTECTED]


NSURLConnection nil result (only on 10.4)

2008-08-31 Thread dexter morgan
Hello List,
I'm using NSURLConnection/NSURLRequest in order to download some pages
from the web.
My app should be compatible both with 10.4 and 10.5.
However I've noticed a strange behavior only on 10.4: the method -
(void)connection:(NSURLConnection *)connection didReceiveData:(NSData
*)data {
never called and my _receivedData object still empty.
The result on - (void)connectionDidFinishLoading:(NSURLConnection
*)connection  method is a nil content.

The code is:

_request = [[NSMutableURLRequest alloc] initWithURL: _url];
[_request setHTTPMethod: @"POST"];
[_request setHTTPShouldHandleCookies: YES];

// setup user agent (standard mode or custom)
[_request setValue: ([_options objectForKey: @"CURLOPT_USERAGENT"] == 
nil ?
 STEALTH_USERAGENT :
 [_options objectForKey: 
@"CURLOPT_USERAGENT"])
forHTTPHeaderField:@"User-Agent"];  

// init session data container
[_receivedData release];
_receivedData= [[NSMutableData alloc] init];

// create a new connection
[_connection release];  
_connection = [[[NSURLConnection alloc] initWithRequest: _request
delegate: self] retain];

All works fine on 10.5.
I've also noticed that this error happends only for certain address.
For example this works fine:
http://www.tim.it/consumer/homepage.do

while these not:
https://www.190.it/190/trilogy/jsp/login.do
http://www.tele2internet.it/clogin.phtml
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSURLConnection nil result (only on 10.4)

2008-08-31 Thread dexter morgan
I've solved the problem... on 10.4 does not follow redirects so you
need to implement something like this.

-(NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse {
NSMutableURLRequest *newRequest = [request mutableCopy];
// returned request has had the UA field stripped, must fix
[newRequest setTimeoutInterval:15.0];
[newRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData];
return newRequest;
}


On Sun, Aug 31, 2008 at 12:27 PM, dexter morgan <[EMAIL PROTECTED]> wrote:
> Hello List,
> I'm using NSURLConnection/NSURLRequest in order to download some pages
> from the web.
> My app should be compatible both with 10.4 and 10.5.
> However I've noticed a strange behavior only on 10.4: the method -
> (void)connection:(NSURLConnection *)connection didReceiveData:(NSData
> *)data {
> never called and my _receivedData object still empty.
> The result on - (void)connectionDidFinishLoading:(NSURLConnection
> *)connection  method is a nil content.
>
> The code is:
>
>_request = [[NSMutableURLRequest alloc] initWithURL: _url];
>[_request setHTTPMethod: @"POST"];
>[_request setHTTPShouldHandleCookies: YES];
>
>// setup user agent (standard mode or custom)
>[_request setValue: ([_options objectForKey: @"CURLOPT_USERAGENT"] == 
> nil ?
> STEALTH_USERAGENT :
> [_options objectForKey: 
> @"CURLOPT_USERAGENT"])
>forHTTPHeaderField:@"User-Agent"];
>
>// init session data container
>[_receivedData release];
>_receivedData= [[NSMutableData alloc] init];
>
>// create a new connection
>[_connection release];
>_connection = [[[NSURLConnection alloc] initWithRequest: _request
> delegate: self] retain];
>
> All works fine on 10.5.
> I've also noticed that this error happends only for certain address.
> For example this works fine:
> http://www.tim.it/consumer/homepage.do
>
> while these not:
> https://www.190.it/190/trilogy/jsp/login.do
> http://www.tele2internet.it/clogin.phtml
>
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


activateIgnoringOtherApps

2008-08-31 Thread Chris Idou

I want to pop up a window in response to a hot key. So I'm creating a window, 
setting it makeKeyAndOrderFront, and I'm calling [NSApp 
activateIgnoringOtherApps] so that it gets focus.

The thing is, activateIgnoringOtherApps seems to bring ALL my app's windows in 
front of other windows (my app has other windows), whereas all I want is to pop 
up my new window in front of the currently active application without affecting 
the order of my app's other windows, and leaving the previously active app to 
be second to top.

Has anyone got any idea how to achieve that?




  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: accessing netinfo db from cocoa?

2008-08-31 Thread Andrew Merenbach

On Aug 31, 2008, at 1:57 AM, Kieren Eaton wrote:


Hi,

I am trying to find a way to access the netinfo DB from cocoa.   
Specifically the sharing (AFP, SMB, etc).
know that server has the command line util 'sharing' for just this  
purpose.
unfortunately this command is not available in the Client version of  
os x :(


the reason i need this is because my app has a client side (on one  
mac) which passes a reference (the name) of a shared resource back  
to the server side (on another mac) where the shared resource is  
based/shared from.
The server then sends update messages to the client that something  
has changed on the resource.


so the server side needs to find out what (if any) shared resources  
are available and their alias's and full paths.


Pointers or ideas are much appreciated.

Kieren



Hi!  I unfortunately believe that what you are doing will be  
impossible, at least if you're using Leopard.  To my knowledge, the  
NetInfo database system has been completely deprecated and removed  
from Mac OS X as of Leopard, in favor of other services.  I'm not sure  
what the alternative solution for your case would be, however. :(


Best,
Andrew


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: accessing netinfo db from cocoa?

2008-08-31 Thread Jaime Magiera


On Aug 31, 2008, at 4:57 AM, Kieren Eaton wrote:


Hi,

I am trying to find a way to access the netinfo DB from cocoa.   
Specifically the sharing (AFP, SMB, etc).

Pointers or ideas are much appreciated.



Hello,

Quick question: Are you using Leopard or Tiger machines? On Tiger, you  
can run the commands "niultil" or "nicl" to query the NetInfo database  
from your application. Note that in Leopard, Netinfo has been  
completely deprecated in favor of a local LDAP database. So, if you  
are using Leopard, run the command "dscl" from your application. In  
either case, you'll have to parse the command results in your app.


On Tiger, the path you want to query is...

/config/SharePoints/

On Leopard, the path you want to query is...

 /Local/Default/SharePoints

hope that helps,

Jaime Magiera

Sensory Research
http://www.sensoryresearch.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Hard calculation crashes after 60Minutes

2008-08-31 Thread Caleb Strockbine

On Aug 31, 2008, at 3:13 AM, "Mr. Gecko" <[EMAIL PROTECTED]> wrote:


Hello I am making a program that does a really hard calculation and it
seems to crash after 60 Minutes. I don't really know why it does, I am
guessing it is because I am using a for loop that takes awhile to run
(an estaminet of 120 MInutes every time it loops). so I was hoping
someone will be able to help me fix it.
Here is the error I am getting.
cal(18129,0xa00c9074) malloc: *** mmap(size=16777216) failed (error
code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Trace/BPT trap



Did you set a breakpoint in malloc_error_break? If yes, what did you  
find? If no, doesn't that seem like a good place to start?


cheers,

Caleb.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Subclassing NSCoder

2008-08-31 Thread Meik Schuetz

Dear everyone,
I am trying to create my own NSCoder implementation to serialize  
objects to a XML format which would like to use to communicate with  
WCF service. The serialization is already done and I had no problems  
do it, however I've got some conceptional questions about the de- 
serialization:


Given the serialized XML:

HELLO WORLD
True
12

THIS IS THE SECOND INSTANCE
False
4711

1
2
3


1
2
3



How would you de-serialize the node  (which is a  
composite value of type CompositeType, having the attributes  
stringValue, boolValue, intValue, compositeValue and arrayOfString)?


1) Would you store information about the type in the XML and let the  
NSCoding subclass have the intelligence to create and initialize the  
object (ex. via NSClassFromString)?
2)  Or would you place this intelligence in the entity  
object's :initWithCoder? If so, how would you create and initialize  
the composite object passing the Coder reference?


Hope I made my problem more or less understandable
Best regards
Meik

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: accessing netinfo db from cocoa?

2008-08-31 Thread Phil
On Sun, Aug 31, 2008 at 8:57 PM, Kieren Eaton <[EMAIL PROTECTED]> wrote:
> I am trying to find a way to access the netinfo DB from cocoa.  Specifically
> the sharing (AFP, SMB, etc).
> know that server has the command line util 'sharing' for just this purpose.
> unfortunately this command is not available in the Client version of os x :(
>

You'll probably be able to get the information you want out of the
DirectoryService framework:


Phil
___

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

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

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

This email sent to [EMAIL PROTECTED]


Problem with NSUserDefaultsController

2008-08-31 Thread Mark Allan

Hi,

I've been playing around with bindings to NSUserDefaultsController in 
a very simple app to test saving preferences, but the 
[sharedUserDefaultsController save:self] method seems to return 
immediately without waiting for the save operation to complete.


The save does actually take place, which I can see if I open the 
plist file in Property List Editor, but if the very next line after 
sending the save message is one which reads a property from the 
plist, it's the old value which gets returned rather than the newly 
saved one.


My test app consists of only one window with a slider (whose value is 
bound to the Shared User Defaults Controller), and three buttons: one 
connected to savePrefs, one to revertPrefs, and one to checkValue 
which prints out the slider's value as stored within the model.


Here's the entire code:

-(id)init {
[super init];
	[[NSUserDefaultsController sharedUserDefaultsController] 
setAppliesImmediately:NO];

myPrefs = [NSUserDefaults standardUserDefaults];
[self readPrefs];
return self;
}

-(void) readPrefs{
//[myPrefs synchronize];  //this line doesn't make any difference
theValue = [myPrefs objectForKey:@"thevalue"];
}

-(void) savePrefs:(NSObject *) sender{
// save prefs and close the window
[[NSUserDefaultsController sharedUserDefaultsController] save:self];
[self readPrefs];
}

-(void) checkValue:(NSObject *) sender{
NSLog(@"value is %@",theValue);
}

-(void) revertPrefs:(NSObject *) sender{
// revert and close the window
	[[NSUserDefaultsController sharedUserDefaultsController] 
revert:sender];

}

If I move [self readPrefs] out of the savePrefs method and into 
checkValue, it prints the new value as expected - but I don't want to 
be reading the preferences every time I need to use that particular 
variable.  Can someone explain the right way to do this please?


For what it's worth, I also get these compiler warnings for the line 
with [sharedUserDefaultsController save:]


warning: multiple methods named '-save:' found
warning: using '-(void)save:(id)sender'
warning: also found '-(BOOL)save:(NSError **)error'

Thanks
Mark

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 NSUserDefaultsController

2008-08-31 Thread Keary Suska
8/31/08 10:13 AM, also sprach [EMAIL PROTECTED]:

> I've been playing around with bindings to NSUserDefaultsController in
> a very simple app to test saving preferences, but the
> [sharedUserDefaultsController save:self] method seems to return
> immediately without waiting for the save operation to complete.
> 
> The save does actually take place, which I can see if I open the
> plist file in Property List Editor, but if the very next line after
> sending the save message is one which reads a property from the
> plist, it's the old value which gets returned rather than the newly
> saved one.

The -save: method is unintuitive in name. It does not, as you may think,
save changes to disk. It simply commits any changes to the NSUserDefaults
object. It's a no-op if appliesImmediately is YES. The only way to force a
save is to call -synchronize on NSUserDefaults.

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: Subclassing NSCoder

2008-08-31 Thread Michael Ash
On Sun, Aug 31, 2008 at 11:45 AM, Meik Schuetz <[EMAIL PROTECTED]> wrote:
> Dear everyone,
> I am trying to create my own NSCoder implementation to serialize objects to
> a XML format which would like to use to communicate with WCF service. The
> serialization is already done and I had no problems do it, however I've got
> some conceptional questions about the de-serialization:
>
> Given the serialized XML:
> 
>HELLO WORLD
>True
>12
>
>THIS IS THE SECOND INSTANCE
>False
>4711
>
>1
>2
>3
>
>
>1
>2
>3
>
> 
>
> How would you de-serialize the node  (which is a composite
> value of type CompositeType, having the attributes stringValue, boolValue,
> intValue, compositeValue and arrayOfString)?
>
> 1) Would you store information about the type in the XML and let the
> NSCoding subclass have the intelligence to create and initialize the object
> (ex. via NSClassFromString)?
> 2)  Or would you place this intelligence in the entity object's
> :initWithCoder? If so, how would you create and initialize the composite
> object passing the Coder reference?

You have to store type information in the XML. There's no other place
for you to get it. You can't make that decision in -initWithCoder:,
because -initWithCoder: supposes that you have *already* discovered
the type and allocated an instance of the class in question. It's like
trying to find your friend's phone number by calling him to ask him
what it is.

That said, I'm not sure that NSCoder is a good API for you to use for
this in any case. Your XML looks like it's a typical XML document,
with a tree structure of fairly regular values. NSCoder is an API for
encoding arbitrary object graphs, which can include disconnected sets,
multiple references to a single object, and even cycles. It can encode
arbitrary objects, arbitrary data for those objects, and arbitrary
relationships between them.

NSKeyedArchiver can already produce XML. If you look at it, you'll
find that it's very confusing. This is because of all the features it
supports. Since XML is a tree structure, it has to do some fancy
things to support arbitrary relationships.

So if not NSCoder, then what? I'd suggest a simpler custom API, such
as a general understanding that your classes will implement a
-xmlRepresentation and -initWithXMLRepresentation: method pair,
possibly creating and using NSXMLNode instances. This would allow you
to create and decode XML without needing to go through an NSCoder.

If you still do want to create an NSCoder subclass, then you might
find mine helpful as some sort of guide. It's called MAKeyedArchiver
and you can download it here:

http://www.mikeash.com/?page=software/source.html

It's intended to be a general-purpose archiver which writes to a
custom binary file format, but you may (or may not) find its general
design and approaches to be useful.

If you do take a look at it, you should beware that I wrote it at a
time when I was sure that the PowerPC 32-bit architecture was
immortal, so the code makes a lot of bad assumptions about the size
and endianness of basic data types. It should work fine on i386, but
the archives won't be cross-architecture compatible. It will probably
crash on PPC64 or x86-64.

The need for MAKeyedArchiver has pretty much gone away, since Cocoa's
built-in archivers have gotten a lot faster than they were when I
wrote it. But just in case anyone happens to have a burning desire to
fix the deficiencies I mentioned above, patches are welcome.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Hard calculation crashes after 60Minutes

2008-08-31 Thread Bill Bumgarner

On Aug 31, 2008, at 8:22 AM, Caleb Strockbine wrote:
Did you set a breakpoint in malloc_error_break? If yes, what did you  
find? If no, doesn't that seem like a good place to start?


Probably not.  If it is crashing after 60 minutes, it is quite a bit  
more likely that the problem is in all of the allocations that aren't  
being freed in the other 59.99 minutes of the runtime...


Assuming this is an Objective-C application, make sure that you are  
either not creating any autoreleased objects during the calculation or  
that you are periodically cycling an autorelease pool on the  
calculation thread.  If you are doing that, then this sounds like a  
straightforward leak.


b.bum



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: Subclassing NSCoder

2008-08-31 Thread Meik Schuetz

Dear Michael,
  thank you very much for your valuable information - I definitively  
will have a look at your MAKeyedArchiver, just to learn how it's done.  
The idea of implementing the xmlRespresentation methods is just great  
and serves perfectly.


Once again, thanks a lot for your time.
Best regards
Meik

On Aug 31, 2008, at 6:30 PM, Michael Ash wrote:

On Sun, Aug 31, 2008 at 11:45 AM, Meik Schuetz <[EMAIL PROTECTED]>  
wrote:

Dear everyone,
I am trying to create my own NSCoder implementation to serialize  
objects to
a XML format which would like to use to communicate with WCF  
service. The
serialization is already done and I had no problems do it, however  
I've got

some conceptional questions about the de-serialization:

Given the serialized XML:

  HELLO WORLD
  True
  12
  
  THIS IS THE SECOND INSTANCE
  False
  4711
  
  1
  2
  3
  
  
  1
  2
  3
  


How would you de-serialize the node  (which is a  
composite
value of type CompositeType, having the attributes stringValue,  
boolValue,

intValue, compositeValue and arrayOfString)?

1) Would you store information about the type in the XML and let the
NSCoding subclass have the intelligence to create and initialize  
the object

(ex. via NSClassFromString)?
2)  Or would you place this intelligence in the entity object's
:initWithCoder? If so, how would you create and initialize the  
composite

object passing the Coder reference?


You have to store type information in the XML. There's no other place
for you to get it. You can't make that decision in -initWithCoder:,
because -initWithCoder: supposes that you have *already* discovered
the type and allocated an instance of the class in question. It's like
trying to find your friend's phone number by calling him to ask him
what it is.

That said, I'm not sure that NSCoder is a good API for you to use for
this in any case. Your XML looks like it's a typical XML document,
with a tree structure of fairly regular values. NSCoder is an API for
encoding arbitrary object graphs, which can include disconnected sets,
multiple references to a single object, and even cycles. It can encode
arbitrary objects, arbitrary data for those objects, and arbitrary
relationships between them.

NSKeyedArchiver can already produce XML. If you look at it, you'll
find that it's very confusing. This is because of all the features it
supports. Since XML is a tree structure, it has to do some fancy
things to support arbitrary relationships.

So if not NSCoder, then what? I'd suggest a simpler custom API, such
as a general understanding that your classes will implement a
-xmlRepresentation and -initWithXMLRepresentation: method pair,
possibly creating and using NSXMLNode instances. This would allow you
to create and decode XML without needing to go through an NSCoder.

If you still do want to create an NSCoder subclass, then you might
find mine helpful as some sort of guide. It's called MAKeyedArchiver
and you can download it here:

http://www.mikeash.com/?page=software/source.html

It's intended to be a general-purpose archiver which writes to a
custom binary file format, but you may (or may not) find its general
design and approaches to be useful.

If you do take a look at it, you should beware that I wrote it at a
time when I was sure that the PowerPC 32-bit architecture was
immortal, so the code makes a lot of bad assumptions about the size
and endianness of basic data types. It should work fine on i386, but
the archives won't be cross-architecture compatible. It will probably
crash on PPC64 or x86-64.

The need for MAKeyedArchiver has pretty much gone away, since Cocoa's
built-in archivers have gotten a lot faster than they were when I
wrote it. But just in case anyone happens to have a burning desire to
fix the deficiencies I mentioned above, patches are welcome.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoa%40consjuri.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]


(Newb) Populate NSMutableDictioanry with NSArray

2008-08-31 Thread Jon Davis

I came across tutorial code that looked sort of like this:

NSMutableDictionary * myCollection;
myCollection = [[NSArray alloc] initWithObjects:@"a", @"b", @"c", nil];

The types are not the same. So my first question is, is this a bug?  
And if so, why didn't the compiler catch it? I come from C# so unless  
NSMutableDictionary inherits NSArray this logic would not compile.


If it is not a bug, can someone confirm that NSDictionary is not just  
used for key/value pairs but as simple list types, too? Otherwise, why  
would myCollection above be declared as an NSMutableDictionary?


Thanks,
Jon

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


NSDictionaryController + NSTableView

2008-08-31 Thread Michael Robinson

Hi

I need to use a NSTableView to control data input by the user.  The  
table has two columns, labeled "Title" and "Content".  The number of  
columns is fixed.


I've read what I can find on the internet, but a lot of it goes way  
over my head (I'm fairly new at ObjC and xCode -- coming from Java).


I understand (from assorted hints I've seen online) that one may use a  
NSDictionaryController to handle data input/output/display/saving etc  
from a table.


I really have no idea how to do this, and haven't found a tutorial  
that speaks to my tiny brain.


I was hoping one of you Cocoa masters would have a tip or two?

This is what I've got:

a bunch of code that works (it creates html for a webpage based on  
user selection/input).  a NSTextArea, NSTextField and NSTableView that  
are currently inert.


A NSDictionaryController sitting idle.

I want it to store data in key(title)value(content) pairs.  Initially  
there are no key/vals, until the user creates a new entry.  This  
should be handled by a little '+' button that I've placed below the  
NSTableview.  Removal of the entries should be handled buy the '-'  
button at its side.


I feel confident that I could do all this, if I had any idea where to  
start.  How do I "link" the NSDict... to my *.m *.h files so that I  
can save/load/ otherwise manipulate the data?  How do I shove data  
into the nsdict?  Is it even an instance of nsdictionary?  Do I  
need to make an NSMutableDictionary and somehow introduce them to each  
other?


Any help would be appreciated, I'm stuck in a bit of a hole here.

Thanks,

Mike


We build our computer (systems) the way we build our cities: over  
time, without a plan, on top of ruins


-- Ellen Ullman

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Sending a GET or POST HTTP request with Cocoa

2008-08-31 Thread Sam Schroeder
Hi all,

I'm new to Cocoa development and I'm trying to learn the basics of
sending HTTP GETs and POSTs from Cocoa.  I've been reading up on NSURL
and searching for decent sample code.  However, I've been unable to
find something simple that _just_ explains how to send a GET and
capture the returned results.  My google_fu is weak.  My ultimate goal
is to send and receive XML (or maybe JSON) requests over HTTP, but
first I want to understand simple GETs and POSTs.

Any links or sample code would be greatly appreciated.

--
Thanks,

Sam
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


App names

2008-08-31 Thread John Joyce

When dealing with applications (application bundles) by name or path,
in Cocoa, when does it make a difference whether you use
App Name.app
example:
Front Row.app
or:
/Applications/Front Row.app

versus
App Name
example:
Front Row
or:
/Applications/Front Row


This seems to be pretty important, and I'm curious when and to what  
degree I should be cautious about the naming used in code.
At this time I am mainly concerned about Apple apps themselves that  
should normally be in the system.


Subsequently, is there any difference concerning 10.3 / 10.4 / 10.5 ?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: (Newb) Populate NSMutableDictioanry with NSArray

2008-08-31 Thread Keary Suska
8/31/08 2:34 AM, also sprach [EMAIL PROTECTED]:

> NSMutableDictionary * myCollection;
> myCollection = [[NSArray alloc] initWithObjects:@"a", @"b", @"c", nil];
> 
> The types are not the same. So my first question is, is this a bug?
> And if so, why didn't the compiler catch it? I come from C# so unless
> NSMutableDictionary inherits NSArray this logic would not compile.

Yes, it is a "bug". Because the return type of -initWithObjects is "id",
which can represent any object, the compiler can't know that the types are
incompatible.

IIRC, you should get a compiler warning if you call a method that only
NSArray implements, such as -objectAtIndex:, on the myCollection object.

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-08-31 Thread Keary Suska
8/31/08 10:30 AM, also sprach [EMAIL PROTECTED]:

> I'm new to Cocoa development and I'm trying to learn the basics of
> sending HTTP GETs and POSTs from Cocoa.  I've been reading up on NSURL
> and searching for decent sample code.  However, I've been unable to
> find something simple that _just_ explains how to send a GET and
> capture the returned results.  My google_fu is weak.  My ultimate goal
> is to send and receive XML (or maybe JSON) requests over HTTP, but
> first I want to understand simple GETs and POSTs.
> 
> Any links or sample code would be greatly appreciated.

http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/U
RLLoadingSystem.html

HTH,

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


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-08-31 Thread Jaime Magiera


On Aug 31, 2008, at 12:30 PM, Sam Schroeder wrote:


However, I've been unable to
find something simple that _just_ explains how to send a GET and
capture the returned results.  My google_fu is weak.  My ultimate goal
is to send and receive XML (or maybe JSON) requests over HTTP, but
first I want to understand simple GETs and POSTs.


Hello,

The easiest way for non-network programmers is probably  
NSMutableURLRequest. You simply instantiate an NSMutableURLRequest  
object, set it's URL, set it's HTTP method and away you go.


http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/Reference/Reference.html

- (void)setHTTPMethod:(NSString *)method

hope that helps,

Jaime Magiera

Sensory Research
http://www.sensoryresearch.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Sending a GET or POST HTTP request with Cocoa

2008-08-31 Thread Jaime Magiera



 it's URL, set it's


"its"

Jaime Magiera

Sensory Research
http://www.sensoryresearch.net

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: activateIgnoringOtherApps

2008-08-31 Thread Ken Thomases

On Aug 31, 2008, at 8:48 AM, Chris Idou wrote:

I want to pop up a window in response to a hot key. So I'm creating  
a window, setting it makeKeyAndOrderFront, and I'm calling [NSApp  
activateIgnoringOtherApps] so that it gets focus.


The thing is, activateIgnoringOtherApps seems to bring ALL my app's  
windows in front of other windows (my app has other windows),  
whereas all I want is to pop up my new window in front of the  
currently active application without affecting the order of my app's  
other windows, and leaving the previously active app to be second to  
top.


Has anyone got any idea how to achieve that?


You can use SetFrontProcessWithOptions with  
kSetFrontProcessFrontWindowOnly.


On the other hand, you should generally avoid bringing your  
application to the front except in response to user action/request.   
Ideally, the order of applications and windows is for the user to  
decide.


If you need the user's attention, you can use NSAlert or - 
[NSApplication requestUserAttention:].  (I believe the former uses the  
latter.)


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: App names

2008-08-31 Thread Seth Willits

On Aug 31, 2008, at 1:14 PM, John Joyce wrote:


When dealing with applications (application bundles) by name or path,
in Cocoa, when does it make a difference whether you use
App Name.app
example:
Front Row.app
or:
/Applications/Front Row.app

versus
App Name
example:
Front Row
or:
/Applications/Front Row


This seems to be pretty important, and I'm curious when and to what  
degree I should be cautious about the naming used in code.
At this time I am mainly concerned about Apple apps themselves that  
should normally be in the system.


Subsequently, is there any difference concerning 10.3 / 10.4 / 10.5 ?



If you're dealing with a file path, then of you of course need to  
specify the extension -- it's part of the file name. You've always had  
to, and always will have to.




--
Seth Willits




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: App names

2008-08-31 Thread John Joyce


On Aug 31, 2008, at 4:51 PM, [EMAIL PROTECTED] wrote:




If you're dealing with a file path, then of you of course need to
specify the extension -- it's part of the file name. You've always had
to, and always will have to.



--
Seth Willits


AppleScript certainly doesn't care about extensions on application  
bundles...

Of course that seems to be due to the syntax...
tell application Finder
...

Which is why I am inquiring. There are certainly points in the Mac OS  
that are designed to be more human.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 NSUserDefaultsController

2008-08-31 Thread Mark Allan



On 31 Aug 2008, at 17:25, Keary Suska <> wrote:


8/31/08 10:13 AM, also sprach:


I've been playing around with bindings to NSUserDefaultsController in
a very simple app to test saving preferences, but the
[sharedUserDefaultsController save:self] method seems to return
immediately without waiting for the save operation to complete.

The save does actually take place, which I can see if I open the
plist file in Property List Editor, but if the very next line after
sending the save message is one which reads a property from the
plist, it's the old value which gets returned rather than the newly
saved one.


The -save: method is unintuitive in name. It does not, as you may  
think,
save changes to disk. It simply commits any changes to the  
NSUserDefaults
object. It's a no-op if appliesImmediately is YES. The only way to  
force a

save is to call -synchronize on NSUserDefaults.


Thanks but the problem is actually the exact opposite. The file IS  
being saved - it's the userdefaults object which doesn't contain the  
right value unless there's some short delay between the save and  
objectForKey messages.


Calling -synchronize on the userDefaults object makes no difference.

I'm already setting appliesimmediately to YES so that I can have  
Cancel and OK buttons, and in terms of saving/reverting the plist file  
it's working fine. Do I need to perform some action to connect the  
userdefaults object to the userDefaultsController object?


Mark

Ps. Email on the iPod touch is impossible - it's taken me about 40  
minutes to write this cos the delete button keeps repeating and  
dfeleting half the message!

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: App names

2008-08-31 Thread Kyle Sluder
On Sun, Aug 31, 2008 at 6:07 PM, John Joyce
<[EMAIL PROTECTED]> wrote:
> AppleScript certainly doesn't care about extensions on application
> bundles...
> Of course that seems to be due to the syntax...
> tell application Finder

That's because you're not specifying a bundle name.  You're specifying
an application name.  When the script is compiled, that app name is
converted into the Finder's FourCC and encoded in an Apple Event
struct.

If you are dealing with Apple Events, apps are known by their FourCC.
If you are dealing with file paths, apps are known by their
fully-qualified path (/Applications/TextEdit.app).  If you're dealing
with bundles, they're known by their bundle name (com.apple.TextEdit).
 There are a lot of different namespaces involved.

--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: accessing netinfo db from cocoa?

2008-08-31 Thread Michael Watson
If you want to do it fast, without shell output parsing, and in a way  
that will work on 10.4 *and* 10.5, use the Directory Services C API.  
The downside is that it's more complex than many of the Cocoa APIs  
you're likely used to.


Docs:







Lots of source to learn from (the dscl sources are a good place to  
look for examples):


http://www.opensource.apple.com/darwinsource/Current/DSTools-112/


--
m-s

On 31 Aug, 2008, at 10:43, Jaime Magiera wrote:



On Aug 31, 2008, at 4:57 AM, Kieren Eaton wrote:


Hi,

I am trying to find a way to access the netinfo DB from cocoa.   
Specifically the sharing (AFP, SMB, etc).

Pointers or ideas are much appreciated.



Hello,

Quick question: Are you using Leopard or Tiger machines? On Tiger,  
you can run the commands "niultil" or "nicl" to query the NetInfo  
database from your application. Note that in Leopard, Netinfo has  
been completely deprecated in favor of a local LDAP database. So, if  
you are using Leopard, run the command "dscl" from your application.  
In either case, you'll have to parse the command results in your app.


On Tiger, the path you want to query is...

/config/SharePoints/

On Leopard, the path you want to query is...

/Local/Default/SharePoints

hope that helps,

Jaime Magiera

Sensory Research
http://www.sensoryresearch.net

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
%40bungie.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: App names

2008-08-31 Thread Michael Watson
AppleScript isn't referring to a file path there, it's referring to a  
process name. The actual file name of "Finder" is "Finder.app",  
because it's a folder with an extension of ".app". If you have to  
reference its path or file name, you have to include ".app" because  
it's part of those.


AppleScript gets to be human because it's not dealing with the file  
system.



--
m-s

On 31 Aug, 2008, at 18:07, John Joyce wrote:



On Aug 31, 2008, at 4:51 PM, [EMAIL PROTECTED] wrote:




If you're dealing with a file path, then of you of course need to
specify the extension -- it's part of the file name. You've always  
had

to, and always will have to.



--
Seth Willits


AppleScript certainly doesn't care about extensions on application  
bundles...

Of course that seems to be due to the syntax...
tell application Finder
...

Which is why I am inquiring. There are certainly points in the Mac  
OS that are designed to be more human.

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/mikey-san 
%40bungie.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]


Seemingly Simple Bindings Question

2008-08-31 Thread Jamie Phelps
I have an NSPopUpButton with five menu items: WTD, MTD, QTD, YTD, and  
Specific Dates. What I want to do is show and hide two labels and  
textfields for Start Date and End Date depending on if the Specific  
Dates option is selected.


My first attempt was to do

@property (readonly) BOOL specifyingDateRange;

-(BOOL)specifyingDateRange{
if([dateRangePopUp indexOfSelectedItem] == 4){
return YES;
}
return NO;
}

but this is not working correctly.

Can anyone explain what the correct implementation is and possibly  
what mistake I made in assessing the problem?


Thanks in advance,
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: App names

2008-08-31 Thread Gregory Weston

John Joyce wrote:


When dealing with applications (application bundles) by name or path,
in Cocoa, when does it make a difference whether you use
App Name.app
example:
Front Row.app
or:
/Applications/Front Row.app

versus
App Name
example:
Front Row
or:
/Applications/Front Row

This seems to be pretty important, and I'm curious when and to what
degree I should be cautious about the naming used in code.


What are you really trying to do? If you're trying to access the  
package as a directory, then of course you need to use the real name.  
If you're trying to do something else with it...well it's entirely  
possible you shouldn't care about "the naming used in code" at all.  
It would, for example, not be a best practice to hard-code the string  
"TextEdit.app" into your program.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Seemingly Simple Bindings Question

2008-08-31 Thread Graham Cox


On 1 Sep 2008, at 9:38 am, Jamie Phelps wrote:

I have an NSPopUpButton with five menu items: WTD, MTD, QTD, YTD,  
and Specific Dates. What I want to do is show and hide two labels  
and textfields for Start Date and End Date depending on if the  
Specific Dates option is selected.


My first attempt was to do

@property (readonly) BOOL specifyingDateRange;

-(BOOL)specifyingDateRange{
   if([dateRangePopUp indexOfSelectedItem] == 4){
   return YES;
   }
   return NO;
}

but this is not working correctly.

Can anyone explain what the correct implementation is and possibly  
what mistake I made in assessing the problem?



You probably don't want to tie the functionality to a specific item  
index - it makes it hard to easily change the UI without breaking (or  
needing to revise) the code. Instead, you could use a tag value to  
represent the item's function, or possibly its representedObject.


Not being familiar with bindings, I can't be sure how this relates to  
that, but more conventionally you'd set an action and target for your  
pop-up menu and the action's signature would look like:


- (IBAction)respondToDateRangePopUp:(id) sender
{
if([sender tag] == kTheTagImLookingFor)
[self doSomething];
}


hth,

Graham
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Trouble with Scripting Bridge

2008-08-31 Thread Tommy Nordgren


On 31 aug 2008, at 03.12, Peter Stirling wrote:


Hi,

I've been trying to do some python scripting of iTunes using pyobjc  
and ScriptingBridge, and I've been having some problems (I reduced  
everything to objective-c on its own in order work out if it was  
caused by pyobjc).


According to:

http://developer.apple.com/releasenotes/scriptingautomation/RN-ScriptingBridge/index.html

running:
  sdef /Applications/iTunes.app/ | sdp -f h --basename iTunes

should generate an objective-c header file which you can use in  
conjunction with [SBApplication  
applicationWithBundleIdentifier:@"com.apple.iTunes"]

(which it does).

An excerpt from the file I generated (included in the zip file):

@interface iTunesTrack : iTunesItem
...
@property BOOL gapless;  // is this track from a gapless album?
...
@end

So there should be an accessor method on iTunesTrack objects called  
gapless that returns a BOOL.


[track respondsToSelector:@selector(gapless)] returns YES

However it doesn't seem to work, the code provided in the zip  
archive (when executed on my machine), produces a list of all the  
gapless tracks in my mp3 collection, but every line ALSO claims that  
the track is 'not gapless'.


(The original python code that I was using seemed to get different  
answers depending on ordering of operations, including calling the  
accessor twice in a row on the same object giving different answers).


Am I doing something wrong? The other accessors that I call appear  
to return the right data, though I've not done exhaustive testing.


(As a background to what I'm doing, I want my iTunes playlists  
random except for gapless cds, which I want to be seamless, the  
shuffle provided by itunes can't make that distinction for itself).





From test.m :
  NSPredicate* predicate = [NSPredicate  
predicateWithFormat:@"gapless=YES"];


this should probably be :   . predicateWithFormat:@"gapless==YES"];
---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[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: activateIgnoringOtherApps

2008-08-31 Thread Chris Idou

It looks like if the window I want to popup has NSBorderlessWindowMask set, 
then this API pops up TWO windows, both the one I really want, and the last 
active. On the other hand if it has a title, then it works as expected.

Any thoughts?

BTW, I'm not popping it up uninitiated, it's in response to a hotkey.


--- On Sun, 8/31/08, Ken Thomases <[EMAIL PROTECTED]> wrote:

> From: Ken Thomases <[EMAIL PROTECTED]>
> Subject: Re: activateIgnoringOtherApps
> To: [EMAIL PROTECTED]
> Cc: cocoa-dev@lists.apple.com
> Date: Sunday, August 31, 2008, 2:05 PM
> On Aug 31, 2008, at 8:48 AM, Chris Idou wrote:
> 
> > I want to pop up a window in response to a hot key. So
> I'm creating  
> > a window, setting it makeKeyAndOrderFront, and I'm
> calling [NSApp  
> > activateIgnoringOtherApps] so that it gets focus.
> >
> > The thing is, activateIgnoringOtherApps seems to bring
> ALL my app's  
> > windows in front of other windows (my app has other
> windows),  
> > whereas all I want is to pop up my new window in front
> of the  
> > currently active application without affecting the
> order of my app's  
> > other windows, and leaving the previously active app
> to be second to  
> > top.
> >
> > Has anyone got any idea how to achieve that?
> 
> You can use SetFrontProcessWithOptions with  
> kSetFrontProcessFrontWindowOnly.
> 
> On the other hand, you should generally avoid bringing your
>  
> application to the front except in response to user
> action/request.   
> Ideally, the order of applications and windows is for the
> user to  
> decide.
> 
> If you need the user's attention, you can use NSAlert
> or - 
> [NSApplication requestUserAttention:].  (I believe the
> former uses the  
> latter.)
> 
> Cheers,
> Ken


  
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Seemingly Simple Bindings Question

2008-08-31 Thread Ken Thomases

On Aug 31, 2008, at 6:38 PM, Jamie Phelps wrote:

I have an NSPopUpButton with five menu items: WTD, MTD, QTD, YTD,  
and Specific Dates. What I want to do is show and hide two labels  
and textfields for Start Date and End Date depending on if the  
Specific Dates option is selected.


My first attempt was to do

@property (readonly) BOOL specifyingDateRange;

-(BOOL)specifyingDateRange{
   if([dateRangePopUp indexOfSelectedItem] == 4){
   return YES;
   }
   return NO;
}

but this is not working correctly.

Can anyone explain what the correct implementation is and possibly  
what mistake I made in assessing the problem?


It's hard to know without more details.

My suspicion is that you haven't arranged for any KVO change  
notification to be sent out when this property changes its value.  KVO  
and Bindings do not poll the properties of objects to check if they've  
changed.  There has to be an affirmative notification sent out to  
observers telling them that the property may have changed.  That  
notification is triggered by a message to the object which has the  
property -- either a KVO-compliant setter (preferred) or a pair of  
willChange…/didChange… messages (last resort if your design  
absolutely can't conform to the normal way of doing things).


I assume the above method is in your controller.  It certainly  
shouldn't be in the model.  However, is the mode implied by the pop-up  
expressed in the model?  And is the pop-up's selection bound through  
the controller to that model property?  If so, then I'd recode that  
method to depend on the model property instead of the pop-up view's  
state.  And then I'd use a  
+keyPathsForValuesAffectingSpecifyingDateRange method to inform KVO  
that when the model property changes, that implies a change in the  
specifyingDateRange property of the controller.


If somehow the mode implied by the pop-up isn't a model property, then  
I'd make it a controller property.  You'd still bind the pop-up's  
selection to it, and you'd still use  
+keyPathsForValuesAffectingSpecifyingDateRange to inform the KVO  
system that the two properties are interrelated.


Cheers,
Ken___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Simple Array of Strings Binding Question

2008-08-31 Thread Rob Keniger


On 31/08/2008, at 12:20 PM, Chris Hanson wrote:

More or less expected in hindsight. There's no value of the string  
to set, instead I want to replace the string object in the array.  
So... what do I do? Do I really need to make up a model object to  
contain the string, just to use bindings here? There's absolutely  
_no_ other data I need to associate with the string, so it'd really  
be pointless otherwise.


Bindings are intended to work with model objects, so yes, you will  
need to create a model object "to contain the string."


Think of it this way:  The string probably isn't "just a string."   
It stands for something -- for example, it could be the name of a  
computer.  While the name of a computer might be the only thing  
worth displaying in that particular table, it doesn't mean that  
you're not displaying the name *of a* computer.



An NSArray of NSStrings isn't mutable, so if you want to edit the  
values you need to wrap your NSStrings in some sort of mutable  
container that is KVC-compliant.


One way is to create an NSMutableArray of NSMutableDictionary objects,  
each containing an NSString. You can then bind to the dictionary key  
you've used to store the string and the NSArrayController will be able  
to update your model object.


E.g:

NSString* myStringKey=@"myStringKey";

NSMutableArray* myStrings=[NSMutableArray arrayWithObjects:
			[NSMutableDictionary dictionaryWithObject:@"Foo"  
forKey:myStringKey],
			[NSMutableDictionary dictionaryWithObject:@"Bar"  
forKey:myStringKey],
			[NSMutableDictionary dictionaryWithObject:@"FooBar"  
forKey:myStringKey],

nil];

You then bind to arrangedObjects.myStringKey in your NSTableView.

Using a vanilla NSMutableDictionary as your "model object" is  
preferable to creating a custom object just to hold a string.


--
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: activateIgnoringOtherApps

2008-08-31 Thread Ken Thomases

On Aug 31, 2008, at 7:28 PM, Chris Idou wrote:

It looks like if the window I want to popup has  
NSBorderlessWindowMask set, then this API pops up TWO windows, both  
the one I really want, and the last active. On the other hand if it  
has a title, then it works as expected.


Any thoughts?


Can the window become "main"?  Check out the documentation for - 
[NSWindow canBecomeMainWindow].  By default, windows without title  
bars can't become main.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: activateIgnoringOtherApps

2008-08-31 Thread Ken Thomases

On Aug 31, 2008, at 7:38 PM, Ken Thomases wrote:


On Aug 31, 2008, at 7:28 PM, Chris Idou wrote:

It looks like if the window I want to popup has  
NSBorderlessWindowMask set, then this API pops up TWO windows, both  
the one I really want, and the last active. On the other hand if it  
has a title, then it works as expected.


Any thoughts?


Can the window become "main"?  Check out the documentation for - 
[NSWindow canBecomeMainWindow].  By default, windows without title  
bars can't become main.


Oh, it might also be whether the window can become key.  So, pay  
attention to -canBecomeKeyWindow, too.


Cheers,
Ken
___

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

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

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

This email sent to [EMAIL PROTECTED]


re: Hard calculation crashes after 60Minutes

2008-08-31 Thread Mr. Gecko
I believe I found the problem and it is a function I am using with a  
framework, so what I will do is I will get only the things need to run  
my program from the framework to make my app work and I may not have  
this problem any more.

I will see if that will help and reply.

Thanks,
Mr. Gecko

On Aug 31, 2008, at 8:29 PM, Thomas L. Moore wrote:

I started to write up one possible answer, but I see you haven't  
completed a  loop.  The following is somewhat releated...


If you're using for loops, check to make sure you're not creating  
and autoreleasing objects without an autorelease pool for each  
loop.  For example:


for(i=0;iThe reason is that if you autorelease, it won't free the memory  
until well after your for loop completes.  If you don't, the code  
will slow and  slow and then come to a halt.


...now back to your problem...

You may still be having autorelease issues or other memory handling  
issues.  Try to get rid of autoreleased objects as much as you can.   
Also add some pools where they might make sense.  Also make sure you  
properly free memory as well...


Tom

On Aug 30, 2008, at 10:08 PM, Mr. Gecko wrote:

Hello I am making a program that does a really hard calculation and  
it seems to crash after 60 Minutes. I don't really know why it  
does, I am guessing it is because I am using a for loop that takes  
awhile to run (an estaminet of 120 MInutes every time it loops). so  
I was hoping someone will be able to help me fix it.

Here is the error I am getting.
cal(18129,0xa00c9074) malloc: *** mmap(size=16777216) failed (error  
code=12)

*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Trace/BPT trap

Note I have tried doing it on other machines and it still crashes.

Thanks for help and tips,
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/sundown%40mac.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: App names

2008-08-31 Thread Marcus


31 aug 2008 kl. 22.14 skrev John Joyce:


When dealing with applications (application bundles) by name or path,
in Cocoa, when does it make a difference whether you use
App Name.app
example:
Front Row.app
or:
/Applications/Front Row.app

versus
App Name
example:
Front Row
or:
/Applications/Front Row


This seems to be pretty important, and I'm curious when and to what  
degree I should be cautious about the naming used in code.
At this time I am mainly concerned about Apple apps themselves that  
should normally be in the system.


Subsequently, is there any difference concerning 10.3 / 10.4 / 10.5 ?


The difference is that App Name.app can be any App Name.app, whether  
or not it  lies inside your bundle, the same directory as you bundle,  
or in a directory that is searched for bundles. /Applications/Front  
Row.app is /Applications/Front Row.app, and no other Front Row.app,  
even if there's a Front Row.app lying somewhere else where your  
application may look for them.


From what I know, there's no difference in the way the above works  
between different versions of Mac OS X.


Marcus




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: accessing netinfo db from cocoa?

2008-08-31 Thread Kieren Eaton


If you want to do it fast, without shell output parsing, and in a way
that will work on 10.4 *and* 10.5, use the Directory Services C API.
The downside is that it's more complex than many of the Cocoa APIs
you're likely used to.

Docs:



Re: (Newb) Populate NSMutableDictioanry with NSArray

2008-08-31 Thread Michael Ash
On Sun, Aug 31, 2008 at 4:34 AM, Jon Davis <[EMAIL PROTECTED]> wrote:
> I came across tutorial code that looked sort of like this:
>
> NSMutableDictionary * myCollection;
> myCollection = [[NSArray alloc] initWithObjects:@"a", @"b", @"c", nil];
>
> The types are not the same. So my first question is, is this a bug? And if
> so, why didn't the compiler catch it? I come from C# so unless
> NSMutableDictionary inherits NSArray this logic would not compile.
>
> If it is not a bug, can someone confirm that NSDictionary is not just used
> for key/value pairs but as simple list types, too? Otherwise, why would
> myCollection above be declared as an NSMutableDictionary?

The important thing to understand about this case is that Objective-C
does not have constructors as are found in certain popular object
oriented languages. The "alloc" and "initWithObjects:" methods you're
calling are just regular old methods. Although they create a new
object for you, there's nothing special about them, or different from
other methods.

With that in mind, let's look at the declaration of the
"initWithObjects:" method:

- (id)initWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION;

And right there is your answer as to why you didn't get an error. It's
typed to return "id", which of course is Objective-C speak for "any
object". It's never an error, or a warning, to assign a value of type
id to a more specific type. So your assignment of a value of type id
to a variable of type NSMutableDictionary is perfectly valid.

This just raises a new question, though: why does this method return
"id" instead of NSArray *? The answer to this is subclasses, of which
there is a great example in the form of NSMutableArray. Imagine if the
method was typed to return NSArray *. Then you wrote code like this:

NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"a",
@"b", nil];

This is perfectly legal code. But the compiler will whine at you.
You're taking a value of type NSArray *, and assigning it to
NSMutableArray *. Since NSMutableArray is a more specific type than
NSArray, this assignment is considered unsafe, and you get a warning.
But the code is perfectly fine. To avoid this problem, and to allow
initializers to work with subclasses, they generally return "id"
rather than a specific class type.

Objective-C is pretty different from C#. In particular, its type
system is a lot more dynamic and runtime oriented. The compiler will
only catch superficial errors for you at compile time, as compared to
environments like C# where compile time type checking is much more
rigorous. Opinions vary as to which is better. Personally speaking,
I've never had a type-based bug in Objective-C code that a stricter
language would have caught but which took me a long time to find in
Objective-C. These things tend to show up almost immediately in
testing. And while they can be confusing if you're just starting out,
with a little experience they tend to be easy to track down.

Mike
___

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

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

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

This email sent to [EMAIL PROTECTED]