Re: If the NIB instantiates everything how does the controller get a reference to the View and the Model?

2008-10-27 Thread Michael A. Crawford

I was missing the IBOutlet keyword in the class declaration.  Thanks.

-Michael

On Oct 27, 2008, at 4:06 PM, Ken Thomases wrote:


On Oct 27, 2008, at 8:48 PM, Michael A. Crawford wrote:

If the NIB instantiates everything how does the controller get a  
reference to the View and the Model?


There are a couple of possibilities:

* The controller is in the nib.  This is often the case with an  
application controller in MainMenu.nib, for example.  In that case,  
you just connect the controller's outlets to the view(s).  The  
application controller often creates the model in code and so has a  
reference to it that way.  It's possible, although I don't  
particularly recommend it, to instantiate your model object in the  
nib, too.


* The controller serves as File's Owner for the nib.  Again, you  
connect outlets to views, but from File's Owner which at design time  
is a stand-in for the object that will own the nib at run time.  You  
have to tell Interface Builder what the class of File's Owner will  
be so it knows about your outlets.  In this case, the controller may  
have created the model or it might have been passed a reference to  
the model when it was created (by another, superior controller).


Cheers,
Ken





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: How to check the number of pending events in the application event queue?

2008-10-27 Thread Peter Sagerson
Since you can postpone the task midstride, then you might just want to  
think of this in terms of breaking the task up into small pieces to be  
interspersed with event handling.


- (void)doSomeMoreWork
{
[self doTheNextStep];

if([self isMoreWorkToDo])
[self performSelector:@selector(doSomeMoreWork)  
withObject:nil afterDelay:0.0];

}

If your work units are small enough, you shouldn't really have to  
worry about idleness.



On Oct 27, 2008, at 6:19 AM, Oleg Krupnov wrote:


Yes, I'd really like to avoid multi-threading. There would be an
intense data exchange between the threads and the effort for
synchronization would be simply not justified for such a tiny feature.
Actually I did try multi-threading before I arrived to this solution,
and I have spent very long and painful day debugging some weird
rare-happening synchronization bug. Besides, real multi-threaded task
works slightly different than simply postponed-to-idleness task. The
two threads may be running simultaneously even if the main thread has
a higher priority, whereas I'd prefer strict suspension of the
secondary task when the main thread wakes up.


On Mon, Oct 27, 2008 at 3:05 PM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:


Le 27 oct. 08 à 13:54, Oleg Krupnov a écrit :


In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle  
for

a certain time.



Have you a good reason to avoid multi-threading ?



___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/psagers 
%40ignorare.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: Core Data Questions--Relationships, UUIDs, and Dirty States

2008-10-27 Thread chaitanya pandit


On 28-Oct-08, at 2:01 AM, Keary Suska wrote:

1. Confirmation clarification: do I understand correctly,  
considering typical RDBMS data integrity rules, that for most to-one  
relationships, I would set the delete rule to "no action", since  
deletion of the "many" item should not effect the "one" item?


2. How do I best implement custom UUIDs for relationships (as a  
property to an entity)? I thought I saw this come up some time ago  
but I can't seem to find the discussion.



You can generate an UUID by:
+ (NSString *)generateUniqueID
{
CFUUIDRef uuid = CFUUIDCreate(NULL);
NSString *identifier = (NSString *)CFUUIDCreateString(NULL, uuid);
CFRelease(uuid);
return identifier;
}
I guess what you wanna do is store this string as a property to an  
entity.


3. How can I, in a bindings-compliant manner, report the "dirty"  
state of an NSManagedObjectContext? I know I can be notified when  
the context has changed, and when the context has saved, but what  
about when the context has been rolled back or changes undo-ed?


4. Does anyone have recommendations on how I can maintain the  
"dirty" state of a single NSManagedObject? I don't figure there is  
anything built into CD for this.


TIA,

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/chaitanya%40expersis.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: Finding out that a volume is going away before it does

2008-10-27 Thread Chris Suter
On Tue, Oct 28, 2008 at 1:50 AM, Francis Devereux <[EMAIL PROTECTED]> wrote:

> My code works on 10.4 8A428 PPC (after I changed mainRunLoop to
> currentRunLoop), but this probably isn't much help to you because
> DiskArbitration.framework is private on 10.3.

You can use it fine on 10.3. As far as I know, there was no change to
the interface between 10.3 and 10.4 (or none that will bother you).
You just need to make sure you link to the framework in
/System/Library/PrivateFrameworks rather than
/System/Library/Frameworks.

NSWorkspace will ultimately be using DiskArbitration; there's no other
way for it to work.

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


NSPredicateEditor error

2008-10-27 Thread Chris Idou

I'm getting the following error:

In , different number of items (3) than predicate 
template views (4) for template 

>From experimenting, the only difference between the 
>NSPredicateEditorRowTemplate that is failing and my other ones that work fine, 
>is that this one has a NSButton in its list of views.

Has anyone else seen this before, and have any insight?




  
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread john fogg
Hi Graham!

On 10/28/08, Graham Cox <[EMAIL PROTECTED]> wrote:

> FWIW, I tried to do some coding in Actionscript a few years ago after
> being immersed in C++ for many years and then Objective-C/Cocoa for a
> few years. To say that it was an exercise in utter frustration is an
> understatement. [...]

I think I know how you feel. :-) And I share your opinion about
Actionscript and (for me) Flash in general. I feel kinda spoiled by
Actionscript but I'm unlearning now. :-))
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread Graham Cox


On 28 Oct 2008, at 2:30 pm, john fogg wrote:


I come from coding in Actionscript (Flash) and there things are
apparently quite different.



FWIW, I tried to do some coding in Actionscript a few years ago after  
being immersed in C++ for many years and then Objective-C/Cocoa for a  
few years. To say that it was an exercise in utter frustration is an  
understatement. As a programmer in these "real" languages I found AS  
to be really mickey-mouse.


Others' opinions will no doubt vary but I suspect that if you know AS  
well, moving to what I call a real language is going to mean  
unlearning a huge heap of rubbish. Sorry, just my opinion.


--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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread john fogg
Hi Ken!

Thank you for your long answer! It cleared up a lot of things for me.
I come from coding in Actionscript (Flash) and there things are
apparently quite different.

Is it true that all instances I create live in memory on the same
level? That they are all somehow equal? And that all relationships
between them are only by pointers?
Because in Actionscript you can have instances inside other object's
instances and once you dealloc the containing instance all the other
object's instances it contained die with it. Think Matryoshka puppets
or something like that.

On 10/28/08, Ken Thomases <[EMAIL PROTECTED]> wrote:

> Part of the problem is that object's don't have names, they have addresses.

I see. So I can only access an instance from within some other
instance if I always remember to pass along a pointer to it?

> But the pointer isn't the object and the object isn't the pointer.

This is what I got wrong I guess.

> So, when you say "I create a subobject called 'mySubObject' inside my
> main object 'myMainObject'" I translate that to mean, that you have a
> pointer named myMainObject to an instance of some custom class.  In
> the implementation of that class, there's a method, and in that method
> you create another object of some other(?) class and store its address
> into a pointer named mySubObject.  mySubObject might be a local
> variable, an instance variable, or whatever.
>
> Now, what does "within 'mySubObject'" mean?  I assume you mean within
> an instance method of the class of which mySubObject is an instance.

Thank you. You translated correctly and explained it to me at the same time! :-)

Your following explanation did the trick for me. Thank you again!

Cheers, John.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread john fogg
Ken Thomases wrote me off-list. I don't know if this was deliberate (I
guess not) but I'd rather not quote his mail here without his consent.

Anyways the problem is fixed and I understand it all a whole lot
better now. Big thanks to everybody and esp. Ken. You all are very
nice people!!
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 9:35 PM, john fogg wrote:


Here is the deal: I create a subobject called "mySubObject" inside my
main object "myMainObject". Now I want to access "myMainObject" from
within "mySubObject".


Your terminology is a bit hard to follow.  Part of the problem is that  
object's don't have names, they have addresses.  Object pointer  
variables have names and can contain the addresses of objects.  But  
the pointer isn't the object and the object isn't the pointer.   
Understanding this is important, since you seem to be foggy on how the  
two concepts interact.  A pointer can change which object it's  
pointing to over time.  An object may be pointed to by many different  
pointers, which will have different names.


And you don't write code or define properties inside objects.  You  
define them in (or for) classes.


So, when you say "I create a subobject called 'mySubObject' inside my  
main object 'myMainObject'" I translate that to mean, that you have a  
pointer named myMainObject to an instance of some custom class.  In  
the implementation of that class, there's a method, and in that method  
you create another object of some other(?) class and store its address  
into a pointer named mySubObject.  mySubObject might be a local  
variable, an instance variable, or whatever.


Now, what does "within 'mySubObject'" mean?  I assume you mean within  
an instance method of the class of which mySubObject is an instance.


OK.

In the method of the first class -- the class of myMainObject; where  
you created mySubObject -- you can pass 'self' to mySubObject as a  
message parameter.  It might be a parameter of the init message (- 
initWithOwner:, for example), or you might use a setter (e.g. - 
setOwner:).  The second class -- the class of mySubObject -- would  
keep track of the owner in one of its instance variables, possibly  
called "owner".  Then, when it wanted to message its owner, it could  
do [owner someMethod] or owner.someProperty, etc.




I'm still not sure what the ideal way to do this would be but I have
gotten it to work somehow. Inside "myMainObject" I create a property
and point it to "self" so it stores a reference to "myMainObject".


Is that a typo?  You have created a property on an object which refers  
to itself?  That doesn't make sense to me.


(Again, the property isn't inside myMainObject.  It's inside the class  
from which myMainObject was instantiated.)




Inside "mySubObject" I cannot access this by writing

   [pointerToMainObject doMethod];

but it works when I write

   [self.pointerToMainObject doMethod];

Why? What difference does "self" make here?


That doesn't seem sensible to me.  However, without seeing the code in  
question, it's very hard to tell what might be happening.  Seeing the  
code would also probably clarify what you're trying to say.


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]


Tiger limits the number of concurrent downloads in WebKit?

2008-10-27 Thread Greg Harris
I'm using WebKit to download files from a web page. On Leopard (tested
10.5.5) everything works as expected, you can download as many files as you
want concurrently. However, with the same app on Tiger (tested 10.4.10 and
10.4.11), if you have started 3 downloads, clicking on additional downloads
will timeout. It's almost like there's a hard limit to the number of
concurrent downloads you can have.

I'm detecting whether the file should be downloaded based on the MIME type
in the decidePolicyForMIMEType... method of the WebPolicyDelegate. If the
file should be downloaded, I'm creating a WebDownload object for that URL.
On attempting to download a fourth file while three are still downloading,
that fourth WebDownload object never calls download:didReceiveResponse, it
just eventually calls download:didFailWithError and times out. If you cancel
or finish one of the previous 3 downloads before the 4th one times out, the
4th one will begin downloading. If it matters, all of the WebView delegates
and download delegate are the same object.

Has anyone else run into this problem? Any ideas?

Thanks!

Greg Harris
___

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

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


Bindings and hierarchical menus

2008-10-27 Thread Jay Martin
I've been searching all over to see if this is possible and have yet  
to find an answer. There was a similar email years ago with no  
response, and I haven't found the right magic keyword combination to  
find the answer on cocoadev. So, please, is it possible to do  
hierarchical menus via bindings? I have a popup button that I'd like  
to populate with a menu hierarchy but for the life of me I can't see  
how you could do it.


Thanks,
jay
___

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

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


Documentation of NSArchiver streamtyped format

2008-10-27 Thread Gregor Jasny

Hi,

I'm looking for documentation of the binary format that is written by
NSArchiver. The file utility tells me that it's called
"NeXT/Apple typedstream data, little endian, version 4, system 1000".

