Re: Two text fields, one outlet?

2010-04-04 Thread Joanna Carter
Hi Jenny

> Is it possible to link multiple NSTextFields to one outlet? I have
> three views - one of A items, one of B items, and one of both A and B
> items. So the text boxes in the A view also exists in the A&B view,
> and the value needs to be able to appear in both, though not at the
> same time. I have a method that calculates values and sets the textbox
> values (or label values, same concept) using an outlet, but I don't
> want it to set 2 outlets, I want it to just set 1.
> 
> Is this possible using outlets or bindings??
> 
> Or is there a way I can place two NSViews into one NSView so there's
> only one copy of everything?

You can certainly bind any number of UI objects to a single property of an 
object.

Specifying an IBOutlet is only necessary if you want to create a connection and 
can only be connected to one thing at a time. Simply specify a property and 
bind the NSTextFields to that.

@interface MyClass
{

}

@property (nonatomic, retain) NSString *aTextValue;

@end

@implementation MyClass

@synthesize aTextValue;

@end

With the later versions of the compiler, you don't even need to specify an 
ivar, it will be created for you.

Joanna

--
Joanna Carter
Carter Consulting

___

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

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

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

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


file path question

2010-04-04 Thread Ariel Feinerman
Hi,
Can we load resource by -*pathForRecourse: ofType: inDirectory:* outside the
bundle folder? Second, there is absolute path represented by NSString,  is
the way to check whether file exist?
-- 
best regards
Ariel
___

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

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

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

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


Re: file path question

2010-04-04 Thread Rajendran_Pichaimurthy
Hi,

To check the file existence use
{
NSFileManager *fileManager = [NSFileManager defaultManager]
BOOL fileexist = [ fileManager  fileExistsAtPath:YOURPATH];
}
- (BOOL)fileExistsAtPath:(NSString *)path

*pathForResource: ofType: inDirectory:*  does not load files outside bundle

Thanks
Rajendran P


On 04/04/10 3:31 PM, "Ariel Feinerman"  wrote:

Hi,
Can we load resource by -*pathForRecourse: ofType: inDirectory:* outside the
bundle folder? Second, there is absolute path represented by NSString,  is
the way to check whether file exist?
--
best regards
Ariel
___

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

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

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

This email sent to rajendran_pichaimur...@mcafee.com

___

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

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

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

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


Mysterious 'QLPreviewView ' crashes.

2010-04-04 Thread Paul Sanders
Anyone ever seen crashes like this before?

http://www.alpinesoft.co.uk/private/crash1.txt
http://www.alpinesoft.co.uk/private/crash2.txt
http://www.alpinesoft.co.uk/private/crash3.txt

These (just these 3) have been reported by customers over the last month or so. 
 We have only seen them on Snow Leopard, but we hardly have a statistical 
sample.  I have never seen it during development or testing.  It seems to be 
connected with disposal of a QLPreviewView by NSOpenPanel when it is closed.  
Note that it's not the main thread that crashes, but it looks like it's doing 
something that whipped the rug out from under the thread that did.  Note also 
that in all cases the faulting address appears to be part of an ASCII string 
(and not one I recognise).

I have raised a bug report about this (7826287) but I thought I'd see if 
anybody here has seen something similar.  I don't think it's us.  I like to 
think that we see these weird, rare crashes because of the reporting facility 
(based on Uli Kusterer's UKCrashReporter) built into our software, rather than 
the fact that we have lots of bugs in our own code.  AFAIK, we are good 
citizens when it comes to respecting other people's memory, but you can never 
be 100% sure.

Paul Sanders.
___

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

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

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

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


Finding managed objects by URI representation

2010-04-04 Thread Gideon King
I have some queries that used to look up objects based on an elementID 
attribute, which used to be my unique identifier for objects, created when the 
objects were inserted or loaded. I am now moving away from that and using the 
standard managed object IDs and reference objects.

So I used to do things like for a drag and drop of objects, I would have 
predicates like this (where the identifiers were the elementIDs of the objects 
I was dragging):

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K in %@", 
@"elementID", identifiers];

I guess that I will now have to use a different way of referencing it, and was 
thinking that I could create the identifiers as:

[[[theManagedObject objectID] URIRepresentation] absoluteString]

but if I was to do that, in order to search using a predicate, I would have to 
create a read only attribute on my managed objects that would return that 
value, right?

So I would create something like the following:

@property (readonly) NSString *uriStringRepresentation;

...

- (NSString *) uriStringRepresentation {
return [[[self objectID] URIRepresentation] absoluteString];
}

...

And then in my search:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K in %@", 
@"uriStringRepresentation", identifiers];


Is this a good way of accomplishing my goal?

My concern with this is that although this might work at the moment, I'm 
planning to implement autosave (haven't looked into how to do this yet), and if 
a save had happened and it was previously a temporary ID, and now it's been 
changed due to the save, then I wouldn't be able to get it back again. 

I'm sort of looking at possible alternatives like using the MOCs 
persistentStoreCoordinator to get the managedObjectIDForURIRepresentation:, and 
then the MOC objectWithID: method to get the actual object back, but don't know 
if managedObjectIDForURIRepresentation: would handle the temporary ID situation 
and potential switch to a permanent ID on save.

I see a few posts along these lines in the past, but I haven't specifically 
seen anything that says whether any of the methods will cope with looking up a 
temporary URI, if it has now been turned into a permanent one.

If it can handle the transition from temporary to permanent ID, then I might 
also use this in a place where I need to partially generate some of my file 
relationships before save. I could save the URIs and then be able to look them 
up in the persistent store coordinator, and replace my URI references with the 
reference object using referenceObjectForObjectID: during the save operation. 
The documentation says that newReferenceObjectForManagedObject: is called 
*after* the MOC has saved, but from what I can see, this happens *before* my 
atomic store's save: method is called, so calling referenceObjectForObjectID: 
during save of an atomic store always retrieve the permanent id. 

Any comments on whether this would be a good way of accomplishing this?

Thanks

Gideon






___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Ken Thomases
On Apr 3, 2010, at 8:31 PM, Jens Alfke wrote:

> Ken, he asked for a reference that wouldn't break if the file were moved or 
> renamed. Neither FSrefs nor URLs have that property.

Yes, they do.

From the link I gave 
:

"File reference URLs provide a way to track a file by its ID. This means that 
the reference is valid even if the file’s name or location in the file system 
changes."

File reference URLs are new with Snow Leopard.  Check out the release notes and 
"What's New in Mac OS X: Mac OS X 10.6" to learn about them.

And FSRefs have always had this property.  Adding file reference URLs was 
essentially a way of allowing URLs to provide analogous functionality as FSRefs.

Regards,
Ken

___

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

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

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

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


What patterns did we miss in "Cocoa Design Patterns"?

2010-04-04 Thread Erik Buck
Don Yacktman and I have received feedback that "Cocoa Design Patterns" should 
have more coverage of multi-threaded and distributed design patterns.  Some 
readers have asked for comparison and contrast between Cocoa design patterns 
and patterns in .Net or other frameworks.  Is it worthwhile to restate the 
patterns in terms specific to Cocoa Touch, or are you comfortable extrapolating 
examples from Cocoa to Cocoa Touch?

I am considering adding some supplemental articles to the book's web site or to 
http://www.cocoadev.com/.  What additional patterns should be discussed?  
Should I make supplemental content editable as a wiki?

For reference: 
site www.cocoadesignpatterns.com
Table Of Contents http://my.safaribooksonline.com/9780321591210

Free samples:
Prefacehttp://my.safaribooksonline.com/9780321591210/pref03
Chapter  1 http://www.informit.com/articles/article.aspx?p=1398611
Chapter 29 http://www.informit.com/articles/article.aspx?p=1397563
Chapter 30 http://www.informit.com/articles/article.aspx?p=1397564
Chapter 03 http://www.informit.com/articles/article.aspx?p=1339553


___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Gregory Weston
Ken Thomases  wrote:

> As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
> but, again, it's probably overkill.  (Both alias records and bookmark data 
> are more suitable if the reference is to be persisted for use by a later 
> process.  Also, both can apply more robust searching heuristics to find an 
> appropriate file even if it isn't the original.  For example, if the original 
> is deleted and replaced with a new file of the same name.)

Having missed the introduction of the new bookmark routines, and having not 
gotten any warnings in my code, I was a bit surprised to read that alias 
records are deprecated. From a quick scan, it looks like the bookmark methods 
are wrappers around the alias manager with (after about 20 years) an official 
mechanism for creating Finder alias files.
G
___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Ken Thomases
On Apr 4, 2010, at 12:06 PM, Gregory Weston wrote:

> Ken Thomases  wrote:
> 
>> As of Snow Leopard, alias records are deprecated in favor of bookmark data, 
>> but, again, it's probably overkill.  (Both alias records and bookmark data 
>> are more suitable if the reference is to be persisted for use by a later 
>> process.  Also, both can apply more robust searching heuristics to find an 
>> appropriate file even if it isn't the original.  For example, if the 
>> original is deleted and replaced with a new file of the same name.)
> 
> Having missed the introduction of the new bookmark routines, and having not 
> gotten any warnings in my code, I was a bit surprised to read that alias 
> records are deprecated.