Thanks,
Gregor

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Finding out that a volume is going away before it does

2008-10-27 Thread Francis Devereux

On 27 Oct 2008, at 13:42, Gregory Weston wrote:


On Oct 27, 2008, at 9:31 AM, Francis Devereux wrote:


On 26 Oct 2008, at 16:37, Gregory Weston wrote:

Amusingly, when you register an unmount or eject approval function  
with DiskArbitration, that function gets invoked *after*  
NSWorkspace sends its didUnmount notification. How's that for a  
lead-in anecdote?


So anyway, I'm looking to react to the imminent or even potential  
departure of a volume. Some way I can know that a volume will (or  
probably will) be taken away from me in the near future but with  
enough lead time that I can reliably make one or two quick  
function calls against it. Any thoughts? I'm not worried about  
abrupt disconnects like the user yanking the cable on an external  
drive. Just looking for the tiniest smidgen of warning for orderly  
unmounts.


Specifically, I'm looking for the opportunity to call  
FSGetCatalogInfo on the mount point and then FSGetVolumeInfo on  
the volume reference number I got back from the first call.


Have you actually tried using DiskArbitration unmount approval  
callbacks?  I decided to give it a go and was able to successfully  
call FSGetVolumeInfo in the callback.  Tested with OS X 10.5.5 and  
Xcode 3.1.1.


I did; that's how I noticed that the approval callback happened  
after the unmount notification. My test case was on a 10.4 machine  
and I actually need to support 10.3+. If it's something they've only  
fixed some time in the last year it's not especially helpful to me  
today. But I appreciate the data point.


My code works on 10.4 8A428 PPC (after I changed mainRunLoop to  
currentRunLoop), but this probably isn't much help to you because  
DiskArbitration.framework is private on 10.3.  Probably best to follow  
Matt Gough's suggestion of caching the info from FSGetVolumeInfo  
before you get the kEventVolumeUnmounted carbon event.


Francis.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Finding out that a volume is going away before it does

2008-10-27 Thread Francis Devereux

On 26 Oct 2008, at 16:37, Gregory Weston wrote:

Amusingly, when you register an unmount or eject approval function  
with DiskArbitration, that function gets invoked *after* NSWorkspace  
sends its didUnmount notification. How's that for a lead-in anecdote?


So anyway, I'm looking to react to the imminent or even potential  
departure of a volume. Some way I can know that a volume will (or  
probably will) be taken away from me in the near future but with  
enough lead time that I can reliably make one or two quick function  
calls against it. Any thoughts? I'm not worried about abrupt  
disconnects like the user yanking the cable on an external drive.  
Just looking for the tiniest smidgen of warning for orderly unmounts.


Specifically, I'm looking for the opportunity to call  
FSGetCatalogInfo on the mount point and then FSGetVolumeInfo on the  
volume reference number I got back from the first call.


Have you actually tried using DiskArbitration unmount approval  
callbacks?  I decided to give it a go and was able to successfully  
call FSGetVolumeInfo in the callback.  Tested with OS X 10.5.5 and  
Xcode 3.1.1.  The full project is at http://www.devrx.org/software/osx/DiskArbitrationTest.zip 
, here's the important bits:


@implementation FDDAController

static DADissenterRef DiskUnmountApprovalCallback(DADiskRef disk, void  
*context)

{
//FDDAController *self = (FDDAController *)context;

OSStatus status;
OSErr err;

CFDictionaryRef diskDescription = DADiskCopyDescription(disk);
NSLog(@"DiskUnmountApprovalCallback diskDescription = %@",  
diskDescription);


NSDictionary *nsDiskDescription = (NSDictionary *)diskDescription;
NSURL *volumeURL = [nsDiskDescription valueForKey:@"DAVolumePath"];
if (![volumeURL isFileURL])
{
NSLog(@"Error: volume URL %@ is not a file URL!", volumeURL);
goto EXIT1;
}

NSString *volumePath = [volumeURL path];
const char *utf8VolumePath = [volumePath UTF8String];
FSRef volumeFSRef;
if ((status = FSPathMakeRef((UInt8 *)utf8VolumePath,  
&volumeFSRef, (Boolean *)NULL)) != noErr)

{
NSLog(@"FDPathMakeRef error: %d", status);
goto EXIT1;
}

FSCatalogInfo catalogInfo;
if ((err = FSGetCatalogInfo(&volumeFSRef, kFSCatInfoVolume,  
&catalogInfo, NULL, NULL, NULL)) != noErr)

{
NSLog(@"FSGetCatalogInfo error: %d", err);
goto EXIT1;
}

FSVolumeInfo volumeInfo;
if ((err = FSGetVolumeInfo(catalogInfo.volume,
   0, NULL,
   kFSVolInfoGettableInfo, &volumeInfo,
   NULL,
   NULL)) != noErr)
{
NSLog(@"FSGetVolumeInfo error: %d", err);
goto EXIT1;
}

NSLog(@"totalBytes = %llu, freeBytes = %llu, blockSize = %u",  
volumeInfo.totalBytes, volumeInfo.freeBytes, volumeInfo.blockSize);


EXIT1:
CFRelease(diskDescription);

return NULL;
}

- (void)awakeFromNib
{
NSLog(@"FDDAController awakeFromNib");

daApprovalSession = DAApprovalSessionCreate(kCFAllocatorDefault);
DAApprovalSessionScheduleWithRunLoop(daApprovalSession,
 [[NSRunLoop mainRunLoop]  
getCFRunLoop],

 kCFRunLoopCommonModes);
DARegisterDiskUnmountApprovalCallback(daApprovalSession,
  NULL,
  &DiskUnmountApprovalCallback,
  (void *)self);
NSLog(@"finished registering callbacks");
}

- (void)dealloc
{
DAUnregisterApprovalCallback(daApprovalSession,  
DiskUnmountApprovalCallback, self);


DAApprovalSessionUnscheduleFromRunLoop(daApprovalSession,
   [[NSRunLoop mainRunLoop]  
getCFRunLoop],

   kCFRunLoopCommonModes);

CFRelease(daApprovalSession);
[super dealloc];
}

Francis

___

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

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

2008-10-27 Thread Nonnus™

hello

i am having a hard time catching a bug in a small NSNetService based  
app i developed


all works as expected except that it crashes if i try to accees the  
menu after a connection is made
i though i had tracked the issue being related to retain / release  
issues
more specifically to typical bonjour [_server release]; when a  
connection is made
by removing those the crash goes away but it also seems to disrupt  
bonjour network as it starts leaving server instances being advertised  
and just creates new ones



i have prepared a small sample app so anyone interested can check it  
out:  http://www.silicon-studios.com/sample.zip


to test the issue, build the app

notice you can access the menu as usual

from the terminal type
dns-sd -B _testing._tcp local

and it will probably your own machine meaning the app is advertising  
its service


now type: telnet localhost:6

it will say u are connected

if u check xcode console the app will say it is connected

if you now try to access the menu the app will now crash and no info  
about the cause on console


thank your for your attention


abraços

nonnus


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread John Velman
I'm new to objective-C and cocoa also, I I don't know the answer to your
specific question about "self".  However, seems that one way to do it would
be to have the init of mySubObject have an initializer with argument, and
you would then create it something like this:

SubObject * mySubObject = [[SubObject alloc] initWithParent:self]

This save puting a variable set to 'self' inside MainObject.

Best,

John V.

On Tue, Oct 28, 2008 at 03:35:55AM +0100, john fogg wrote:
> Hi again!
> 
> I'm still plucking along and any help is still greatly appreciated!
> 
> Here is the deal: I create a subobject called "mySubObject" inside my
> main object "myMainObject". Now I want to access "myMainObject" from
> within "mySubObject".
> 
> I'm still not sure what the ideal way to do this would be but I have
> gotten it to work somehow. Inside "myMainObject" I create a property
> and point it to "self" so it stores a reference to "myMainObject".
> Inside "mySubObject" I cannot access this by writing
> 
> [pointerToMainObject doMethod];
> 
> but it works when I write
> 
> [self.pointerToMainObject doMethod];
> 
> Why? What difference does "self" make here?
> 
> I'm still trying to wrap my head around all this stuff so please bear
> with me here. :-)
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/velman%40cox.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: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread Nick Zitzmann


On Oct 27, 2008, at 8:35 PM, john fogg wrote:


Inside "mySubObject" I cannot access this by writing

   [pointerToMainObject doMethod];

but it works when I write

   [self.pointerToMainObject doMethod];

Why? What difference does "self" make here?



Because the latter accesses the property of self, and the former  
doesn't. Assuming you're not developing exclusively for 64-bit (the 64- 
bit runtime supports properties without synthesis or implementations,  
IIRC), then using the original pointer variable in place of the former  
ought to work.


Nick Zitzmann




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Why "self"? (Was: Newbie: Referencing Objects)

2008-10-27 Thread john fogg
Hi again!

I'm still plucking along and any help is still greatly appreciated!

Here is the deal: I create a subobject called "mySubObject" inside my
main object "myMainObject". Now I want to access "myMainObject" from
within "mySubObject".

I'm still not sure what the ideal way to do this would be but I have
gotten it to work somehow. Inside "myMainObject" I create a property
and point it to "self" so it stores a reference to "myMainObject".
Inside "mySubObject" I cannot access this by writing

[pointerToMainObject doMethod];

but it works when I write

[self.pointerToMainObject doMethod];

Why? What difference does "self" make here?

I'm still trying to wrap my head around all this stuff so please bear
with me here. :-)
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Can we ask iPhone questions yet?

2008-10-27 Thread Brian Stern


Apple has made an iPhone forum for iPhone developers available here




On Oct 27, 2008, at 6:19 PM, Karan, Cem (Civ, ARL/CISD) wrote:

Like the subject says, can we ask iPhone questions yet?  I'm stumped  
and I need help.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: If the NIB instantiates everything how does the controller get a reference to the View and the Model?

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 8:48 PM, Michael A. Crawford wrote:

If the NIB instantiates everything how does the controller get a  
reference to the View and the Model?


There are a couple of possibilities:

* The controller is in the nib.  This is often the case with an  
application controller in MainMenu.nib, for example.  In that case,  
you just connect the controller's outlets to the view(s).  The  
application controller often creates the model in code and so has a  
reference to it that way.  It's possible, although I don't  
particularly recommend it, to instantiate your model object in the  
nib, too.


* The controller serves as File's Owner for the nib.  Again, you  
connect outlets to views, but from File's Owner which at design time  
is a stand-in for the object that will own the nib at run time.  You  
have to tell Interface Builder what the class of File's Owner will be  
so it knows about your outlets.  In this case, the controller may have  
created the model or it might have been passed a reference to the  
model when it was created (by another, superior controller).


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: CFPreferences and init: a possible reason?

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 8:08 PM, Adam Penny wrote:

I am able to write The contents of my one NSTextField to the plist  
with CFPreferencesSetAppValue, it's writing the two arrays that is  
the sticking point. When I try to do CFPreferencesSetAppValue for  
the array(s) I get an EXC_BAD_ACCESS raised by the debugger.


You're trying to store an array of objects of a custom class (Server)  
to CFPreferences?  That won't work.


CFPreferences can only store objects of the Core Foundation property  
list types.  That can include CFArray and CFDictionary, but only if  
those contain property list typed objects.


If you want to store other types of objects, you have to archive them  
to/from an NSData/CFData.  There's an example here: http://developer.apple.com/documentation/Cocoa/Conceptual/UserDefaults/StoringNSColorInDefaults.html


To use that technique, you'll have to make your Server class conform  
to NSCoding.



By the way, your Server class -dealloc releases the "name" and "mac"  
instance variables, but your -init does not retain the initial strings  
it assigns to them.  That's an imbalance.  Now, it's not likely that  
this imbalance will bite you with string literals, but it's still  
incorrect.