Sorry.  I probably shouldn't have said "deprecated".  Aliases are not 
officially deprecated, as far as I know.  Perhaps "superseded" is a better 
word.  Bookmarks are clearly the new Apple-preferred way of achieving what used 
to be done with aliases.

> From a quick scan, it looks like the bookmark methods are wrappers around the 
> alias manager with (after about 20 years) an official mechanism for creating 
> Finder alias files.

Well, conceptually, bookmarks are a superset of alias records.  However, I 
believe that they have separate representations.  In particular, some of the 
documentation mentions that alias files created using the bookmark API contain 
both the bookmark data and the old-style alias record, separately.

Also, bookmark data records some of the file properties so you can query them 
without having to resolve or access the original file.

Regards,
Ken

___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Jens Alfke
You're saying that if I have a FSRef to a file, then the file is moved, the 
FSRef will still reference the moved file and not the location where it used to 
be?

That's surprising to me, because FSRefs were created as a replacement for 
FSSpecs, which do not have that property (they were a struct {volume ID, dir 
ID, filename}.)

Anyway, note that a file inode ID is more fragile than an alias/bookmark, 
because it won't survive the common practice of replacing an old copy of a file 
with a new one ("safe save") unless the code doing the replace is careful to 
propagate metadata to the new file. 

--Jens {via iPad}

On Apr 4, 2010, at 8:00 AM, Ken Thomases  wrote:

> On Apr 3, 2010, at 8:31 PM, Jens Alfke wrote:
> 
>> Ken, he asked for a reference that wouldn't break if the file were moved or 
>> renamed. Neither FSrefs nor URLs have that property.
> 
> Yes, they do.
> 
> From the link I gave 
> :
> 
> "File reference URLs provide a way to track a file by its ID. This means that 
> the reference is valid even if the file’s name or location in the file system 
> changes."
> 
> File reference URLs are new with Snow Leopard.  Check out the release notes 
> and "What's New in Mac OS X: Mac OS X 10.6" to learn about them.
> 
> And FSRefs have always had this property.  Adding file reference URLs was 
> essentially a way of allowing URLs to provide analogous functionality as 
> FSRefs.
> 
> Regards,
> Ken
> 
___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Ken Thomases
On Apr 4, 2010, at 12:50 PM, Jens Alfke wrote:

> You're saying that if I have a FSRef to a file, then the file is moved, the 
> FSRef will still reference the moved file and not the location where it used 
> to be?

Yes.  They are file-ID-based.


> That's surprising to me, because FSRefs were created as a replacement for 
> FSSpecs, which do not have that property (they were a struct {volume ID, dir 
> ID, filename}.)

True, although FSSpecs should have tracked the parent directory should it have 
been moved or renamed.  I'm not sure they did, though.

Also, remember that, unlike FSSpecs, FSRefs can only refer to existing 
files/directories -- precisely because they are file-ID-based.

It's hardly surprising that the replacement differs from the original, 
otherwise why replace the original?

Cheers,
Ken

___

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

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

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

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


Re: Terminating subtasks reliably

2010-04-04 Thread Julian Hsiao
Why not have the parent call setsid() / setpgid() at the beginning?  This 
should prevent the PID from getting recycled until every process in the process 
group exits.

Julian Hsiao
mad...@nyanisore.net

On Apr 2, 2010, at 8:10 PM, Michael Ash wrote:

> On Thu, Apr 1, 2010 at 7:19 PM, Dave Keck  wrote:
 Look like a race condition. The man page says getppid() will not fail, but
 not what happens after the parent dies. I will test this.
>>> 
>>> If the parent dies, the process becomes the child of launchd. For a quick
>>> fix I checked for the parent PID greater than 1.
>>> 
>>> A better fix, the parent process passed its PID to the child process as an
>>> argument. In the child process, if getppid() does not return the PID from
>>> the parent process, exit.
>> 
>> Another problem is if the parent dies after the getppid(), and another
>> process starts with the same PID as the old parent, all before the
>> call to kevent(). In this scenario you'll now be waiting for an
>> unrelated process to die. This situation is likely impossible
>> currently with incrementing PIDs, but there's been mention of PID
>> randomization on darwin-dev:
>> 
>>http://lists.apple.com/archives/darwin-dev/2009/Oct/msg00056.html
>> 
>> I only mention this because I use this kevent method to detect a
>> parent's death, and have been looking for a better technique that
>> also doesn't require the parent's cooperation...
> 
> Call getppid, set up the kevent listener, then before you actually
> block in kevent, call getppid *again*. If the answer matches the first
> call, then you can go ahead and call kevent. If the answer doesn't
> match, you've hit the race condition you outline here, your parent is
> dead, and you can exit immediately. If the parent quits after the
> second getppid but before the call to kevent, you should still get the
> exit notification because you registered it before the parent quit.
> 
> Mike
___

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

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

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

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


Multi Window cocoa application

2010-04-04 Thread Bharadwaj Parthasarathy


Hi,

I am currently working on porting an existing open source windows  
application to mac OSX.

I am fairly new to cocoa programming.

The application involves opening a new window for a specifying the  
parameters of the simulation.

The second window has about 20 textboxes and cannot be a modal window.
I have the XIB files and I got the windows working together somehow,  
but needs a lot of fixing.


If there are multiple windows in an application, how do I pass values  
and messages between them?


Apple developer library does not have an example source code and many  
internet sources point to
/Developer/Examples/InterfaceBuilder/SimpleMultiWindow which is  
apparently not present in leopard.
If some one has this example, that would be great. Also, this example  
being removed hints that there is a new and better way to do it?


I would appreciate if someone can pass on resources or sample code on  
working with multiple windows in a cocoa application.
Just to clarify, this is not a document based application. You can  
reach me at barbi dot bruce at gmail


Thanks,
B
___

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

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

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

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


[iPhone]Is it possible for apps to use the file sharing directory?

2010-04-04 Thread Development
I have an app that I would like to be able to have use the file sharing 
directory so that it's data could be accessed via iTunes. I've not had any luck 
finding information on doing this... Is it even possible?


April.___

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

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

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

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


re: Finding managed objects by URI representation

2010-04-04 Thread Ben Trumbull
> I have some queries that used to look up objects based on an elementID 
> attribute, which used to be my unique identifier for objects, created when 
> the objects were inserted or loaded. I am now moving away from that and using 
> the standard managed object IDs and reference objects.
> 
> So I used to do things like for a drag and drop of objects, I would have 
> predicates like this (where the identifiers were the elementIDs of the 
> objects I was dragging):
> 
>NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K in %@", 
> @"elementID", identifiers];
> 
> I guess that I will now have to use a different way of referencing it, and 
> was thinking that I could create the identifiers as:
> 
>[[[theManagedObject objectID] URIRepresentation] absoluteString]
> 
> but if I was to do that, in order to search using a predicate, I would have 
> to create a read only attribute on my managed objects that would return that 
> value, right?

No, this is going the wrong way.  The objectID is the object's identity in the 
persistent store (e.g. primary key).  You don't need to store pieces of it 
somewhere else.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self == %@", 
myobjectid];
or
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self in %@", 
objectidarray];

> I'm sort of looking at possible alternatives like using the MOCs 
> persistentStoreCoordinator to get the managedObjectIDForURIRepresentation:, 
> and then the MOC objectWithID: method to get the actual object back, but 
> don't know if managedObjectIDForURIRepresentation: would handle the temporary 
> ID situation and potential switch to a permanent ID on save.
> 
> I see a few posts along these lines in the past, but I haven't specifically 
> seen anything that says whether any of the methods will cope with looking up 
> a temporary URI, if it has now been turned into a permanent one.


If you stash a temporary URIRepresentation from an unsaved newly inserted 
object externally, like in the pasteboard, then no these methods won't track 
the switch to a permanent ID.  Of course, passing around IDs to objects that 
don't exist in the persistent store yet is juggling fire.  Those objects only 
exist in the MOC in which they were inserted until save, so nobody else can 
actually use their IDs yet.

If you need a permanent ID immediately, you can call 
-obtainPermanentIDsForObjects:error: on the NSManagedObjectContext

- Ben



___

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

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

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

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


Re: Multi Window cocoa application

2010-04-04 Thread Sebastian Morsch

Hi Bharadwaj,

I can't point you to the resources/sample code, but maybe this helps  
you anyway: when following the MVC paradigm, windows must NOT  
communicate with each other directly. Instead, they are usually owned  
by window controllers (subclasses of NSWindowController you will have  
to write). These controllers may have methods and properties specific  
to the functionality represented by their windows. The controllers  
themselves are usually owned and managed by the Application Delegate  
which coordinates their interaction. This interaction can be  
implemented by various means (i. e. KVO or Notifications).