Also, your -toPlist: method makes a copy of the servers array, but it  
doesn't have to.  And your -initWithBundle: will leak the objects  
obtained from CFPreferences if they aren't of the expected type.


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]


If the NIB instantiates everything how does the controller get a reference to the View and the Model?

2008-10-27 Thread Michael A. Crawford

-Michael

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]

CFPreferences and init: a possible reason?

2008-10-27 Thread Adam Penny
Forgive me if I'm sounding like a broken record, but after a day  
experimenting with different approaches based on ideas that came up  
yesterday, I'm pretty confident that everything is sound as far as my  
controller class is concerned. I've been mulling this problem over and  
wanted to put my hypothesis forward for consideration by anyone with  
more experience, which is probably everyone else on this list.


I am able to write The contents of my one NSTextField to the plist  
with CFPreferencesSetAppValue, it's writing the two arrays that is the  
sticking point. When I try to do CFPreferencesSetAppValue for the  
array(s) I get an EXC_BAD_ACCESS raised by the debugger.


I got to wondering whether my problem might have something to do with  
the content of the array rather than the array itself. My  
NSArrayController is bound to a class Servers that initialises two  
NSStrings: name and mac which are inserted into the new index in the  
NSMutableArray and these are bound to the two columns of my NSTableView.


I was just wondering whether my controller class necessarily knows  
anything about the two NSStrings in each row of the array, since it's  
the array controller that deals with formatting the rows for display  
in the NSTableView? Could not having the contents of the array  
declared in the preference controller itself be what's upsetting  
CFPreferences when I try to write the array?


Just as a reminder here's my WopolPrefs.m as it stands now along with  
the server class. I'm not bothering to put the printers class as it's  
much the same principle as the server class anyway.
I've put them at  the end of the email as you've probably seen  
variations on it far too many times by now. The code isn't very tidy  
at the moment as I've been experimenting a lot, but it all works save  
the aforementioned issues.


Thanks again,

Adam


***Beginning of code**
#import "WopolPref.h"


@implementation WopolPref

- (id)initWithBundle:(NSBundle *)bundle
{
if (![super initWithBundle:bundle]) return nil;
appID = CFSTR("uk.co.pennynet.Wopol");
	CFPropertyListRef  
serversFromPlist=CFPreferencesCopyAppValue( CFSTR("servers"), appID);
	if (serversFromPlist &&  
CFGetTypeID(serversFromPlist)==CFArrayGetTypeID())

{
		servers=[[NSMutableArray alloc]initWithArray: (NSArray  
*)serversFromPlist];

CFRelease(serversFromPlist);
}
else servers= [[NSMutableArray alloc] init];
	CFPropertyListRef printersFromPlist=  
CFPreferencesCopyAppValue( CFSTR("printers"), appID);
	if (printersFromPlist &&  
CFGetTypeID(printersFromPlist)==CFArrayGetTypeID())

{
		printers=[[NSMutableArray alloc]initWithArray: (NSArray  
*)printersFromPlist];

CFRelease(printersFromPlist);
}
else printers= [[NSMutableArray alloc] init];
broadcastIP= @"255.255.255.255";
return self;
}

- (void) mainViewDidLoad
{
CFPropertyListRef value;
/*Get value for the broadcastIP textfield*/
value=CFPreferencesCopyAppValue( CFSTR("broadcastIP"), appID);
	if (value && CFGetTypeID(value) == CFStringGetTypeID()) [broadcastIP  
setStringValue:(NSString *)value];

else [broadcastIP setStringValue:(NSString *)@"255.255.255.255"];
/*release the value*/
if (value) CFRelease(value);
}

- (void) setPrinters:(NSMutableArray *)newPrinters
{
//Not relevant
}

- (void) setServers:(NSMutableArray *)newServers;
{
//Method for adding a new server, with mac address to the servers dict
if (newServers==servers) return;
[newServers retain];
[servers release];
servers=newServers;
	/*if([servers count]!=0) CFPreferencesSetAppValue(CFSTR("servers"),  
(NSArray *)servers, appID);

else CFPreferencesSetAppValue(CFSTR("servers"), NULL, appID);
[self updatePrefs];*/

}

- (void) updatePrefs;
{

CFPreferencesAppSynchronize(appID);
}

- (void)controlTextDidEndEditing: (NSNotification *)aNotification;
{
NSLog(@"TextField changed");
/*	CFPreferencesSetAppValue(CFSTR("broadcastIP"), (NSString *) 
[broadcastIP stringValue], appID);

[self updatePrefs];*/   }

- (void)dealloc
{
[printers release];
[servers release];
[super dealloc];
}

- (IBAction) toPlist:(id)sender
{
NSLog(@"Trying to write to Plist");
NSArray *serversToWrite=[[NSArray alloc]initWithArray:servers];
	if([serversToWrite count]!=0)  
CFPreferencesSetAppValue(CFSTR("servers"), (NSArray *)serversToWrite,  
appID);

else CFPreferencesSetAppValue(CFSTR("servers"), NULL, appID);
[self updatePrefs];
[serversToWrite release];
NSLog(@"PList saved");
}
@end
end of code *
The class that I mentioned that is bound to the servers array  
controller is:

***beginning of code
//The .h:
#import 


@interface Server : NSObject {
NSString *n

Re: Not so long filenames

2008-10-27 Thread Jeremy Pereira


On 26 Oct 2008, at 09:55, Gerriet M. Denkmann wrote:



On 26 Oct 2008, at 00:30, Postmaster wrote:



On 14 Oct 2008, at 21:00, Gerriet M. Denkmann wrote:



On 14 Oct 2008, at 18:07, Jason Coco wrote:



On Oct 14, 2008, at 11:28 , Gerriet M. Denkmann wrote:




HFS+ stores files in decomposed UTF-8.  Checking the system headers,
"system headers" is kind of vague: which file exactly do you have in  
mind?


it can store files with a maximum file name length of 255 bytes.   
How do you get 256 bytes of UTF-8 into 255 bytes?


Checking the system header hfs_format.h for HFSUniStr255 one sees  
that it can store file names with a maximum length of 255 u_int16_t.
And there is no real problem of putting the 128 shorts of Utf-16  
into 255 u_int16_t.


It's actually the VFS layer I was thinking of.  The OS X VFS uses  
UTF-8 (otherwise there would be no backward compatibility for calls  
like open(2) etc).  I got the 255 byte limit by looking at struct  
dirent defined in /usr/include/sys/dirent.h which is the structure  
used in the readdir syscall.


___

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

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

2008-10-27 Thread [EMAIL PROTECTED]

At 6:51 PM -0500 10/27/08, Ken Thomases wrote:

On Oct 27, 2008, at 4:05 PM, [EMAIL PROTECTED] wrote:

if i call -[anObject performSelectorOnMainThread:aSelector 
withObject:nil waitUntilDone:NO] and then later throw an exception 
(of my own), which i catch, the deferred execution of aSelector 
never happens. note that the performSelectonOnMainThread, and the 
throw and catch are all in the same run of the run loop and are all 
in the main thread.


is this a bug (seems like it to me) or proper/expected behavior. if 
i didn't catch the exception, i could understand this, but as i 
said, i am catching it. if this is proper behavior, can anyone 
offer me an explanation as to why?


Sounds like a bug to me.  File it with Apple .


will do/



Out of curiosity, since you're only trying to defer a message and 
everything's on the main thread, does it still happen with [anObject 
performSelector:aSelector withObject:nil afterDelay:0]?


i didn't try that. however, i've since re-architected somewhat and 
can't easily test in my app. i may try that before filing a bug 
report.


ken




Regards,
Ken


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: performSelectorOnMainThread and exceptions

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 4:05 PM, [EMAIL PROTECTED] wrote:

if i call -[anObject performSelectorOnMainThread:aSelector  
withObject:nil waitUntilDone:NO] and then later throw an exception  
(of my own), which i catch, the deferred execution of aSelector  
never happens. note that the performSelectonOnMainThread, and the  
throw and catch are all in the same run of the run loop and are all  
in the main thread.


is this a bug (seems like it to me) or proper/expected behavior. if  
i didn't catch the exception, i could understand this, but as i  
said, i am catching it. if this is proper behavior, can anyone offer  
me an explanation as to why?


Sounds like a bug to me.  File it with Apple bugreport.apple.com>.


Out of curiosity, since you're only trying to defer a message and  
everything's on the main thread, does it still happen with [anObject  
performSelector:aSelector withObject:nil afterDelay:0]?


Regards,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Looking for the big hammer

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 4:00 PM, Chilton Webb wrote:

I have a particular problem that is buried deep in layers of logic.  
Worse, it only happens on some systems, and only after they've been  
running for a long time. I know it's extremely heavy handed, but I  
want to know every single function call in my app that happens from  
one point to another, even if it takes an hour to generate, and is  
hundreds of megabytes in size.


It looks like dtrace might do it. Does anyone have a dtrace script  
that returns a mountain of data like this?


When you say "every single function call in my app", do you mean the  
functions that are defined in your app that are called, or all  
functions anywhere that are called by your app?


If you try to instrument every single function entry and return for  
your app and every framework and library to which it links, I think  
that'll overwhelm DTrace.  Also, although you think you want all that  
info, I suspect it will overwhelm your ability to analyze it.


In theory, you would use something like this:

sudo dtrace -F -n 'pid$target:::entry, pid$target:::return {}' -c / 
path/to/YourApp.app/Contents/MacOS/YourApp



If you want to limit it to just the functions in your app, you'd  
specify your app as the module in the probe specifiers:


sudo dtrace -F -n 'pid$target:YourApp::entry, pid 
$target:YourApp::return {}' -c /path/to/YourApp.app/Contents/MacOS/ 
YourApp


(You can use -p  rather than -c  to trace an already  
running process.)



The above commands use the -F switch and probes on function entry and  
return to get a formatted call tree.  That's nice for simple cases,  
but tends to fall down in real-world tracing.  The problem is that  
DTrace gets data from the kernel asynchronously and, if a process or  
thread migrates from one CPU core to another, it may be out of order.   
That messes up the call tree.


To address that, I've sometimes used a technique where I manually  
trace a bunch of explicit data about function entry and return,  
including which thread it's on, call depth, a per-thread sequence  
number, etc.  I then have DTrace write this to a tab-delimited file,  
without attempting to format it with -F.  Post-processing of the  
output file allows one to recreate the call tree for each thread.   
Here's a sample DTrace script that illustrates the technique:


== begin script ==
#pragma D option quiet

self int order, level;

pid$target:YourApp::entry,
pid$target:YourApp::return
{
printf("%s\t%s\t%s\t%lld\t%d\t", probemod, probefunc, probename,  
(long long)tid, ++self->order);

}

pid$target:YourApp::entry
{
printf("%d\n", self->level++);
}

pid$target:YourApp::return
{
printf("%d\n", --self->level);
}
== end script ==

Good luck,
Ken

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Editing a dictionary using NSTableView

2008-10-27 Thread Graham Cox


On 28 Oct 2008, at 3:27 am, Corbin Dunn wrote:

You probably want to set an appropriate formatter on the cell in - 
willDisplayCell:. This sounds like the best approach to what you are  
wanting. You could always right a custom formatter if you need to.



OK, thanks, I'll look into that approach.

cheers, 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: Core Data Questions--Relationships, UUIDs, and Dirty States

2008-10-27 Thread Keary Suska


On Oct 27, 2008, at 2:55 PM, I. Savant wrote:


1. Confirmation clarification: do I understand correctly, considering
typical RDBMS data integrity rules, that for most to-one  
relationships, I
would set the delete rule to "no action", since deletion of the  
"many" item

should not effect the "one" item?


 Impossible to generalize, but generally - :-) - you'd want "nullify"