I think Apples "Cocoa Fundamentals Guide" goes into more detail  
regarding this.


If you simply need a parameter that is set in one window for  
functionality that is part of another window, you can bind that  
parameter to NSUserDefaultsController and fetch it from there when you  
need it. As a nice side-effect, that value is stored in the  
preferences file of your app.


Hope that helps a little!
Best,
Sebastian




Am 04.04.2010 um 01:22 schrieb Bharadwaj Parthasarathy >:




Hi,

I am currently working on porting an existing open source windows  
application to mac OSX.

I am fairly new to cocoa programming.

The application involves opening a new window for a specifying the  
parameters of the simulation.

The second window has about 20 textboxes and cannot be a modal window.
I have the XIB files and I got the windows working together somehow,  
but needs a lot of fixing.


If there are multiple windows in an application, how do I pass  
values and messages between them?


Apple developer library does not have an example source code and  
many internet sources point to
/Developer/Examples/InterfaceBuilder/SimpleMultiWindow which is  
apparently not present in leopard.
If some one has this example, that would be great. Also, this  
example being removed hints that there is a new and better way to do  
it?


I would appreciate if someone can pass on resources or sample code  
on working with multiple windows in a cocoa application.
Just to clarify, this is not a document based application. You can  
reach me at barbi dot bruce at gmail


Thanks,
B
___

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

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

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

This email sent to sebastianmor...@mac.com


___

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

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

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

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


Run Loop in Tool Idles for 60.0 seconds before exitting

2010-04-04 Thread Jerry Krinock
My app package includes a tool which can be invoked to do some of the work that 
the main app normally does, kind of like xcodebuild.  In the tool, I create and 
run a run loop with this code:

while (
![[AgentPerformer sharedPerformer] isDone]
&&
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
 beforeDate:[NSDate distantFuture]]) {
   NSLog(@"Did Run") ;
}
NSLog(@"Exitting run loop") ;

The work to be done involves about 3 dozen dependent NSOperations, so the "Done 
Run" logs about 3 dozen times in 10 seconds or so.  These operations are also 
logged.  The last operation sets the sharedPerformer's isDone to YES.  I expect 
the run loop to exit immediately, but upon testing *most* builds it sits idle 
for exactly 60 seconds before "Exitting run loop".  Sometimes, seemingly by 
throwing in extra NSLogs, it exits immediately as expected, but this behavior 
is not repeatable in any way that I can comprehend.

A Sample taken during the 60 seconds of idle time is shown below.

I cannot find any suspicious 60.0-second timeout in my code.  Has anyone ever 
seen the Cocoa runtime apply such a timeout?  What might be wrong with my 
design?

I was wondering if the run loop needed "one last kick", so I added a timer to 
the last operation.  (See code at bottom of post).  But that timer never fires, 
which tells me that the timer's thread is blocked, and this is probably the 
same thread which is waiting 60 seconds.  Who might be doing that?  Can't find 
any clues in Threading Programming Guide ▸ Run Loops.

Jerry Krinock


Sampling process 33013 for 3 seconds with 1 millisecond of run time between 
samples
Sampling completed, processing symbols...
Analysis of sampling BookMacster-Worker (pid 33013) every 1 millisecond
Call graph:
2747 Thread_498571   DispatchQueue_1: com.apple.main-thread  (serial)
  2747 start
2747 main
  2747 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
2747 CFRunLoopRunInMode
  2747 CFRunLoopRunSpecific
2747 __CFRunLoopRun
  2747 mach_msg
2747 mach_msg_trap
2747 Thread_498576   DispatchQueue_2: com.apple.libdispatch-manager  
(serial)
  2747 start_wqthread
2747 _pthread_wqthread
  2747 _dispatch_worker_thread2
2747 _dispatch_queue_invoke
  2747 _dispatch_mgr_invoke
2747 kevent

Total number in stack (recursive counted multiple, when >=5):

Sort by top of stack, same collapsed (when >= 5):
kevent  2747
mach_msg_trap   2747
Sample analysis of process 33013 written to file /dev/stdout


/* "One Last Kick" in the final operation ***/

- (void)byebye:(NSTimer*)timer {
NSLog(@"Bye Bye") ; // Never logs
}

/* Method invoked by the final NSOperation's "main" wrapper*/
- (void)terminateWork {
NSLog(@"-->> %s", __PRETTY_FUNCTION__) ;
[NSTimer scheduledTimerWithTimeInterval:5.0
 target:self
   selector:@selector(byebye:)
   userInfo:nil
repeats:NO] ;
[[AgentPerformer sharedPerformer] setIsDone:YES] ;
NSLog(@"<<-- %s", __PRETTY_FUNCTION__) ;
}