and not "no action". This is because you've most likely taken
advantage of the "inverse relationships". This means that (using the
Department / Employee example), when you remove an Employee from the
Department's "employees" set, you also want to tell the employee that
its department is nil.

 Doing nothing in this case will leave your object graph in an
inconsistent state. If you have a good reason for this, knock yourself
out, but if you can't name it, you probably don't have it.


Well, I am looking at just delete cases, but as long as Core Data  
won't nullify the to-many relationship until all the "many" objects  
are deleted, then it seems safe to nullify. I just wasn't sure if that  
was a correct assumption.




2. How do I best implement custom UUIDs for relationships (as a  
property to
an entity)? I thought I saw this come up some time ago but I can't  
seem to

find the discussion.


 I'm not sure I understand your question ... do you want a UUID to be
the name of a relationship or do you just want a property that is a
UUID? What is your goal? Are you looking to solve a cross-store
relationship problem?


My persistent store is not supported, the source RDBMS has legacy  
primary keys that have to be maintained, and I need to know when the  
key changes so I can maintain referential integrity. If I can use my  
own keys for UUIDs, I can let CD take care of that. Otherwise I have  
to do all that myself. Trying to determine which one is easiest and  
least error-prone.


3. How can I, in a bindings-compliant manner, report the "dirty"  
state of an

NSManagedObjectContext? I know I can be notified when the context has
changed, and when the context has saved, but what about when the  
context has

been rolled back or changes undo-ed?


 Isn't an undo just another change? It's setting properties and
relationships back to the way they were, but the key is the word
"setting".


Well, if you undo back to the original state, the MOC reports NO for - 
hasChanges. I basically want the same -documentEdited behavior that  
NSPersistentDocument gives, without using NSPersistentDocument.


4. Does anyone have recommendations on how I can maintain the  
"dirty" state
of a single NSManagedObject? I don't figure there is anything built  
into CD

for this.


 In a document-based or non-document-based application?



Non-doc based. Basically I just want the documentEdited feature I  
describe above. I really just need to know on a per-MO basis, but if  
that is not practical, I can probably work with just knowing the MOC's  
state.


Thanks,

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]


Can we ask iPhone questions yet?

2008-10-27 Thread Karan, Cem (Civ, ARL/CISD)
Like the subject says, can we ask iPhone questions yet?  I'm stumped and I need 
help.

Thanks,
Cem Karan
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: LSSharedFileList API bug(s) -- workaround?

2008-10-27 Thread Steven Degutis
The three applications I've written which use my Cocoa wrapper are normal
applications with the exception that they have LSUIElement set to YES, and
means they live in the menu bar as NSStatusItems, not in the Dock.
Therefore, as far as I understand from reading
http://developer.apple.com/technotes/tn2005/tn2083.html, Login Items is the
appropriate solution here, not a launchd service. Although it is worth
taking into consideration.
On Mon, Oct 27, 2008 at 4:00 PM, Jerry Krinock <[EMAIL PROTECTED]> wrote:

>
> On 2008 Oct, 27, at 13:24, Steven Degutis wrote:
>
>  I've been writing my own wrapper for the LSSharedFileList API to be able
>> to
>> stick it in my Cocoa app. However I've found a few bugs.
>> One isn't that big of a deal, but I've filed a rdar for it anyway, and
>> it's
>> that you can't actually set the Hide property. It just fails in odd ways.
>>
>
> Actually, when I wrote ^my^ wrapper for LSSharedFileList, I found that Hide
> fails consistently.  You might want to reference the bug I filed, 5901742,
> 2008-04-30.  Still open :(
>
>  The other one, however, is pretty major...
>>
>
> Another good reason to not use Login Items.
>
>  If anyone has any ideas for a workaround or solution, please let me know!
>>
>
> Yes.  Instead of using a Login Item, have launchd launch whatever you want
> launched at login, and keep it running.  This way, your user only has one UI
> to deal with adding/removing your login item: Your UI.
>
> I've come to the conclusion that Login Items is for users who have a
> preference to see their Mail.app, iCal, coffee-maker, or whatever launched
> at login.  For an application to place itself or its Helper in Login Items
> is redundant and confusing to the user.  And, of course, redundant and
> confusing concepts lead one to write lots of buggy code.
>
> http://developer.apple.com/macosx/launchd.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/steven.degutis%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
Steven Degutis
___

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

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

2008-10-27 Thread Michael Nickerson


On Oct 27, 2008, at 12:52 AM, Michael Ash wrote:


On Mon, Oct 27, 2008 at 12:07 AM, Michael Nickerson
<[EMAIL PROTECTED]> wrote:


You can always set things up to ignore child processes:
signal( SIGCHLD, SIG_IGN );


It's bad to rely on this sort of global state, though. What if some
other bit of code relies on having a handler for this signal? (Of
course it is relying on this sort of global state too in that case,
but it takes two to screw things up)



Libraries and frameworks shouldn't be setting or relying on signals.   
It is, as you say, a global state.  So really, if you haven't  
specifically set it in your app, you should be fine and if you have  
you should already know about it.


That way, if the children aren't specifically reaped they don't  
stay around
as zombies.  Do note that the wait functions *do* still work if you  
set that
up, so this isn't going to mess anything up elsewhere that is  
reaping a

child.


How does that work, exactly? The whole purpose of the zombie is to
store the end state of the dead process so that wait() can pick it up.
If wait() still works, then what stores that end state if not a zombie
process? More to the point, if wait() still works, that implies that
*something*, *somewhere* is storing that end state. And if you never
call wait() but you continue to create children, that storage will
grow without limit, and this is bad. So it seems to me that either no,
wait() doesn't really work in this scenario, or in fact you still get
zombies or something like them. Am I missing something?



Sorry, my fault for replying late at night.  The wait functions will  
still block for the duration of the child process, but you do lose the  
state information about it.  So if you're relying on state information  
I suppose you would consider that broken, but if all you're using wait  
for is to wait until the child process has terminated, then it still  
works as intended.


--
Darkshadow
(aka Michael Nickerson)
http://www.nightproductions.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: Core Data Questions--Relationships, UUIDs, and Dirty States

2008-10-27 Thread Jim Correia

On Oct 27, 2008, at 4:31 PM, Keary Suska wrote:

1. Confirmation clarification: do I understand correctly,  
considering typical RDBMS data integrity rules, that for most to-one  
relationships, I would set the delete rule to "no action", since  
deletion of the "many" item should not effect the "one"


What the delete action is is going to depend on the needs of your  
"business" logic.


"No action" is an extraordinary choice (because without your  
intervention, you'll end up with dangling inverse relationships.)


If "cascade" is not what you want, "nullify" usually is.

2. How do I best implement custom UUIDs for relationships (as a  
property to an entity)? I thought I saw this come up some time ago  
but I can't seem to find the discussion.


What are you trying to accomplish here? Knowing what you want to do  
will help us better answer the question.


3. How can I, in a bindings-compliant manner, report the "dirty"  
state of an NSManagedObjectContext? I know I can be notified when  
the context has changed, and when the context has saved, but what  
about when the context has been rolled back or changes undo-ed?


-hasChanges will give you the answer you are looking for, but it is  
not documented as being KVO compliant.


4. Does anyone have recommendations on how I can maintain the  
"dirty" state of a single NSManagedObject? I don't figure there is  
anything built into CD for this.


Again, what specifically are you trying to do here?

You can ask an object if it

-isInserted
-isDeleted
-isUpdated

to query those states.

Jim



___

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

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


performSelectorOnMainThread and exceptions

2008-10-27 Thread [EMAIL PROTECTED]
if i call -[anObject performSelectorOnMainThread:aSelector 
withObject:nil waitUntilDone:NO] and then later throw an exception 
(of my own), which i catch, the deferred execution of aSelector never 
happens. note that the performSelectonOnMainThread, and the throw and 
catch are all in the same run of the run loop and are all in the main 
thread.


is this a bug (seems like it to me) or proper/expected behavior. if i 
didn't catch the exception, i could understand this, but as i said, i 
am catching it. if this is proper behavior, can anyone offer me an 
explanation as to why?


thanx,
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: LSSharedFileList API bug(s) -- workaround?

2008-10-27 Thread Jerry Krinock


On 2008 Oct, 27, at 13:24, Steven Degutis wrote:

I've been writing my own wrapper for the LSSharedFileList API to be  
able to

stick it in my Cocoa app. However I've found a few bugs.
One isn't that big of a deal, but I've filed a rdar for it anyway,  
and it's
that you can't actually set the Hide property. It just fails in odd  
ways.


Actually, when I wrote ^my^ wrapper for LSSharedFileList, I found that  
Hide fails consistently.  You might want to reference the bug I filed,  
5901742, 2008-04-30.  Still open :(



The other one, however, is pretty major...


Another good reason to not use Login Items.

If anyone has any ideas for a workaround or solution, please let me  
know!


Yes.  Instead of using a Login Item, have launchd launch whatever you  
want launched at login, and keep it running.  This way, your user only  
has one UI to deal with adding/removing your login item: Your UI.


I've come to the conclusion that Login Items is for users who have a  
preference to see their Mail.app, iCal, coffee-maker, or whatever  
launched at login.  For an application to place itself or its Helper  
in Login Items is redundant and confusing to the user.  And, of  
course, redundant and confusing concepts lead one to write lots of  
buggy code.


http://developer.apple.com/macosx/launchd.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]


Looking for the big hammer

2008-10-27 Thread Chilton Webb

Hi,

I have a particular problem that is buried deep in layers of logic.  
Worse, it only happens on some systems, and only after they've been  
running for a long time. I know it's extremely heavy handed, but I  
want to know every single function call in my app that happens from  
one point to another, even if it takes an hour to generate, and is  
hundreds of megabytes in size.


It looks like dtrace might do it. Does anyone have a dtrace script  
that returns a mountain of data like this?


Thank you,
-Chilton
___

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

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

2008-10-27 Thread Steven Degutis
Han,
You might find it beneficial to check out this website on how to get
answers. It doesn't just apply to cocoa-dev either, it's universally an
overall set of good ideas.

http://www.mikeash.com/getting_answers.html

Steven Degutis
http://www.degutis.org/
http://www.thoughtfultree.com/

On Tue, Oct 28, 2008 at 10:10 AM, han <[EMAIL PROTECTED]> wrote:

> i try to implemnet a self-delete app. first start the app. a copy of the
> app is created in another direction.then,i start the copy of the app.the
> copy run and disppear.
>
> how i make the copy not disppear when start the copy.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
>
> This email sent to [EMAIL PROTECTED]
>



-- 
Steven Degutis
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Questions--Relationships, UUIDs, and Dirty States

2008-10-27 Thread I. Savant
> 1. Confirmation clarification: do I understand correctly, considering
> typical RDBMS data integrity rules, that for most to-one relationships, I
> would set the delete rule to "no action", since deletion of the "many" item
> should not effect the "one" item?

  Impossible to generalize, but generally - :-) - you'd want "nullify"
and not "no action". This is because you've most likely taken
advantage of the "inverse relationships". This means that (using the
Department / Employee example), when you remove an Employee from the
Department's "employees" set, you also want to tell the employee that
its department is nil.

  Doing nothing in this case will leave your object graph in an
inconsistent state. If you have a good reason for this, knock yourself
out, but if you can't name it, you probably don't have it.

> 2. How do I best implement custom UUIDs for relationships (as a property to
> an entity)? I thought I saw this come up some time ago but I can't seem to
> find the discussion.

  I'm not sure I understand your question ... do you want a UUID to be
the name of a relationship or do you just want a property that is a
UUID? What is your goal? Are you looking to solve a cross-store
relationship problem?

> 3. How can I, in a bindings-compliant manner, report the "dirty" state of an
> NSManagedObjectContext? I know I can be notified when the context has
> changed, and when the context has saved, but what about when the context has
> been rolled back or changes undo-ed?

  Isn't an undo just another change? It's setting properties and
relationships back to the way they were, but the key is the word
"setting".

> 4. Does anyone have recommendations on how I can maintain the "dirty" state
> of a single NSManagedObject? I don't figure there is anything built into CD
> for this.

  In a document-based or non-document-based application?

--
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: Sizing strangeness in the land of NSDrawer

2008-10-27 Thread Luke Evans

Hi Steve,

Thanks for the reply.

Ouch, yes, you're right, it works perfectly with GC turned off, and  
misbehaves with "Required" or "Supported".


This will be a major bummer if there's no workaround (I guess it will  
be bye-bye NSDrawer).
So the obvious next question: is there a work around, or was I always  
supposed to be doing something special to make this work at all  
(though that doesn't seem right to me)?


-- Lwe

On 25-Oct-08, at 6:47 PM, Steven Riggs wrote:

Typo,  I meant  turn off garbage collection and see if it starts  
working.


oops
-Steve

On Oct 25, 2008, at 9:06 PM, Luke Evans wrote:


Hello list denizens.

I've just created some UI with an NSDrawer attached to a regular  
window.  I've done this before a while back and everything worked  
fine.  I thought everything was fine this time too: the drawer  
opens on command, has the correct initial size, and behaves mostly  
normally except when I try to resize the main window (with the  
drawer open).  The main window resizes just fine, but leaves the  
drawer exactly where is was (i.e. no effect on its size or position  
- i.e. because it is on the RHS of the window, it is left as an  
island if the window is made smaller horizontally, and covered up  
if the window is made bigger.  When the window is resized (for  
instance, leaving the drawer isolated), it will move the drawer (as  
an island at a fixed offset) around with it when subsequently  
moved.  If you grab the draw to resize it (i.e. pull it 'out'  
further by the right hand edge), it will suddenly snap back to  
where it should be on the right side of the window.


The NSDrawer appears to have everything it needs, but there most be  
something internally preventing the parent window's resizing from  
getting propagated (... or something).


I have no delegate set on the NSDrawer, only contentView and  
parentView outlets are connected and working.  I just want default  
sizing behaviour, so don't have a need for the delegate  
notification (and assume everything should default without it).  I  
do have some minimum size constraints set on the NSDrawer object  
(set in IB 3), and these are reasonable and correctly adhered to  
when the drawer is opened and used.


My Main Window is not (to my knowledge) special.  There ought to be  
nothing that prevents normal messages going about their business -  
it's just a regular NSView hierachy.  I am using Core Animation  
layers in the hierarchy, and have a few sibling views therein  
deliberately overlapping others (causing a warning in IB).  Could  
it be that some issue propagating subview resizing in the Main  
Window would somehow prevent continuous resize messages from  
reaching the drawer's outer window?  That seems like a non-sequitur  
as the main window ought to be able to separately indicate its  
outer frame size changes to the drawer, irrespective of what is  
going on within its bounds.


Anyway, I'm stumped (for the moment) and thought I'd fish on the  
list for ideas!


-- Lwe

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/steven.riggs 
%40me.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: Problems when putting a window between desktop and desktop icons

2008-10-27 Thread Karl Goiser

Dear Markus and others,

This is a problem that I have had with an application of mine,  
iCalViewer, which displays a window on the desktop.


What happens is that you can find a window level which draws the  
window under the desktop icons and over the desktop itself.  However,  
at that level, that window captures the mouse events as if it was  
_over_ the desktop icons.


My only solution was to disable mouse interaction with my window.


I raised this as a bug with Apple, bug number 3521992 on 5 January,  
2004 - coming up to 5 years ago!



Regards,

Karl



On 24/10/2008, at 4:48 AM, Markus Amalthea Magnuson wrote:


On Thu, Oct 23, 2008 at 19:26, Matt Neuburg <[EMAIL PROTECTED]> wrote:


Hello,

I am trying to put a window above the desktop but below the desktop
icons. I have achieved this by using the following code (in my own
subclass of NSWindow):

[self setLevel:kCGDesktopIconWindowLevel - 1];


I think what you want to say is
CGWindowLevelForKey(kCGDesktopWindowLevelKey). This should be more  
robust

than manipulating the level value directly.


Thanks for the tip! However, that doesn't really solve my problem,
which I am beginning to think is a bug on Apple's behalf. If anyone is
interested in some sample code, please download it here:

http://data.konstochvanligasaker.se/markus/GiveMeWindow.zip

Any other suggestions are welcome.
--
Markus Amalthea Magnuson

http://konstochvanligasaker.se
http://nattlek.se

"Life... is like a grapefruit. It's orange and squishy, and has a few
pips in it, and some folks have half a one for breakfast."
– Douglas Adams
___

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

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

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

2008-10-27 Thread Jerry Krinock

On 2008 Oct, 27, at 12:32, Andy Lee wrote:

I don't see that instance variable.  I only see a private  
_managedObjectContext instance variable in the header, which you  
wouldn't have access to anyway.  Am I missing something?


Well, there NSPersistentDocument has -managedObjectContext and - 
setManagedContext: methods.  So, I presume that there is an instance  
variable in there somewhere.



Should he also override -setManagedObjectContext:?


That's a whole'nother weird subject.  Trying to get rid of super's  
moc, I tried this:


NSPersistentDocument* doc = [[NSPersistentDocument alloc] init] ;
NSLog(@"After initing, moc = %@", [[doc managedObjectContext]  
description]) ;			

[doc setManagedObjectContext:nil] ;
NSLog(@"After nilling, moc = %@", [[doc managedObjectContext]  
description]) ;


Here's what I got:

  After initing, moc = 
  After nilling, moc = 

:{

My 2 cents: this seems like a brittle design -- it expects the  
overrider to know that the superclass never uses the ivar directly  
except in accessors, and it expects the implementer of the base  
class to remember never to use the ivar directly...


Yes, the more I think about this, the less I like it.  I'm going to  
step back here and try to avoid overriding that moc.


In any case, I think the documentation could be clearer and I'll  
send feedback to that effect.


Great!

___

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

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


Core Data Questions--Relationships, UUIDs, and Dirty States

2008-10-27 Thread Keary Suska
1. Confirmation clarification: do I understand correctly, considering  
typical RDBMS data integrity rules, that for most to-one  
relationships, I would set the delete rule to "no action", since  
deletion of the "many" item should not effect the "one" item?


2. How do I best implement custom UUIDs for relationships (as a  
property to an entity)? I thought I saw this come up some time ago but  
I can't seem to find the discussion.


3. How can I, in a bindings-compliant manner, report the "dirty" state  
of an NSManagedObjectContext? I know I can be notified when the  
context has changed, and when the context has saved, but what about  
when the context has been rolled back or changes undo-ed?


4. Does anyone have recommendations on how I can maintain the "dirty"  
state of a single NSManagedObject? I don't figure there is anything  
built into CD for this.


TIA,

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: how to self-delete app

2008-10-27 Thread Steven Degutis
The first thing to figure out here is why you even want to do this in the
first place. It's possible you have a legitimate reason, though more likely
is that you're using this as a solution for a problem that either may not
actually exist, or requires an entirely different kind of hammer to fix. Is
there something in particular your application is doing that requires it to
copy itself when it runs the first time? Even if so, this isn't a task to be
taken lightly. There are issues such as permissions, user consistency, etc.
to take into account. So what does your app do and why is it copying itself?
Steven Degutis
http://www.degutis.org/
http://www.thoughtfultree.com/

On Tue, Oct 28, 2008 at 10:10 AM, han <[EMAIL PROTECTED]> wrote:

> i try to implemnet a self-delete app. first start the app. a copy of the
> app is created in another direction.then,i start the copy of the app.the
> copy run and disppear.
>
> how i make the copy not disppear when start the copy.
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
>
> This email sent to [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: Overridding -[NSPersistentDocument managedObjectContext]

2008-10-27 Thread Ron Lue-Sang


On Oct 27, 2008, at 12:40 PM, Andy Lee wrote:


On Oct 27, 2008, at 3:25 PM, Ron Lue-Sang wrote:

On Oct 27, 2008, at 10:49 AM, Jerry Krinock wrote:
So it seems like I need to instead use my own instance variable,  
myMOC.  Something like this should work:


- (NSManagedObjectContext*)managedObjectContext {
 if (![self myMOC]) {
 NSManagedObjectContext* newMOC ;
//
 // ... code to alloc, initialize and configure newMOC
 //
 [self setMyMOC:newMOC] ;
 [myMOC release] ;
 }

 return [self myMOC] ;
}

But it seems odd that now super's instance variable  
managedObjectContext will just sit there forever, pointing to  
nil.  Is this the proper intended usage?




Yes, that's the intended usage. Use your own storage or call super.


Should he also override -setManagedObjectContext:?


He may choose to. It may be sufficient for him to create a new context  
in init and call [self setManagedObjectContext:] and never have to  
override either accessor.


If you're worried about some other context being set here, then yea.  
You'd need to override this and check/handle when the context isn't  
one of "yours".





My 2 cents: this seems like a brittle design -- it expects the  
overrider to know that the superclass never uses the ivar directly  
except in accessors, and it expects the implementer of the base  
class to remember never to use the ivar directly.  In any case, I  
think the documentation could be clearer and I'll send feedback to  
that effect.


Yea, I see your point. Please file away.
Thanks




--Andy




--
RONZILLA



___

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

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


LSSharedFileList API bug(s) -- workaround?

2008-10-27 Thread Steven Degutis
I've been writing my own wrapper for the LSSharedFileList API to be able to
stick it in my Cocoa app. However I've found a few bugs.
One isn't that big of a deal, but I've filed a rdar for it anyway, and it's
that you can't actually set the Hide property. It just fails in odd ways.

The other one, however, is pretty major:

When you are running a 32/64-bit Universal binary on your Release target,
calling LSSharedFileListItemResolve() at all will trigger your callback.

If you have this being called inside your callback to determine if your own
application's path is one of the Login Items (for example to update an
NSMenuitem's state), this will trigger an infinite loop!

This has made my applications' real-memory usage go up over a GB, slowing my
Mac to a crawl, for no good reason!

Also, the seed value given by each update is unique, so unfortunately we
can't just ignore it if it matches the previous seed value.

One workaround I've tried is to
use LSSharedFileListRemoveObserver() *before*
using LSSharedFileListItemResolve(), and then afterwards, add myself back as
an observer. This completely fails to do anything useful. As another shot, I
tried to add self as an observer again in a method called after a certain
delay, for example 2.0 seconds. Again, it doesn't solve the issue. Then out
of desperation, I tried to CFRelease(sharedFileList) right after removing
myself as an observer, and then create it again
using LSSharedFileListCreate() right before
calling LSSharedFileListItemResolve(). This availed me nothing.

I've not filed a bug on this yet because I've been busy doing as much
testing as I can to find a better solution, lest I have to resort to using
the old, ugly ways of hacking this Login Item problem.

If anyone has any ideas for a workaround or solution, please let me know!

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


NSPredicate exceptions with wrong level?

2008-10-27 Thread Gerd Knops

This code:

NSPredicate *aPredicate=nil;

@try
{
aPredicate=[NSPredicate predicateWithFormat:@invalid"];
}
@catch(NSExcption *e)
{
NSLog(@"Handled");
}

causes my exception handler delegate to be called with an exception  
with the NSHandleTopLevelExceptionMask even though it is clearly being  
handled. Am I missing something or is that a bug?


The @catch branch is only executed if the exception handler delegate  
declines to handle the exception.


Thanks

Gerd

___

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

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

2008-10-27 Thread Andy Lee

On Oct 27, 2008, at 3:25 PM, Ron Lue-Sang wrote:

On Oct 27, 2008, at 10:49 AM, Jerry Krinock wrote:
So it seems like I need to instead use my own instance variable,  
myMOC.  Something like this should work:


- (NSManagedObjectContext*)managedObjectContext {
  if (![self myMOC]) {
  NSManagedObjectContext* newMOC ;
//
  // ... code to alloc, initialize and configure newMOC
  //
  [self setMyMOC:newMOC] ;
  [myMOC release] ;
  }

  return [self myMOC] ;
}

But it seems odd that now super's instance variable  
managedObjectContext will just sit there forever, pointing to nil.   
Is this the proper intended usage?




Yes, that's the intended usage. Use your own storage or call super.


Should he also override -setManagedObjectContext:?

My 2 cents: this seems like a brittle design -- it expects the  
overrider to know that the superclass never uses the ivar directly  
except in accessors, and it expects the implementer of the base class  
to remember never to use the ivar directly.  In any case, I think the  
documentation could be clearer and I'll send feedback to that effect.


--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Overridding -[NSPersistentDocument managedObjectContext]

2008-10-27 Thread Andy Lee

On Oct 27, 2008, at 3:12 PM, Jerry Krinock wrote:

On 2008 Oct, 27, at 11:44, Andy Lee wrote:


- (NSManagedObjectContext*)managedObjectContext {
 NSManagedObjectContext* moc = /* ... create your own MOC ... */;

 [self setManagedObjectContext:moc];

 return moc;
}

Or alternatively, if your intent is to use the inherited behavior  
but do some additional stuff to the MOC:


- (NSManagedObjectContext*)managedObjectContext {
 NSManagedObjectContext* moc = [super managedObjectContext];

 // ... Do custom stuff to moc ...

 return moc;
}


Thanks, Andy.  It looks like I would then be creating a new moc, or  
doing custom stuff to it, whenever this getter is invoked.  No good.


Ah, I see my first proposed solution doesn't actually work, because it  
*always* creates a new moc without checking whether it's done so  
already.  But you can't use [super managedObjectContext] to check  
this, because it will use the inherited behavior to create its own moc.


I'm still not sure whether or not it is appropriate to not use  
super's managedObjectContext instance variable, as proposed at the  
bottom of my original post.



I don't see that instance variable.  I only see a private  
_managedObjectContext instance variable in the header, which you  
wouldn't have access to anyway.  Am I missing something?


It might be worth sending feedback on the documentation for - 
[NSPersistentDocument managedObjectContext].  I agree it's unclear  
*how* you're supposed to override it.  If they wanted to provide a way  
to override the creation, I think they should have factored it out  
into a separate method, perhaps -createManagedObjectContext, that  
would get called by -managedObjectContext.  But they didn't.


--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: how to self-delete app

2008-10-27 Thread Jerry Krinock


On 2008 Oct, 28, at 8:10, han wrote:

i try to implemnet a self-delete app. first start the app. a copy of  
the app is created in another direction.then,i start the copy of the  
app.the copy run and disppear.


how i make the copy not disppear when start the copy.


You would write and launch a "tool" or "background process" which  
would do all of this launching, copying, deleting, whatever, then  
terminate itself when all the work was done.  Andy Matuschak's Sparkle  
Updater does something similar...


http://bazaar.launchpad.net/%7Eandymatuschak/sparkle/main/annotate/318?file_id=relaunch.m-20080509010607-j69j7xrgk1domcop-103


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: How to draw a Recessed Button Shadow

2008-10-27 Thread Dalzhim Dalzhim
It's been a while since I haven't had a chance to work on this but I've
finally got back onto it and I still haven't found a solution to get the
bezel border to be drawn properly.  Subclassing any of the public methods
doesn't work as the closest I can get to the result I want is by overriding
drawBezelWithFrame and then I can paint the background with the color or
gradient I wish, but I still lose the bezel border and I can't seem to
reproduce that one.

When subclassing NSButton and NSButtonCell to reproduce the same behavior
with a Recessed NSButton instead of a Recessed NSPopUpButton the result
remains the same.  I can draw any background I wish but I cannot seem to
draw the bezel border.

regards


-Dalzhim



2008/10/21 Kyle Sluder
<[EMAIL PROTECTED]<[EMAIL PROTECTED]>
>

> On Tue, Oct 21, 2008 at 9:55 AM, Dalzhim Dalzhim
> <[EMAIL PROTECTED]> wrote:
> > I have already tried the methods you mention and they draw the gray
> opaque
> > background that I want to get rid of so that I can make the highlight a
> > different color, as well as drawing the arrow images.
>
> So subclass NSPopUpButton and override the implementation of those methods.
>
> --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: Overridding -[NSPersistentDocument managedObjectContext]

2008-10-27 Thread Ron Lue-Sang

Hi Jerry,
Scroll down…

On Oct 27, 2008, at 10:49 AM, Jerry Krinock wrote:


Documentation for -[NSPersistentDocument managedObjectContext] states:

"If a managed object context for the receiver does not exist, one is  
created automatically.  You override this method to customize the  
creation of the persistence stack."


Well, the first sentence leaves me in a bit of quandary when I try  
and follow the second.  Something like this won't work:


- (NSManagedObjectContext*)managedObjectContext {
   if (![super managedObjectContext]) {
   // Create a new MOC...
   // Oops, sorry, this branch will never execute.
   }

   return [self managedObjectContext] ;
}

So it seems like I need to instead use my own instance variable,  
myMOC.  Something like this should work:


- (NSManagedObjectContext*)managedObjectContext {
   if (![self myMOC]) {
   NSManagedObjectContext* newMOC ;
//
   // ... code to alloc, initialize and configure newMOC
   //
   [self setMyMOC:newMOC] ;
   [myMOC release] ;
   }

   return [self myMOC] ;
}

But it seems odd that now super's instance variable  
managedObjectContext will just sit there forever, pointing to nil.   
Is this the proper intended usage?




Yes, that's the intended usage. Use your own storage or call super.


--
RONZILLA



___

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

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

2008-10-27 Thread Jerry Krinock


On 2008 Oct, 27, at 11:44, Andy Lee wrote:


- (NSManagedObjectContext*)managedObjectContext {
  NSManagedObjectContext* moc = /* ... create your own MOC ... */;

  [self setManagedObjectContext:moc];

  return moc;
}

Or alternatively, if your intent is to use the inherited behavior  
but do some additional stuff to the MOC:


- (NSManagedObjectContext*)managedObjectContext {
  NSManagedObjectContext* moc = [super managedObjectContext];

  // ... Do custom stuff to moc ...

  return moc;
}


Thanks, Andy.  It looks like I would then be creating a new moc, or  
doing custom stuff to it, whenever this getter is invoked.  No good.


I'm still not sure whether or not it is appropriate to not use super's  
managedObjectContext instance variable, as proposed at the bottom of  
my original post.


Jerry

___

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

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

2008-10-27 Thread Andy Lee

On Oct 27, 2008, at 1:49 PM, Jerry Krinock wrote:

- (NSManagedObjectContext*)managedObjectContext {
   if (![super managedObjectContext]) {
   // Create a new MOC...
   // Oops, sorry, this branch will never execute.
   }

   return [self managedObjectContext] ;
}


Won't this lead to infinite recursion?  And why are you calling [super  
managedObjectContext] if the intent is to create your own MOC?  It  
looks like this should be something like:


- (NSManagedObjectContext*)managedObjectContext {
   NSManagedObjectContext* moc = /* ... create your own MOC ... */;

   [self setManagedObjectContext:moc];

   return moc;
}

Or alternatively, if your intent is to use the inherited behavior but  
do some additional stuff to the MOC:


- (NSManagedObjectContext*)managedObjectContext {
   NSManagedObjectContext* moc = [super managedObjectContext];

   // ... Do custom stuff to moc ...

   return moc;
}

[Disclaimer: I don't know Core Data, I'm just going by a quick look at  
the docs and a guess at your possible intentions.]


--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to exit a thread help...

2008-10-27 Thread Tom Jones

>> I'm writing a Foundation tool and I need to run a NSTask in a 
>> separate thread.


> An NSTask is a different thing from a thread.  Since NSTask provides 
> asynchronous notification of its death (and NSFileHandle provides 
> asynchronous methods for dealing with I/O), there should be no need to 
> use a separate thread to manage a task.

Yes, I'm running the NSTask in a separate thread so that the main run loop will 
not be effected.I just want the thread to exit once the NSTask is completed.


>> I have it working but when the task completes the thread is still 
>> running. I tried issuing a [NSThread exit] but that did nothing.


> By what evidence do you conclude the thread is still running, and 
> which thread are you talking about?

If I look at Activity Monitor I can see the number of threads I have, and when 
the NSTask thread is completed it's still present.


>> What am I missing?


> I suspect it's because you aren't allowing any run loops to run.  See 
> the thread beginning here: 
> http://lists.apple.com/archives/Cocoa-dev/2008/Oct/msg01016.html

Thanks,
tom
___

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

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

2008-10-27 Thread Peter Ammon


On Oct 27, 2008, at 11:28 AM, Peter Ammon wrote:



On Oct 25, 2008, at 4:07 AM, Chris Idou wrote:



Has anyone found a way to make a row in the NSPredicateEditor to  
have components taller than the standard height or a more  
complicated arrangement of components, or are you pretty much  
limited to  one row of buttons, and text fields and similar sized  
components?


Programs like Hazel are able to vary the height of rows at will,  
however it doesn't use the real NSPredicateEditor, it seems to  
simulate something similar with a table or something.


You can insert by returning it within an override of templateViews.

There's no support for multiple rows of different height though.

-Peter


I meant to write "You can insert a custom view by returning it within  
an override of templateViews," but there's no support for multiple  
rows of different height.


___

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

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

2008-10-27 Thread Peter Ammon


On Oct 25, 2008, at 4:07 AM, Chris Idou wrote:



Has anyone found a way to make a row in the NSPredicateEditor to  
have components taller than the standard height or a more  
complicated arrangement of components, or are you pretty much  
limited to  one row of buttons, and text fields and similar sized  
components?


Programs like Hazel are able to vary the height of rows at will,  
however it doesn't use the real NSPredicateEditor, it seems to  
simulate something similar with a table or something.


You can insert by returning it within an override of templateViews.

There's no support for multiple rows of different height though.

-Peter

___

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

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

2008-10-27 Thread Corbin Dunn


On Oct 27, 2008, at 10:54 AM, Carmen Cerino Jr. wrote:


Howdy,

My goal is to create an upload dialog. Like most upload/download  
dialogs, I
am going to use a table view to display my information. Eventually I  
will
need to create my own custom NSCell in order to represent an item  
being
uploaded, so I can  represent multiple pieces of information in one  
cell. I
am currently having difficulty getting my NSTableView setup in order  
to
accept this custom NSCell. I first tried doing the usual, and adding  
an
NSTableView in IB. I can't seem to figure out how to make IB  
recognize my
custom NSCell class so it appears in the drop down list for the cell  
in my

table's column.


I first comment checking out this demo:

http://developer.apple.com/samplecode/PhotoSearch/

Chances are, you need to subclass NSTextFieldCell instead of NSCell --  
try that, and then you will be able to set the custom class in IB.  
This is a known problem with IB.



Next I tried adding an NSTableView to my view in my code. I
was able to successfully set the cell for my table's column to my  
custom
cell, but I was not able to figure out how to go about getting the  
TableView

to size properly. In other words, I would set my the ScrollView that
enclosed the TableView to be 400x400, but the TableView would size  
to fit
the data instead of matching the size of its container. I thought  
setting
the TableView's size to match that of the ScrollView would fix the  
problem,

but for some reason it doesn't.


NSTableView should do it automatically; instead of creating the table  
in code, can you put it into a nib? That will save you a lot of  
trouble. If you are using a nib, then something else may be setup wrong.


corbin

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSTableView Questions

2008-10-27 Thread Carmen Cerino Jr.
Howdy,

My goal is to create an upload dialog. Like most upload/download dialogs, I
am going to use a table view to display my information. Eventually I will
need to create my own custom NSCell in order to represent an item being
uploaded, so I can  represent multiple pieces of information in one cell. I
am currently having difficulty getting my NSTableView setup in order to
accept this custom NSCell. I first tried doing the usual, and adding an
NSTableView in IB. I can't seem to figure out how to make IB recognize my
custom NSCell class so it appears in the drop down list for the cell in my
table's column. Next I tried adding an NSTableView to my view in my code. I
was able to successfully set the cell for my table's column to my custom
cell, but I was not able to figure out how to go about getting the TableView
to size properly. In other words, I would set my the ScrollView that
enclosed the TableView to be 400x400, but the TableView would size to fit
the data instead of matching the size of its container. I thought setting
the TableView's size to match that of the ScrollView would fix the problem,
but for some reason it doesn't.


Any advice on the best approach for designing this project would be greatly
appreciated.


Carmen C. Cerino Jr.
___

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

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


Overridding -[NSPersistentDocument managedObjectContext]

2008-10-27 Thread Jerry Krinock

Documentation for -[NSPersistentDocument managedObjectContext] states:

"If a managed object context for the receiver does not exist, one is  
created automatically.  You override this method to customize the  
creation of the persistence stack."


Well, the first sentence leaves me in a bit of quandary when I try and  
follow the second.  Something like this won't work:


- (NSManagedObjectContext*)managedObjectContext {
if (![super managedObjectContext]) {
// Create a new MOC...
// Oops, sorry, this branch will never execute.
}

return [self managedObjectContext] ;
}

So it seems like I need to instead use my own instance variable,  
myMOC.  Something like this should work:


- (NSManagedObjectContext*)managedObjectContext {
if (![self myMOC]) {
NSManagedObjectContext* newMOC ;
//
// ... code to alloc, initialize and configure newMOC
//
[self setMyMOC:newMOC] ;
[myMOC release] ;
}

return [self myMOC] ;
}

But it seems odd that now super's instance variable  
managedObjectContext will just sit there forever, pointing to nil.  Is  
this the proper intended usage?


Thanks,

Jerry Krinock


[1] http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPersistentDocument_Class/Reference/Reference.html#/ 
/apple_ref/occ/instm/NSPersistentDocument/managedObjectContext

___

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

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

2008-10-27 Thread David Duncan

On Oct 26, 2008, at 3:06 PM, Tommy Nordgren wrote:


A specific printer can be used ONLY by a special app.


Any printer that can be seen by Print Center can be used by all  
applications by default. If you are a printer vendor, then you can do  
additional things, but you will need to write to CUPS (the subsystem  
that eventually handles all printing on Mac OS X).



Changing printer settings for an App affects that app only.


Some printer settings are system wide, some are tied to print  
sessions. What settings do you need to change?

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Leaking CGColor objects

2008-10-27 Thread David Duncan

On Oct 26, 2008, at 1:06 PM, DKJ wrote:

In the documentation, the foregroundColor property is defined like  
this:


@property CGColorRef foregroundColor

There's no retain parameter.



Correct, however the property is implemented as if it was retain. This  
is because the compiler will generate a warning (or error, can't  
recall which at the moment) when you declare a retained property for a  
non-Obj-C object - which as far as the compiler can tell is all Core  
Foundation data types.


For the purposes of Core Animation at least, you can assume that all  
properties that operate on Core Foundation data types are retained  
properties and that the appropriate Core Animation object will  
property release them when that object is deallocated. Thus the  
correct way to assign a foregroundColor is


CGColorRef color = CGColorCreateGenericRGB(...);
self.foregroundColor = color;
CFRelease(color);

And you don't need to release it yourself in a custom dealloc method  
(the layer is responsible for that).

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSImage/NSImageView opacity (solved)

2008-10-27 Thread Randall Meadows

On Oct 24, 2008, at 10:27 PM, Randall Meadows wrote:


On Oct 24, 2008, at 8:00 PM, Ken Ferry wrote:

Yes, -cacheDisplayInRect:toBitmapImageRep: is going to end up  
calling drawRect:.  It's not meant to be invoked _from_ drawRect:.




You can call that from another view, or from a controller, or  
whatever.


That's what I'm doing; I am calling cacheDisplay... on the  
viewToReflect *from* the reflectionView's -drawRect, not its own - 
drawRect.  But when I do that, reflectionView's -drawRect is called,  
not viewToReflect's -drawRect.  That's why I said it all seemed so  
logical, but the behavior I'm seeing is not.


I am, I *really* am.  Trust me. :)

The problem, as it turns out, is that the outlet "viewToReflect" was  
attached to the NSView that was *containing* both the reflectionView  
and the viewToReflect (for resizing purposes), instead of *just* the  
viewToReflect view.  G...the difference in types caused IB to  
connect it to the parent view instead, which I didn't notice that,  
which was causing the wrong view to be (re)drawn.


(It's amazing what solutions to problems come to me in the shower,  
when I'm not even really thinking about the problem...)


Anyway, thanks again, Ken, for the tip to that cacheDisplay... call;  
working like a charm now!


randy
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Not so long filenames

2008-10-27 Thread Shawn Erickson
http://developer.apple.com/technotes/tn/tn1150.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]


Re: Newbie: Referencing Objects (second try)

2008-10-27 Thread Andreas Mayer


Am 27.10.2008 um 03:20 Uhr schrieb john fogg:


And how do I do this with my main application delegate? I want to call
it from wherever I am.



That one is already stored by your NSApplication object:

[NSApp delegate]

NSApp is a predeclared global variable that holds the current  
NSApplication instance.



Andreas
___

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

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

2008-10-27 Thread Corbin Dunn


On Oct 26, 2008, at 3:29 PM, Graham Cox wrote:

Let's say I have a NS(Mutable)Dictionary and I'd like to make a very  
simple editor for its keys and values. So I have a NSTableView with  
two columns, key and value. The dictionary can contain any mix of  
strings and numbers, and the numbers can be ints or reals.


I find that when setting an edited value for a given key, everything  
gets converted to a string, because the object type returned by the  
table is a string. (The column type for value is a string, but  
numbers passed as the object value are automatically converted. I'm  
not using a formatter.)


That's right; setObjectValue: on a text cell will ultimately make it  
into a string that can be displayed and edited by the user.





Is there a simple way to allow the table to edit a value but  
preserve its type in the dictionary?


You probably want to set an appropriate formatter on the cell in - 
willDisplayCell:. This sounds like the best approach to what you are  
wanting. You could always right a custom formatter if you need to.


corbin

I could check the type of the key I'm about to set and convert each  
value to that type, but it seems very clunky. I feel I've missed  
something obvious.


___

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

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

2008-10-27 Thread Filip van der Meeren

Lol !

On 27 Oct 2008, at 16:57, Jonathan del Strother wrote:

On Tue, Oct 28, 2008 at 4:54 PM, han <[EMAIL PROTECTED]>  
wrote:

how to run single instance?


Double click
___

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

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

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

This email sent to [EMAIL PROTECTED]


Filip van der Meeren
http://www.sourceforge.net/projects/xlinterpreter




___

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

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

2008-10-27 Thread Jonathan del Strother
On Tue, Oct 28, 2008 at 4:54 PM, han <[EMAIL PROTECTED]> wrote:
> how to run single instance?

Double click
___

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

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


how to run single instance?

2008-10-27 Thread han

how to run single instance?
___

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

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


CF equivalent of NSPortMessage?

2008-10-27 Thread James Trankelson
I've been running a multithreaded application that listens for
messages from other threads within the same application. I've build a
number of applications that work in this way, and they've worked well.
However, I've recently been trying to write the CoreFoundation
equivalent of my existing mechanism, and haven't yet had any success.
I'm wondering if someone can help me see where I'm going wrong...

My (working) approach is as follows. Somewhere in my application, I
spawn a thread, which creates a port and listens on it. I create the
thread like so:

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

With the thread method as follows:

-(void) listener {
...
port = (NSMachPort *)[NSMachPort port];
[port setDelegate:self];
[[NSRunLoop currentRunLoop] port forMode:NSDefaultRunLoopMode];

for(;;) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
}


I send a message like so:

 NSPortMessage *message = [[NSPortMessage alloc]
initWithSendPort:np->port receivePort:np->port components:nil];
 [np->port sendBeforeDate:[NSDate distantFuture] components:nil
from:nil reserved:0];
 [message sendBeforeDate:[NSDate distantFuture]]);

When my thread gets this message, the "handlePortMessage" delegate
gets called, and everything is OK. Done.

Now for my attempt at a CoreFoundation version:

I create the thread in the same way, and do all of the CoreFoundation stuff:

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

 -(void) listener {
...
CFMessagePortRef local =
CFMessagePortCreateLocal(kCFAllocatorDefault, CFSTR("myport"),
myCallBack, &portContext, false);
CFRunLoopSourceRef source =
CFMessagePortCreateRunLoopSource(kCFAllocatorDefault, local, 0);
CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode);
CFRunLoopRun();

Once this is set up, I try to send a message to this port in the
following manner:

CFMessagePortRef remote = CFMessagePortCreateRemote(NULL, CFSTR("myport"));
char *message = "Hello!";
CFDataRef data, returnData = NULL;
data = CFDataCreate(NULL, message, strlen(message)+1);
CFMessagePortSendRequest(remote, 0, data, 1, 1, kCFRunLoopDefaultMode,
&returnData);

And it appears to work okay, because when I send a message like this,
my "myCallBack" method indeed gets invoked. However, I invariably get
a BAD_ACCESS at random points during the execution of the callback.
Usually not the same place.

Any ideas on what would cause this type of behavior? My loop appears
to be set up appropriately... Is there a better way to translate the
NSPortMessage version to use CoreFoundation functionality?

Thanks for any help!

-jt
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Finding out that a volume is going away before it does

2008-10-27 Thread Ken Thomases

On Oct 27, 2008, at 8:42 AM, Gregory Weston wrote:


On Oct 27, 2008, at 9:31 AM, Francis Devereux wrote:


On 26 Oct 2008, at 16:37, Gregory Weston wrote:

Amusingly, when you register an unmount or eject approval function  
with DiskArbitration, that function gets invoked *after*  
NSWorkspace sends its didUnmount notification. How's that for a  
lead-in anecdote?




I think you're putting too much stock into this ordering.  Think about  
it: how do you think NSWorkspace arranges to learn about volume  
unmounts in order to deliver the notification?  It probably registers  
a callback with DiskArbitration.  If so, then the fact that it is  
delivering its unmount notification before your callback gets called  
is probably just due to the order in which the callbacks were  
registered.  Both your code and NSWorkspace are probably responding to  
the same mechanism.




Have you actually tried using DiskArbitration unmount approval  
callbacks?  I decided to give it a go and was able to successfully  
call FSGetVolumeInfo in the callback.  Tested with OS X 10.5.5 and  
Xcode 3.1.1.


I did; that's how I noticed that the approval callback happened  
after the unmount notification.


So what?  Why do you care about this ordering?

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]


how to self-delete app

2008-10-27 Thread han
i try to implemnet a self-delete app. first start the app. a copy of the 
app is created in another direction.then,i start the copy of the app.the 
copy run and disppear.


how i make the copy not disppear when start the copy.
___

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

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

2008-10-27 Thread Ralph Manns
Hello Thomas,
thanks you, works great.
The documentation says setContentResizingMask determines how the receiver
resize its content when zooming...

Thanks, Ralph.

2008/10/27 Thomas Goossens <[EMAIL PROTECTED]>

> Hi Ralph,
>
> Use setContentResizingMask: with NSViewWidthSizable so that the
> IKImageBrowserView resizes its content horizontally when zooming/resizing...
> -- Thomas
>
> On Oct 27, 2008, at 2:06 PM, Ralph Manns wrote:
>
> Hello,
> is there a away to limit the number of rows to 1, so that
> IKImageBrowserView
> scrolls only horizontal ?
>
> Ralph
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/tgoossens%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: Bind button title to Boolean

2008-10-27 Thread Steve Christensen

On Oct 27, 2008, at 3:32 AM, Trygve Inda wrote:

How can I bind a button title to a Boolean but have a custom title  
for each
state? For example, I have a BOOL  isRunning, if YES, my button  
should read

"Stop Running" else "Start Running".

I can't really do this with an alternate title since when the  
button is
pushed and temporarily held down, the title should not change as it  
is a

normal push "pill" button.


How about something like this? Whenever isRunning changes, it  
triggers an update of the button's title.



+ (void) initialize
{
...

[self setKeys:[NSArray arrayWithObject:@"isRunning"]
triggerChangeNotificationsForDependentKey:@"buttonTitle"];

...
}


- (NSString*) buttonTitle
{
return [self isRunning] ? @"Stop Running" : @"Start Running";
}


- (BOOL) isRunning
{
return _isRunning;
}

- (void) setIsRunning:(BOOL)isRunning
{
[self willChangeValueForKey:@"isRunning"];
_isRunning = isRunning;
[self didChangeValueForKey:@"isRunning"];
}

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Finding out that a volume is going away before it does

2008-10-27 Thread Gregory Weston


On Oct 27, 2008, at 9:31 AM, Francis Devereux wrote:


On 26 Oct 2008, at 16:37, Gregory Weston wrote:

Amusingly, when you register an unmount or eject approval function  
with DiskArbitration, that function gets invoked *after*  
NSWorkspace sends its didUnmount notification. How's that for a  
lead-in anecdote?


So anyway, I'm looking to react to the imminent or even potential  
departure of a volume. Some way I can know that a volume will (or  
probably will) be taken away from me in the near future but with  
enough lead time that I can reliably make one or two quick  
function calls against it. Any thoughts? I'm not worried about  
abrupt disconnects like the user yanking the cable on an external  
drive. Just looking for the tiniest smidgen of warning for orderly  
unmounts.


Specifically, I'm looking for the opportunity to call  
FSGetCatalogInfo on the mount point and then FSGetVolumeInfo on  
the volume reference number I got back from the first call.


Have you actually tried using DiskArbitration unmount approval  
callbacks?  I decided to give it a go and was able to successfully  
call FSGetVolumeInfo in the callback.  Tested with OS X 10.5.5 and  
Xcode 3.1.1.


I did; that's how I noticed that the approval callback happened after  
the unmount notification. My test case was on a 10.4 machine and I  
actually need to support 10.3+. If it's something they've only fixed  
some time in the last year it's not especially helpful to me today.  
But I appreciate the data point.


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: How to check the number of pending events in the application event queue?

2008-10-27 Thread Oleg Krupnov
Yes, I'd really like to avoid multi-threading. There would be an
intense data exchange between the threads and the effort for
synchronization would be simply not justified for such a tiny feature.
Actually I did try multi-threading before I arrived to this solution,
and I have spent very long and painful day debugging some weird
rare-happening synchronization bug. Besides, real multi-threaded task
works slightly different than simply postponed-to-idleness task. The
two threads may be running simultaneously even if the main thread has
a higher priority, whereas I'd prefer strict suspension of the
secondary task when the main thread wakes up.


On Mon, Oct 27, 2008 at 3:05 PM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:
>
> Le 27 oct. 08 à 13:54, Oleg Krupnov a écrit :
>
>> In my app I'd like to perform some background task without affecting
>> the responsiveness of the UI. To avoid multi-threading, I just
>> postpone the task to a moment when the user becomes and stays idle for
>> a certain time.
>>
>
> Have you a good reason to avoid multi-threading ?
>
>
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: How to check the number of pending events in the application event queue?

2008-10-27 Thread Jean-Daniel Dupas


Le 27 oct. 08 à 13:54, Oleg Krupnov a écrit :


In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle for
a certain time.



Have you a good reason to avoid multi-threading ?

___

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

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

2008-10-27 Thread Thomas Goossens

Hi Ralph,

Use setContentResizingMask: with NSViewWidthSizable so that the  
IKImageBrowserView resizes its content horizontally when zooming/ 
resizing...


-- Thomas

On Oct 27, 2008, at 2:06 PM, Ralph Manns wrote:


Hello,
is there a away to limit the number of rows to 1, so that  
IKImageBrowserView

scrolls only horizontal ?

Ralph
___

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

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

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


IKImageBrowserView only horizontal scrolling

2008-10-27 Thread Ralph Manns
Hello,
is there a away to limit the number of rows to 1, so that IKImageBrowserView
scrolls only horizontal ?

Ralph
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: How to check the number of pending events in the application event queue?

2008-10-27 Thread Tommy Nordgren


On 27 okt 2008, at 13.54, Oleg Krupnov wrote:


In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle for
a certain time.

I call NSObject's performSelector: afterDelay: and then use
CGEventSourceSecondsSinceLastEventType to check if the idleness period
has elapsed. If not, I wait again the remaining time, else I begin
performing the task.

Also, because the background task is quite lengthy, I make the task
poll periodically if the user has become active during the task, and
in this case postpone the task's continuation again until the user
becomes idle again.

This solution seems to be quite good, but for one question : how do I
check if there are pending events in the application's queue right at
the moment of timer firing? This would work as a double-check that
there are no pending tasks for the application (e.g. other periodic
events of the app) that would always have to be done before the
low-priority background task.

I tried NSApplication's nextEventMatchingMask, but it blocks execution
if there are no events, whereas I'd like it to return nil. Any other
suggestions?
___


Use a separate thread.
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[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]


How to check the number of pending events in the application event queue?

2008-10-27 Thread Oleg Krupnov
In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle for
a certain time.

I call NSObject's performSelector: afterDelay: and then use
CGEventSourceSecondsSinceLastEventType to check if the idleness period
has elapsed. If not, I wait again the remaining time, else I begin
performing the task.

Also, because the background task is quite lengthy, I make the task
poll periodically if the user has become active during the task, and
in this case postpone the task's continuation again until the user
becomes idle again.

This solution seems to be quite good, but for one question : how do I
check if there are pending events in the application's queue right at
the moment of timer firing? This would work as a double-check that
there are no pending tasks for the application (e.g. other periodic
events of the app) that would always have to be done before the
low-priority background task.

I tried NSApplication's nextEventMatchingMask, but it blocks execution
if there are no events, whereas I'd like it to return nil. Any other
suggestions?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Finding out that a volume is going away before it does

2008-10-27 Thread matt . gough


On 27 Oct 2008, at 12:30, Gregory Weston wrote:

The documentation you attached included a caveat that the volume  
reference number I'd receive isn't useful for anything except  
comparison against cached data. Can't use FSGetVolumeInfo.


The assumption being that you already have a cache of vRefNums and  
whatever info you need from their FSGetVolumeInfo calls.


Perhaps if you mention what you are actually trying to do we might be  
able to find a better/simpler solution.


Matt
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Finding out that a volume is going away before it does

2008-10-27 Thread Gregory Weston


On Oct 27, 2008, at 4:37 AM, [EMAIL PROTECTED] wrote:



On 26 Oct 2008, at 17:37, Gregory Weston wrote:


Specifically, I'm looking for the opportunity to call  
FSGetCatalogInfo on the mount point and then FSGetVolumeInfo on  
the volume reference number I got back from the first call.


Greg


It look to me like registering for kEventClassVolume /  
kEventVolumeUnmounted carbon events would do what you need. This  
will tell you the cRefNum of the unmounted volume (once again  
though after it had gone).


The documentation you attached included a caveat that the volume  
reference number I'd receive isn't useful for anything except  
comparison against cached data. Can't use FSGetVolumeInfo. 
___


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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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] Amsterdam CocoaHeads Thursday 10/30 7:00pm

2008-10-27 Thread Cathy Shive
The first meeting of CocoaHeads Amsterdam chapter will be this  
Thursday - October 30th - from 7:00 - 9:00pm.


The meeting will be at the Sofa (http://www.madebysofa.com) office:

Hasebroekstraat 10-12
1053 CT, Amsterdam

Map:
http://maps.google.com/maps?f=q&hl=en&geocode=&q=Hasebroekstraat+10-12+amsterdam&sll=37.0625,-95.677068&sspn=48.555061,66.796875&ie=UTF8&t=h&z=16&g=Hasebroekstraat+10-12+amsterdam&iwloc=addr

The agenda for this first meeting is simply to get to some Cocoa  
developers in and around Amsterdam together in one room.  There will  
be beer in the room.


Hope to see you there!
Cathy

___

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

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

2008-10-27 Thread Trygve Inda
> How can I bind a button title to a Boolean but have a custom title for each
> state? For example, I have a BOOL  isRunning, if YES, my button should read
> "Stop Running" else "Start Running".
> 
> I can't really do this with an alternate title since when the button is
> pushed and temporarily held down, the title should not change as it is a
> normal push "pill" button.

I know I can write a value transformer, but is there a simple way to do such
a two state button title in IB and just provide it my "isRunning" method? It
seems like a common enough default situation.

T.


___

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

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


Bind button title to Boolean

2008-10-27 Thread Trygve Inda
How can I bind a button title to a Boolean but have a custom title for each
state? For example, I have a BOOL  isRunning, if YES, my button should read
"Stop Running" else "Start Running".

I can't really do this with an alternate title since when the button is
pushed and temporarily held down, the title should not change as it is a
normal push "pill" button.

Thanks,

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: Finding out that a volume is going away before it does

2008-10-27 Thread matt . gough


On 26 Oct 2008, at 17:37, Gregory Weston wrote:


Specifically, I'm looking for the opportunity to call  
FSGetCatalogInfo on the mount point and then FSGetVolumeInfo on the  
volume reference number I got back from the first call.


Greg


It look to me like registering for kEventClassVolume /  
kEventVolumeUnmounted carbon events would do what you need. This will  
tell you the cRefNum of the unmounted volume (once again though after  
it had gone).


Matt Gough


 *  kEventClassVolume / kEventVolumeUnmounted
 *
 *  Summary:
 *An existing volume has been unmounted (or media ejected).
 *
 *  Discussion:
 *This event is sent to all handlers registered for it.
 *
 *  Mac OS X threading:
 *Not thread safe
 *
 *  Parameters:
 *
 *--> kEventParamDirectObject (in, typeFSVolumeRefNum)
 *  The volume refnum of the volume that was unmounted. At the
 *  point when this event is sent, this is no longer a valid
 *  volume refnum, and cannot be passed to any File Manager
 *  API; it is useful only for comparison with cached volume
 *  refnums in your own data structures.
 *
 *  Availability:
 *Mac OS X: in version 10.0 and later in Carbon.framework
 *CarbonLib:in CarbonLib 1.3.1 and later
 */
enum {
  kEventVolumeUnmounted = 2

___

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

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

2008-10-27 Thread Graham Cox


On 27 Oct 2008, at 3:47 pm, Michael Ash wrote:


As far as I know the conversion happens upon request, not upon
storage. In other words, the internal representation is of the type
you initially used to create the NSNumber. If you then request the
value through a method whose type doesn't match, it retrieves the
internal representation, converts it to the requested type, then
returns that. The internal storage remains the original type, so you
can still distinguish between how they were created.



If true, I can rest easy! But there is this remark:

"Note, though, that if you ask a number for its objCType, the returned  
type does not necessarily match the method the receiver was created  
with."


found here:

http://developer.apple.com/documentation/Cocoa/Conceptual/NumbersandValues/Articles/Numbers.html

which appears to suggest that there are cases where conversion happens  
at creation time and that the information about the original type is  
lost. Unfortunately the docs aren't more explicit. :(



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