___

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

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

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

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


Re: [iPhone]Is it possible for apps to use the file sharing directory?

2010-04-04 Thread Jens Alfke
iPad apps can do this. But the 3.2 OS APIs are still under NDA. If you download 
the iPad SDK, you might be able to find documentation, but we can't talk about 
it here yet.

--Jens {via iPad}

On Apr 4, 2010, at 1:27 PM, Development  wrote:

>   I have an app that I would like to be able to have use the file sharing 
> directory so that it's data could be accessed via iTunes. I've not had any 
> luck finding information on doing this... Is it even possible?
> 
> 
> April.___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jens%40mooseyard.com
> 
> This email sent to j...@mooseyard.com
___

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

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

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

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


Re: Run Loop in Tool Idles for 60.0 seconds before exitting

2010-04-04 Thread Ken Thomases
On Apr 4, 2010, at 4:06 PM, Jerry Krinock wrote:

> while (
>![[AgentPerformer sharedPerformer] isDone]
>&&
>[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
> beforeDate:[NSDate distantFuture]]) {
>   NSLog(@"Did Run") ;
>}
> NSLog(@"Exitting run loop") ;
> 
> The work to be done involves about 3 dozen dependent NSOperations, so the 
> "Done Run" logs about 3 dozen times in 10 seconds or so.  These operations 
> are also logged.  The last operation sets the sharedPerformer's isDone to 
> YES.  I expect the run loop to exit immediately, but upon testing *most* 
> builds it sits idle for exactly 60 seconds before "Exitting run loop".  
> Sometimes, seemingly by throwing in extra NSLogs, it exits immediately as 
> expected, but this behavior is not repeatable in any way that I can 
> comprehend.

Have you read and understood the documentation for -[NSRunLoop 
runMode:beforeDate:]?

Since you specified an infinite timeout, that method blocks until an input 
source is signaled and handled.  As near as I can tell, you are not causing any 
input source to be signaled.  Frankly, it seems like pure luck that it's ever 
exiting.


If your NSOperations are queued on an operation queue that you allocated, then 
they will run on background threads, which may not involve the main thread or 
its run loop, at all.  Even if they are queued on the main operation queue 
(+[NSOperationQueue mainQueue]), it's not clear if that counts as a run loop 
input source.


> I was wondering if the run loop needed "one last kick", so I added a timer to 
> the last operation.  (See code at bottom of post).  But that timer never 
> fires, which tells me that the timer's thread is blocked, and this is 
> probably the same thread which is waiting 60 seconds.

If you schedule a timer from an operation that's running on a non-main queue, 
then that will happen on an arbitrary thread that you don't own and can't make 
any assumptions about.  The timer will be scheduled on that thread's run loop, 
which is bad.

First, there's no guarantee that the thread will run its run loop, ever.

Second, there's no guarantee that the thread will continue to exist after your 
-main method exits.  It was created automatically, it can be destroyed 
automatically, too.

Third, even if the timer were to fire, it would not be on the main thread's run 
loop.  Therefore, it would not be expected to affect the main thread's run loop.

Fourth, even if it were to fire on the main thread, the documentation makes it 
clear that timers don't cause -runMode:beforeDate: to return.


Since you're already using operations, why use the above 'while' loop, anyway?  
Why not use -[NSOperationQueue waitUntilAllOperationsAreFinished].  Or schedule 
a "sentinel" operation that depends on all of the other operations, either 
directly or indirectly, and then invoke -waitUntilFinished on it.

If you prefer, you can keep using your 'while' loop and schedule such a 
"sentinel" operation on the main queue on the theory that it will count as an 
input source.  While you're at it, that operation's isFinished property would 
replace the isDone flag.

If that still doesn't work, you can use -performSelector:withObject:afterDelay: 
(from the main thread) or 
-performSelectorOnMainThread:withObject:waitUntilDone: (from a background 
thread) to signal the completion.  I believe either of those is known to count 
as an input source for the purposes of terminating -runMode:beforeDate:.

Regards,
Ken

___

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

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

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

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


Re: Terminating subtasks reliably

2010-04-04 Thread Scott Ribe
> Why not have the parent call setsid() / setpgid() at the beginning?

IIRC, odd things happen if a GUI app is not in the Login Window's process
group...

-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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

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

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

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


Re: [iPhone]Is it possible for apps to use the file sharing directory?

2010-04-04 Thread Eli Bach

On Apr 4, 2010, at 3:44 PM, Jens Alfke wrote:

> iPad apps can do this. But the 3.2 OS APIs are still under NDA. If you 
> download the iPad SDK, you might be able to find documentation, but we can't 
> talk about it here yet.
> 
> --Jens {via iPad}

The 3.2 SDK is now under the 'regular' nda, as it's no longer beta/prerelease.  
It's a small 2.4 Gb download...

Eli

___

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

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

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

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


Re: [iPhone]Is it possible for apps to use the file sharing directory?

2010-04-04 Thread Kyle Sluder
On Sun, Apr 4, 2010 at 5:26 PM, Eli Bach  wrote:
> The 3.2 SDK is now under the 'regular' nda, as it's no longer 
> beta/prerelease.  It's a small 2.4 Gb download...

Historically, Scott has needed to give the go-ahead before discussion
of anything new is allowed on this list. This applies to desktop OS
releases as well as iPhone OS releases.

--Kyle Sluder
___

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

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

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

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


Re: How do I get a file reference w/o relying on the path?

2010-04-04 Thread Charles Srstka
On Apr 4, 2010, at 12:50 PM, Jens Alfke wrote:

> You're saying that if I have a FSRef to a file, then the file is moved, the 
> FSRef will still reference the moved file and not the location where it used 
> to be?
> 
> That's surprising to me, because FSRefs were created as a replacement for 
> FSSpecs, which do not have that property (they were a struct {volume ID, dir 
> ID, filename}.)
> 
> Anyway, note that a file inode ID is more fragile than an alias/bookmark, 
> because it won't survive the common practice of replacing an old copy of a 
> file with a new one ("safe save") unless the code doing the replace is 
> careful to propagate metadata to the new file. 
> 
> --Jens {via iPad}

This is the way FSRefs work. However, AliasRecords always contained both the 
path *and* the file ID. I believe it used the path first, and if it didn’t find 
a file there, then it fell back on the file ID. There were, of course, ways to 
alter this default behavior, such as the kResolveAliasTryFileIDFirst flag, 
which reversed the default resolution behavior, and the FSNewAliasMinimal() 
function, which left out one of the two ways of finding the file (I think it 
kept the file ID and left out the path, but I could be misremembering). Anyway, 
I’d be pretty surprised if the new bookmark feature didn’t also include this 
functionality.

By the way, it’s not the file inode ID that a FSRef points to, it’s the catalog 
node ID. The ID is actually a property of the catalog B-tree node rather than 
the file itself - if you have a file that has multiple hard links, each hard 
link will have the same inode but a different CNID.

Charles___

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

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

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

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


Re: Two text fields, one outlet?

2010-04-04 Thread Jenny M
Thanks everyone! Your answers helped, it's what I thought, I was just
overthinking things.

> You can certainly bind any number of UI objects to a single property of an 
> object.
>
> Specifying an IBOutlet is only necessary if you want to create a connection 
> and can only be connected to one thing at a time. Simply specify a property 
> and bind the NSTextFields to that.
>


This is the method I ended up going with. I had tried to use bindings
before by doing exactly that - setting up a property, synthesizing it,
and binding the value to the property - but I noticed I was setting
the value wrong. I was calling
   property = [NSNumber...]
rather than
   [self setProperty:[]]. <-- Finally, that worked!!


Jenny
___

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

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

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

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


How do I compare two NSDates using NSPredicate & Core Data

2010-04-04 Thread Michael A. Crawford
Thus far I've gotten away with using -predicateWithFormat and scalar values.  I 
now need to compare a couple of NSDate instances but am not sure how to code it 
up with NSPredicate.  Consider me a 'visual' learner.

-Michael
___

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

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

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

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


Proposal for category in plugin environment

2010-04-04 Thread JongAm Park
Hello,

I'm not not sure if it should be only implemented on language side in gcc or 
cocoa also need to handle it, but I posted a proposal to my blog about category 
under plugin environment. ( 
http://jongampark.wordpress.com/2010/04/04/proposal-for-category-in-plugin-environment/
 )

Are Apple people thinking about the same or similar mechanism?
If not, what do you think about my proposal. ( I don't mean that I will 
implement it, but... just suggesting.. )

Thank you.
JongAm Park


___

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

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

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

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


Re: [iPhone]Is it possible for apps to use the file sharing directory?

2010-04-04 Thread Development
Well, I finally found the answer. I was using a bad search phrase which is why 
it did not come up before. Turns out it's well documented.

On Apr 4, 2010, at 1:27 PM, Development wrote:

>   I have an app that I would like to be able to have use the file sharing 
> directory so that it's data could be accessed via iTunes. I've not had any 
> luck finding information on doing this... Is it even possible?
> 
> 
> April.___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/development%40fornextsoft.com
> 
> This email sent to developm...@fornextsoft.com

___

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

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

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

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


Re: Run Loop in Tool Idles for 60.0 seconds before exitting [Solved]

2010-04-04 Thread Jerry Krinock

On 2010 Apr 04, at 14:44, Ken Thomases wrote:

> Have you read and understood the documentation for -[NSRunLoop 
> runMode:beforeDate:]?

Read?  Yes.  Understood?  Well, probably I was misled by the way things "just 
almost worked".

> ... Frankly, it seems like pure luck that it's ever exiting.

> If you schedule a timer from an operation that's running on a non-main queue, 
> then that will happen on an arbitrary thread that you don't own and can't 
> make any assumptions about.  The timer will be scheduled on that thread's run 
> loop, which is bad.

Indeed, it was on a secondary thread.  Oh, so many things to think about when 
you're multithreading!

> First, ... 
> Second, ...
> Third, ...
> Fourth, ...
> 
> Since you're already using operations, why use the above 'while' loop, 
> anyway?  Why not use -[NSOperationQueue waitUntilAllOperationsAreFinished].  
> Or schedule a "sentinel" operation that depends on all of the other 
> operations, either directly or indirectly, and then invoke -waitUntilFinished 
> on it.

Alas, many of my operations call back to perform Core Data operations on the 
main thread.  (Syncing multiple managed object contexts never looked like much 
fun to me.)  The disadvantage is that this nice, clean approach you suggest 
results in deadlock.

> If you prefer, you can keep using your 'while' loop and schedule such a 
> "sentinel" operation on the main queue on the theory that it will count as an 
> input source.  While you're at it, that operation's isFinished property would 
> replace the isDone flag.

I believe that my -terminateWork is part of such a sentinel operation already, 
although I made my own "main queue", since this app works in 10.5 where 
+[NSOperationQueue mainQueue] is not yet available.  If you meant to make this 
operation run on the main thread, I don't know how to do that since 
-isConcurrent is ignored in Mac OS 10.6.

> If that still doesn't work, you can use 
> -performSelector:withObject:afterDelay: (from the main thread) or 
> -performSelectorOnMainThread:withObject:waitUntilDone: (from a background 
> thread) to signal the completion.  I believe either of those is known to 
> count as an input source for the purposes of terminating -runMode:beforeDate:.

In the Threading Programming Guide ▸ Run Loops ▸ Input Sources, there is a 
subsection titled "Cocoa Perform Selector Sources".  This seems to imply that a 
-performSelector::: method is indeed a run loop source, with all the 
incorporated privileges and responsibilities.  Although they don't explicitly 
state the effect upon -runMode:beforeDate:, I see that "The run loop processes 
all queued perform selector calls each time through the loop".  And, it seems 
to work ...

- (void)tickleRunLoop {
// No op
}

/* This method is called from the -main of the final NSOperation
 in an Agent task.  Like all NSOperations, it's running on a
 secondary thread. */
- (void)terminateWork {
// Set the exit condition for Worker
[[AgentPerformer sharedPerformer] setIsDone:YES] ;

// Now install an input source on the main run loop, so that
// in Worker-main.m, in main(), -runLoop:beforeDate: will
// unblock, the above exit condition will be tested, found
// to be true, and cause the loop to break so that Worker
// can continue along to exit.
[self performSelectorOnMainThread:@selector(tickleRunLoop)
   withObject:nil
waitUntilDone:YES] ;
}

This is actually a simple modification of the code at the end of my original 
post, except that now we remember to call back to the main thread -- Thank you, 
Ken!

I'm happy with this, although I suspect someone might suggest something less 
kludgey.

I still wonder why my original code exitted after a 60-second timeout, though.  
It's as though Apple saw me coming, and so Cocoa secretly does some kind of 
"thread garbage collection" when "multithreading dummy" programming errors are 
detected :)

___

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

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

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

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


Re: Run Loop in Tool Idles for 60.0 seconds before exitting [Solved]

2010-04-04 Thread Turd Burp
>This seems to imply that a -performSelector::: method is indeed a
> run loop source, with all the incorporated privileges and
> responsibilities.

This was how it appeared to me as well.
___

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

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

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

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