Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-30 Thread Oleg Krupnov
Hi Ken,

I've tried sockets instead of mach ports, but the result is almost the
same. At first, the request via the new connection was handled in the
new server thread, which rejoiced me, but then the second request to
the same connection from the same client thread was handled in the
main server thread again. The threads seem to be picked arbitrary as
well as in the case of mach ports :(

I have a strange idea, but if it would be possible, it could solve the
problem. Can I, hem, just launch a new server thread and create
another connection point, and register it under a different name, and
vend another root object through it (different instance of different
class) and then launch a run loop in that thread?

Here is the code:

- (void)threadMain
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSConnection* connectionPoint = [[NSConnection new] autorelease];

NSProtocolChecker* vendedThreadObject = [NSProtocolChecker
protocolCheckerWithTarget:self
protocol:@protocol(ThreadObjectProtocol)];

[connectionPoint setRootObject:vendedThreadObject];

if ([connectionPoint registerName:@"anotherName02"])
{   
while (!isTerminated)
{
[[NSRunLoop currentRunLoop] run];
}
}

[pool release];
}

However, the line "registerName" returns NO. What is the problem?

Thanks,

Oleg.


On Thu, Sep 30, 2010 at 7:45 PM, Ken Thomases  wrote:
> On Sep 30, 2010, at 11:17 AM, Oleg Krupnov wrote:
>
>> NSSocketPort* port = [[NSSocketPort alloc] initWithTCPPort:1234];
>> NSConnection* connectionPoint = [[NSConnection alloc]
>> initWithReceivePort:port sendPort:nil];
>> if ([connectionPoint registerName:CONNECTION_NAME
>> withNameServer:[NSSocketPortNameServer sharedInstance]])
>>
>> This time it registered, but on client side I get nil when asking for proxy:
>>
>> proxy = [NSConnection
>> rootProxyForConnectionWithRegisteredName:CONNECTION_NAME host:nil];
>>
>> I get nil. I tried "localhost" and "128.0.0.1" for host, but still no luck.
>
> Try +rootProxyForConnectionWithRegisteredName:host:usingNameServer: and 
> specify the socket port name server (similar to what you did, above).
>
>> There must be something simple I've overlooked? The docs do not tell
>> how to set up sockets easily, only Mach ports come by default...
>
> There are multiple approaches.  You can use the initializers of NSSocketPort 
> to create socket ports.  You can use one of the -portForName:... methods of 
> NSSocketPortNameServer to obtain a socket port for communicating with the 
> named service.
>
> Once you have the socket ports, you can create NSConnection objects from 
> them, as you did above.
>
> 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


Flipped NSView + scaled NSAffineTransform = confusion

2010-09-30 Thread Ken Tozier
Hi

I have a custom view, which contains a number of subviews, where it is much 
more intuitive to the user if items appear from the upper left corner than the 
bottom left corner. Normally, I would just flip the view and the placement of 
subviews is what I expect. When I apply a scaled affine transform to the 
subviews however, poof. The subviews vanish and no amount of resizing the 
window makes them reappear. 

Here's a simple example of what I'm doing

Containing view:

- (BOOL) isFlipped { return YES; }

- (id) initWithFrame:(NSRect) inFrame
{
self = [super initWithFrame: inFrame];
if (self)
{
NSRect  *subFrame   = 
NSMakeRect(10, 10, 500, 1000);
MySubView   *subview= 
[[MySubView alloc] initWithFrame: subFrame];
NSAffineTransform   *subTransform   = [[NSAffineTransform 
transform] retain];
float   vertPadding 
= 20;

[transform scaleBy: (inFrame.size.height - vertPadding) / 
subFrame.size.height];

[self addSubview: subview];
}

return self;
}

- (void) drawRect:(NSRect) inDirtyRect
{
[[NSColor blackColor] set];
NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}

- (NSAffineTransform *) subTransform
{
return subTransform;
}

MySubView

- (void) drawRect:(NSRect) inDirtyRect
{
[[[self superview] subTransform] concat];
[[NSColor greenColor] set];
NSRectFillUsingOperation(inDirtyRect, NSCompositeSourceOver);
}

What do I need to do to scale a subview using an NSAffineTransform and have 
it's upper left stay put? Or at least not move it off into the aether?

Thanks for any 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 arch...@mail-archive.com


Continuously running daemon process CFConstantStringRefs build up over time

2010-09-30 Thread Kevin Ross
Greetings Cocoa Developers,

I have run into a snag while writing my background daemon and I was hoping that 
there might be some people on this list that could point me in the right 
direction or suggest a workaround.  I am writing a background daemon to handle 
to field incoming software update requests for several client applications 
running in the wild.  My implementation is working great, but I seem to have a 
slow buildup of CFConstantStringRefs that are being created by internal 
Foundation calls and CFSTR macros and are  never released.  This slowly builds 
up over time and there doesn't appear to be any way to release these strings.  

I have run the daemon through the clang static analyzer and the Instruments 
leaks tool but none are reporting any leaks.  I have even downloaded a fresh 
copy of valgrind from svn and it too is not finding anything.  The instruments 
allocation monitor is reporting that there are CFConstantStringRefs that 
Foundation is allocating from internal methods and CFSTR macros that I am using 
in some functions.  I'm happy to provide more details of the actual call-stacks 
and code if necessary.

Does anyone have any idea about what could be causing this or what I can do 
about it?  While this isn't a big deal in the short term, I have seen it build 
up fairly quickly during stress testing.  I have even tried setting hard and 
soft resource limits using the launchd plist by setting the MemoryLock and 
ResidentSetSize but these are not having the expected effect of limiting the 
memory buildup.

A work around I was contemplating was to have an idle timer that kills the app 
after a time if there are no active or incoming connections so it will then be 
restarted by launchd and reset the memory.  This seems like a hack to get 
around the problem and I think I must be overlooking something.

Any help would be greatly appreciated as I've tried googling and re-reading the 
background daemon tech notes and have turned up nothing.  Thank you for your 
help.

Sincerely,

Kevin Ross

___

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

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


Hitting Layers

2010-09-30 Thread Curious Yogurt
I'm working on a game using core animation that depends on hitting CA
layers.  This works great as long as the user is not in fullscreen mode;
when in fullscreen, hits are still registered, but they do not correspond to
the objects.  Any ideas what might be going wrong?  Here is my code for
detecting the hit:

-(GameObjectLayer *)chipLayerHit:(NSPoint)mouseloc

{

NSPoint translated = [[gameController window] convertScreenToBase:mouseloc];

CGPoint point = NSPointToCGPoint(translated);

 CALayer *rootLayer = [[[gameController window] contentView] layer];

id hitLayer = [rootLayer hitTest:point];

if (![hitLayer isKindOfClass:[GameObjectLayer class]]) return nil;

else return hitLayer;

}


GameObjectLayer is, ultimately, a CALayer.  I'm looking for just hits on
GameObjectLayer objects, not on other sorts of objects that are floating
around.  I'm wondering whether I need to modify the first line of the method
(NSPoint translated = [[gameController window] convertScreenToBase:mouseloc];)
when in fullscreen mode?


Thanks,


Ravi Coyne
___

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

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

2010-09-30 Thread Laurent Daudelin
[NSBundle mainBundle] will return the path of the application bundle, not 
~/Library/Application Support/[App Name]. You need to use 
"NSSearchPathForDirectoriesInDomains" with the appropriate masks to search in 
the user's Library.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

On Sep 30, 2010, at 16:00, Ariel Feinerman wrote:

> Are you sure in the using of 'library/application support'? There is
> of the matter is that one is designed for the app data not for the
> user data.
> Maybe you should save such files in a directory relative to the bundle
> or in the bundle itself (not good idea). In this case you can launch
> your app from your drive.
> 
> If your app is in /Users/user/yourapp, your files in
> /Users/user/yourapp/Application Support, it looks:
> 
> NSString *appSupport = NSBundle mainBundle] bundlePath]
> stringByDeletingLastPathComponent] stringByAppendingPathComponent:
> @"Appication Support"];
> 
> 
> 
> 2010/9/29 Amy Heavey 
>> 
>> I'm writing an app for personal use, using core data.
>> 
>> At the moment it's set up to save the data file in the library/application 
>> support/myapp folder on the machine. I also want to store a growing number 
>> of images to use with the app, so they are set to store in this folder as 
>> well.
>> 
>> However, I'd like to be able to use this app on my laptop as well as the 
>> desktop. I don't really fancy managaing some kind of sync, and thought the 
>> best solution would be to store the app and all the data/images on a thumb 
>> drive. There's only me using the app, and having to walk and get the drive 
>> from the office isn't a huge headache, and I can easily take it with me if I 
>> want to work elsewhere (not on my home network).
>> 
>> How would I set the data store to a mobile drive? can anyone point me at a 
>> tutorial? Is it as simple as naming the thumbdrive and referring to it by 
>> name in the code? The Code I've currently got is the auto/default type set 
>> up, following the Hillegass book as well,
>> 
>> Thanks,
>> Amy

___

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

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


Is there any other way of enumerating windows and getting their positions except Accessibility API?

2010-09-30 Thread eveningnick eveningnick
Hello
Is there a way in MacOS X to determine the position of the control on
a screen, if the application doesnt provide Accessibility object for
that control?

What am I trying to do - is to get the position of the topleft corner
of Mac:Word Page (it seems to be a View or something like that).
Word does provide Accessibility API, but only as deep as the window
which is called Document Pane that contains pages (and this document
pane may contain several pages, or the page can be scrolled while that
Document Pane doesnt change its location).

I am wondering, if this page can be interpreted as a control and then,
maybe using some Windowing APIs i could retrieve that position.
I am sorry about the terminology, before i've been coding only for
Windows, thus i hardly imagine how windowing system works in MacOS.

Thanks for any 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 arch...@mail-archive.com


"spawn_via_launchd() failed, errno=5" in Mac OS X 10.6.x

2010-09-30 Thread Heizer, Charles
Hello,
I'm trying to launch my Reboot application for the current user but I keep 
seeing this message in the system.log. This used to work just fine under Mac OS 
X 10.5.x.

Error Message:
9/30/10 5:50:01 PM  /Library/mp/Client/oraw[6379]   spawn_via_launchd() 
failed, errno=5 label=[0x0-0x18c18c].gov.llnl.MPReboot 
path=/Library/mp/Client/MPReboot.app/Contents/MacOS/MPReboot flags=1

Does anyone know how to resolve this, this is a big part of my app.

Thanks,
Charles

--
Charles Heizer
Systems Management Solutions Group
Lawrence Livermore National Laboratory
P: 925-422-0197 



___

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

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


NSCollectionView file promise drag & drop and selection

2010-09-30 Thread Nick Zitzmann
I searched for answers for these two questions and did not find anything 
pertinent:

1. I noticed that, on Snow Leopard, when the user clicks on a collection view 
item, the item is selected, but it doesn't do this on Leopard. Instead, on 
Leopard, the only way to select an item is to click and drag to select items. I 
can confirm it's not just my application by using the SourceView sample under 
Leopard. Normally I would work around this by overriding -mouseDown: and using 
-frameForItemAtIndex: to figure out what the user clicked on, but that method 
is only present in Snow Leopard. So has anyone figured out how to get 
NSCollectionView's selection behavior on Snow Leopard to work on Leopard as 
well?

2. I'm also wondering if anyone has been successful in doing file promise drags 
with NSCollectionView in Snow Leopard, and if so, then what did you have to do 
to get it to work? I'm doing this:

- (BOOL)collectionView:(NSCollectionView *)collectionView 
writeItemsAtIndexes:(NSIndexSet *)indexes toPasteboard:(NSPasteboard *)pboard
{
[pboard addTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] 
owner:self];
[pboard setPropertyList:[NSArray arrayWithObjects:@"rtf", @"rtfd", nil] 
forType:NSFilesPromisePboardType];
return YES;
}

If I look at the pasteboard in Pasteboard Inspector, I can see the file promise 
pasteboard types being written to the pasteboard. However, the Finder will not 
accept the drag. If I do the exact same thing in a table view 
writeItemsAtIndexes:... method, then it works as expected. If I inspect its 
pasteboard in Pasteboard Inspector, then it turns out to be identical to the 
collection view's pasteboard.

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 arch...@mail-archive.com


Re: portable app

2010-09-30 Thread Ariel Feinerman
Are you sure in the using of 'library/application support'? There is
of the matter is that one is designed for the app data not for the
user data.
Maybe you should save such files in a directory relative to the bundle
or in the bundle itself (not good idea). In this case you can launch
your app from your drive.

If your app is in /Users/user/yourapp, your files in
/Users/user/yourapp/Application Support, it looks:

NSString *appSupport = NSBundle mainBundle] bundlePath]
stringByDeletingLastPathComponent] stringByAppendingPathComponent:
@"Appication Support"];



2010/9/29 Amy Heavey 
>
> I'm writing an app for personal use, using core data.
>
> At the moment it's set up to save the data file in the library/application 
> support/myapp folder on the machine. I also want to store a growing number of 
> images to use with the app, so they are set to store in this folder as well.
>
> However, I'd like to be able to use this app on my laptop as well as the 
> desktop. I don't really fancy managaing some kind of sync, and thought the 
> best solution would be to store the app and all the data/images on a thumb 
> drive. There's only me using the app, and having to walk and get the drive 
> from the office isn't a huge headache, and I can easily take it with me if I 
> want to work elsewhere (not on my home network).
>
> How would I set the data store to a mobile drive? can anyone point me at a 
> tutorial? Is it as simple as naming the thumbdrive and referring to it by 
> name in the code? The Code I've currently got is the auto/default type set 
> up, following the Hillegass book as well,
>
> Thanks,
> Amy
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/arielfapple%40gmail.com
>
> This email sent to arielfap...@gmail.com



--
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: Changing classes

2010-09-30 Thread Kyle Sluder
On Thu, Sep 30, 2010 at 2:45 PM, jonat...@mugginsoft.com
 wrote:
> Trying to dynamically match a stepwise revealed information structure to a 
> particular class in a hierarchy sounds fragile.
> If an individual hardware item property doesn't match the class hierarchies 
> expectations then you have to subclass.

This sounds like a good candidate for a descriptor-based approach.
NSFontDescriptor is a good example: you fill it with properties and
then ask the font manager for a font matching that descriptor. In your
case, you'd create a HardwareDescriptor object, fill it with
information you receive over the network, and then ask some factory
method to return you an object of the appropriate class for that
descriptor.

Of course, you might not really need separate classes for each kind of
hardware object you have. You might get along fine with a single
generic HardwareObject class, with a dictionary of attributes, as
Jonathan describes.

--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: Changing classes

2010-09-30 Thread jonat...@mugginsoft.com

On 30 Sep 2010, at 20:35, Allen Ingling wrote:

> On Thu, Sep 30, 2010 at 2:28 PM, Remco Poelstra  wrote:
> 
>> Hi,
>> 
>> 
> Maybe a class cluster would be useful here?
> 
Clustering might be a solution but it's a bit of a heavyweight pattern.

Trying to dynamically match a stepwise revealed information structure to a 
particular class in a hierarchy sounds fragile.
If an individual hardware item property doesn't match the class hierarchies 
expectations then you have to subclass.

If a specific class is not necessary for each hardware item then it might be 
possible to think in terms of a single
or small number of generic classes. 
The specificity of these base classes can be extended by the use of associative 
storage property (an NSDictionary instance).
ie: dump all the hardware properties into the dictionary then query it as and 
when required.

This would give a lot of type flexibility without excessive subclassing.

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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: Exceptions to the "don't use -[NSManagedObject dealloc]" rule?

2010-09-30 Thread Jonathan del Strother
Do retained NSManagedObjects never fault, then?

On 30 September 2010 16:18, Dave DeLong  wrote:
> I'd probably set the managed object as the delegate of your URL connection.  
> NSURLConnection retains its delegate, and NSURLConnection is itself retained 
> by the run loop, so you don't have to worry about the managed object 
> disappearing from underneath you.  Then you can simply clean up the 
> connection in the connection:didFailWithError: or connectionDidFinish: 
> delegate methods.
>
> Dave
>
> On Sep 30, 2010, at 7:41 AM, Jonathan del Strother wrote:
>
>> if my model refaults while a connection is in progress,
>> the connection ought to carry on uploading.  After the connection has
>> uploading, it doesn't actually need the model's attributes, so won't
>> trigger a new fetch.  So where am I supposed to release the
>> connection?
>
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Should I use NSDocument, NSUserDefaults or something else

2010-09-30 Thread Quincey Morris
On Sep 30, 2010, at 04:42, Jonny Taylor wrote:

> This made me think that an NSDocument might be a more appropriate solution 
> (different document for each experiment, storing a hierarchical dictionary of 
> key/value pairs but implementing my own handling of defaults for missing 
> keys, etc). However this class is understandably a very complex class and I'm 
> finding it hard to drill down to the details of what I would need to do in 
> order to implement this pretty basic functionality - particularly since in 
> some ways it would be a non-standard use of the class, in that the "document" 
> was not associated with one single window, etc.

You have some design work to do before you can choose an implementation. The 
issue is not so much whether to use NSDocument or not, but rather what 
functionality and user experience you want your application to have.

There are probably 3 basic approaches here. The boundaries between the 
different approaches are not clear cut, but it might help you to think in these 
terms.

1. Settings. You'd remember the current hardware settings for your devices, and 
restore them whenever starting the application. There's absolutely no reason 
why you couldn't use NSUserDefaults for this. It *is* inherently designed for 
"hierarchical data storage", because you can put dictionaries into user 
defaults, and dictionaries are nothing if not hierarchical.

2. Configurations. You'd have all of #1, plus the ability to swap named sets of 
settings in and out of the current settings. You'd need to add an interface to 
manage the settings (name, activate, delete, etc). This could also live in user 
defaults. Alternatively, your settings could be in a file (or set of files) in 
the Application Support folder. The difference is that the Preferences folder 
is not really intended as something that users should go into, but Application 
Support can be. So, if you wanted users to be able to move configurations from 
one Mac to another, files in Application Support may be a slightly better 
choice.

3. Documents. This is similar to #3, except that the document files are placed 
wherever the user chooses. That makes it easy for the user to "own" the files, 
without having to hunt for them if it's necessary to move them to a different 
Mac, or to organize them into subfolders, or to back them up. The consequence 
of this choice is that the Mac OS document metaphor applies -- users will need 
to save documents explicitly, unlike #2 where the settings get "saved" 
automatically.

Depending on your user requirements, the document metaphor may or may not be 
appropriate. If not, but you still want to ease the transfer of settings 
between Macs, you can use something like:

3a. Configurations with export. You'd add to #2 the ability to export settings 
files (which could be a completely separate format, possibly even text files), 
and the ability to import settings files.

HTH


___

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

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


Crash in NSBinder

2010-09-30 Thread Cate Tony
I just received two crash reports from a beta tester. Here's the common 
back-trace:

Thread 0 Crashed:
0   libobjc.A.dylib 0x937de688 objc_msgSend + 24
1   com.apple.AppKit0x9625a7b9 -[_NSBindingInfo dealloc] + 
128
2   com.apple.CoreFoundation0x91f4e38a CFRelease + 90
3   com.apple.CoreFoundation0x91edd3cd __CFArrayReleaseValues + 221
4   com.apple.CoreFoundation0x91f4e538 _CFRelease + 216
5   com.apple.AppKit0x96216025 -[NSBinder _dealloc] + 63
6   com.apple.AppKit0x96215fbe -[NSBinder dealloc] + 83
7   com.apple.Foundation0x9799244f NSPopAutoreleasePool + 431
8   com.apple.AppKit0x96048026 -[NSApplication run] + 930
9   com.apple.AppKit0x960151d8 NSApplicationMain + 574
10  com.3caam.A Cook's Books0x21f2 main + 24
11  com.3caam.A Cook's Books0x21ae start + 54

I don't use bindings. Perhaps in the future, but bindings are still magic to 
me. 

In one case, user was quitting the program. In the second case, she had just 
finished printing. 

I don't have a clue how to recreate this, let alone debug it. Has anyone seen 
this or have an idea what could be going on?

Tony
3 Cats And A Mouse
http://www.3caam.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: Changing classes

2010-09-30 Thread Quincey Morris
On Sep 30, 2010, at 12:28, Remco Poelstra wrote:

> I've a class that represents a general piece of hardware. Subclasses of that 
> class represent more specific versions of that hardware. When I scan the 
> network for hardware, I first only know some basic properties of the hardware 
> and only after some more queries I'll know all details. I thought it would be 
> a good thing to instantiate from the base class when I detect the hardware 
> and then change the class to a more specific class as I find out more about 
> the hardware.
> But how do I change a class? I know about the ISA pointer, but changing it 
> doesn't allocate any additional variables.
> What would be a nice solution to this problem?

It's not at all obvious that having your class(es) "represent" your hardware is 
the right way to approach this.

What are you actually trying to achieve? If the various kinds of hardware are 
differentiated by their "properties", then a single class encapsulating the 
possible properties (including a specification of which properties are actually 
present for each device) may be all that you need.

You would only use a class hierarchy if the class has significant shared 
*behavior*, plus behavior that is specific to each device type. Note that I'm 
talking about class behavior, not device behavior. The device behavior isn't 
relevant to the class behavior, unless the class is a software simulation of 
the device.


___

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

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

2010-09-30 Thread Keary Suska
On Sep 30, 2010, at 1:28 PM, Remco Poelstra wrote:

> Hi,
> 
> I've a class that represents a general piece of hardware. Subclasses of that 
> class represent more specific versions of that hardware. When I scan the 
> network for hardware, I first only know some basic properties of the hardware 
> and only after some more queries I'll know all details. I thought it would be 
> a good thing to instantiate from the base class when I detect the hardware 
> and then change the class to a more specific class as I find out more about 
> the hardware.
> But how do I change a class? I know about the ISA pointer, but changing it 
> doesn't allocate any additional variables.
> What would be a nice solution to this problem?

Why not just allocate a new object to replace the existing one? E.g.:

id hardware = [[HardWare alloc] init];
[someDictionary setObject:hardware forKey:@"newHardware"];
[hardware release]; // owned only by dict
...
// now you know the specific hw properties
USBHardware *usbHardWare = [[USBHardware alloc] init];
[someDictionary setObject: usbHardWare forKey:@"newHardware"];
[usbHardWare release];

HTH,

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

___

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

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

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

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


Re: Changing classes

2010-09-30 Thread Allen Ingling
On Thu, Sep 30, 2010 at 2:28 PM, Remco Poelstra  wrote:

> Hi,
>
> I've a class that represents a general piece of hardware. Subclasses of
> that class represent more specific versions of that hardware. When I scan
> the network for hardware, I first only know some basic properties of the
> hardware and only after some more queries I'll know all details. I thought
> it would be a good thing to instantiate from the base class when I detect
> the hardware and then change the class to a more specific class as I find
> out more about the hardware.
> But how do I change a class? I know about the ISA pointer, but changing it
> doesn't allocate any additional variables.
> What would be a nice solution to this problem?
>
>
Maybe a class cluster would be useful 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 arch...@mail-archive.com


Re: Should I use NSDocument, NSUserDefaults or something else

2010-09-30 Thread Mark Munz
I think you can use NSUserDefaults just fine.

For the exposure example, you might do something like register a
default value for "exposure" category.

First check for the camera specific key ("QI1438.exposure"), if result
is nil, grab the general category value.

You could wrap that in a single method that took a category &
cameraID. It could build the camera specific key, check it, and if
nil, return the category value.

Mark

On Thu, Sep 30, 2010 at 4:42 AM, Jonny Taylor  wrote:
> Thankyou for peoples patience with my recent very basic conceptual cocoa 
> questions. I have another where I am trying to understand the best way of 
> handling some persistent data storage.
>
> My app is a workstation for a type of microscope, which from the point of 
> view of the software consists of several different video cameras and some 
> other devices controlled over USB. Each camera has associated settings (e.g. 
> exposure) that I want to persist between app launches. I am not sure what the 
> best way is of storing this information. There are multiple cameras involved, 
> with each camera having quite a distinct role, so I would like to tie the 
> settings to individual camera serial numbers.
>
> I had a look into NSUserDefaults but that doesn't sound quite ideal. As far 
> as I can see (and I may be missing something) it is not inherently designed 
> for hierarchical data storage. If I wanted to store, say, QI1438.exposure and 
> PS1451.exposure as separate (flat) keys, then I don't think there would be a 
> way of specifying a default value for the generalized key "exposure" in 
> registerDefaults (regardless of the camera serial number). It could also be 
> argued that these settings are not really "user preferences", particularly 
> since one could imagine having a different bank of settings for different 
> experiments.
>
> This made me think that an NSDocument might be a more appropriate solution 
> (different document for each experiment, storing a hierarchical dictionary of 
> key/value pairs but implementing my own handling of defaults for missing 
> keys, etc). However this class is understandably a very complex class and I'm 
> finding it hard to drill down to the details of what I would need to do in 
> order to implement this pretty basic functionality - particularly since in 
> some ways it would be a non-standard use of the class, in that the "document" 
> was not associated with one single window, etc. Can anybody point me towards 
> some example code that uses an NSDocument for this sort of application?
>
> Any advice people have on which of these solutions (or indeed a third one...) 
> I should be using would be very welcome.
>
> Cheers
> Jonny___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/unmarked%40gmail.com
>
> This email sent to unmar...@gmail.com
>



-- 
Mark Munz
unmarked software
http://www.unmarked.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


Changing classes

2010-09-30 Thread Remco Poelstra
Hi,

I've a class that represents a general piece of hardware. Subclasses of that 
class represent more specific versions of that hardware. When I scan the 
network for hardware, I first only know some basic properties of the hardware 
and only after some more queries I'll know all details. I thought it would be a 
good thing to instantiate from the base class when I detect the hardware and 
then change the class to a more specific class as I find out more about the 
hardware.
But how do I change a class? I know about the ISA pointer, but changing it 
doesn't allocate any additional variables.
What would be a nice solution to this problem?
 
Kind regards,

Remco Poelstra

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Should I use NSDocument, NSUserDefaults or something else

2010-09-30 Thread Shawn Bakhtiar

Have you looked at the sample code for  NSUserDefaults ?

I think this IS the place you want to put your info, even though you may not 
have realized it yet ;)

You can serialize any data that can take advantage of NSCoding? ie NSData, and 
save that as a key value pair. 

Also, you should first look at the defaults command, to see how well some 
application have been able to serialize there configurations. 

just type "defaults read" and you will see all the domains, application, etc... 
and how some of the configuration information is saved. Notice, how window 
coordinates, colors, etc... are saved.

I don't see why the serial number of the project/camera/etc.. could not be 
hashed into the key, so you can retrieve specific values; number of options 
could not be encoded in to say XML, that is than saved/loaded via the NSString 
and parsed using and XML interpreter for those specific values.

Hope this gives you some ideas,





> From: j.m.tay...@durham.ac.uk
> Date: Thu, 30 Sep 2010 12:42:04 +0100
> To: cocoa-dev@lists.apple.com
> Subject: Should I use NSDocument, NSUserDefaults or something else
> 
> Thankyou for peoples patience with my recent very basic conceptual cocoa 
> questions. I have another where I am trying to understand the best way of 
> handling some persistent data storage.
> 
> My app is a workstation for a type of microscope, which from the point of 
> view of the software consists of several different video cameras and some 
> other devices controlled over USB. Each camera has associated settings (e.g. 
> exposure) that I want to persist between app launches. I am not sure what the 
> best way is of storing this information. There are multiple cameras involved, 
> with each camera having quite a distinct role, so I would like to tie the 
> settings to individual camera serial numbers.
> 
> I had a look into NSUserDefaults but that doesn't sound quite ideal. As far 
> as I can see (and I may be missing something) it is not inherently designed 
> for hierarchical data storage. If I wanted to store, say, QI1438.exposure and 
> PS1451.exposure as separate (flat) keys, then I don't think there would be a 
> way of specifying a default value for the generalized key "exposure" in 
> registerDefaults (regardless of the camera serial number). It could also be 
> argued that these settings are not really "user preferences", particularly 
> since one could imagine having a different bank of settings for different 
> experiments.
> 
> This made me think that an NSDocument might be a more appropriate solution 
> (different document for each experiment, storing a hierarchical dictionary of 
> key/value pairs but implementing my own handling of defaults for missing 
> keys, etc). However this class is understandably a very complex class and I'm 
> finding it hard to drill down to the details of what I would need to do in 
> order to implement this pretty basic functionality - particularly since in 
> some ways it would be a non-standard use of the class, in that the "document" 
> was not associated with one single window, etc. Can anybody point me towards 
> some example code that uses an NSDocument for this sort of application?
> 
> Any advice people have on which of these solutions (or indeed a third one...) 
> I should be using would be very welcome.
> 
> Cheers
> Jonny___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/shashaness%40hotmail.com
> 
> This email sent to shashan...@hotmail.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: Acquiring an NSConnection otherwise than by registered name?

2010-09-30 Thread Ken Thomases
On Sep 30, 2010, at 11:17 AM, Oleg Krupnov wrote:

> NSSocketPort* port = [[NSSocketPort alloc] initWithTCPPort:1234];
> NSConnection* connectionPoint = [[NSConnection alloc]
> initWithReceivePort:port sendPort:nil];
> if ([connectionPoint registerName:CONNECTION_NAME
> withNameServer:[NSSocketPortNameServer sharedInstance]])
> 
> This time it registered, but on client side I get nil when asking for proxy:
> 
> proxy = [NSConnection
> rootProxyForConnectionWithRegisteredName:CONNECTION_NAME host:nil];
> 
> I get nil. I tried "localhost" and "128.0.0.1" for host, but still no luck.

Try +rootProxyForConnectionWithRegisteredName:host:usingNameServer: and specify 
the socket port name server (similar to what you did, above).

> There must be something simple I've overlooked? The docs do not tell
> how to set up sockets easily, only Mach ports come by default...

There are multiple approaches.  You can use the initializers of NSSocketPort to 
create socket ports.  You can use one of the -portForName:... methods of 
NSSocketPortNameServer to obtain a socket port for communicating with the named 
service.

Once you have the socket ports, you can create NSConnection objects from them, 
as you did above.

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: NSOperation -dealloc not called

2010-09-30 Thread Andreas Grosam
Setting the block to nil within the block itself actually did the trick. 

Thank you very much for the quick reply and the correct solution! :)

Andreas



On Sep 30, 2010, at 5:21 PM, Dave DeLong wrote:

> By referencing instance variables within the block, you're causing the block 
> to retain self, and since self retains (copy'd) the block, you've got a 
> retain cycle.
> 
> The easiest way to fix this is to break the retain cycle yourself.  Doing 
> "[self setCompletionBlock:nil];" at the end of the block should be adequate.
> 
> Dave
> 
> On Sep 30, 2010, at 9:17 AM, Andreas Grosam wrote:
> 
>> I've subclassed a NSOperation and declared a completion block in the 
>> initializer as follows:
>> 
>> - (id) initWithParameter:(id)parameter
>> {
>>  self = [super init];
>>  if (self != nil) {
>>  [self setCompletionBlock:^{
>>  NSLog(@"operation completed"); 
>>  [someIvar release], someIvar = nil;
>>  }];
>> 
>>  // ... initialize ivars
>>  }
>>  return self;
>> }
>> 
>> 
>> The problem is now, once a completion block has been defined and set as 
>> shown above, the NSOperation instance will never be dealloced. I noticed, 
>> when -setCompletionBlock: returns, the retain count of the NSOperation 
>> instance has been incremented by one. 
>> 
>> When there is no completion block set, the NSOperation object will be 
>> deallocated as expected some time later when the operation finished.
>> 
>> The -initWithParameter: method is invoked on the main thread.
>> 
>> The code of the completion block is trivial: It logs to the console and 
>> simply releases certain ivars. So, there should no autoreleased object 
>> (namely the operation object itself) left in some unknown execution context 
>> possibly without a pool and hence leaking.
>> 
>> 
>> As a side note: according the docs, the exact execution context for the 
>> completion block is undefined. So, I think this means, we should better use 
>> synchronization primitives when accessing ivars since the dealloc method 
>> might still executing, right?
>> 
>> 
>> This is running on iOS.
>> 
>> 
>> Any hints?
>> 
>> 
>> 
>> Thanks in advance
>> 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 arch...@mail-archive.com


Re: NSOperation -dealloc not called

2010-09-30 Thread Dave DeLong
By referencing instance variables within the block, you're causing the block to 
retain self, and since self retains (copy'd) the block, you've got a retain 
cycle.

The easiest way to fix this is to break the retain cycle yourself.  Doing 
"[self setCompletionBlock:nil];" at the end of the block should be adequate.

Dave

On Sep 30, 2010, at 9:17 AM, Andreas Grosam wrote:

> I've subclassed a NSOperation and declared a completion block in the 
> initializer as follows:
> 
> - (id) initWithParameter:(id)parameter
> {
>   self = [super init];
>   if (self != nil) {
>   [self setCompletionBlock:^{
>   NSLog(@"operation completed"); 
>   [someIvar release], someIvar = nil;
>   }];
> 
>   // ... initialize ivars
>   }
>   return self;
> }
> 
> 
> The problem is now, once a completion block has been defined and set as shown 
> above, the NSOperation instance will never be dealloced. I noticed, when 
> -setCompletionBlock: returns, the retain count of the NSOperation instance 
> has been incremented by one. 
> 
> When there is no completion block set, the NSOperation object will be 
> deallocated as expected some time later when the operation finished.
> 
> The -initWithParameter: method is invoked on the main thread.
> 
> The code of the completion block is trivial: It logs to the console and 
> simply releases certain ivars. So, there should no autoreleased object 
> (namely the operation object itself) left in some unknown execution context 
> possibly without a pool and hence leaking.
> 
> 
> As a side note: according the docs, the exact execution context for the 
> completion block is undefined. So, I think this means, we should better use 
> synchronization primitives when accessing ivars since the dealloc method 
> might still executing, right?
> 
> 
> This is running on iOS.
> 
> 
> Any hints?
> 
> 
> 
> Thanks in advance
> 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/davedelong%40me.com
> 
> This email sent to davedel...@me.com



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Exceptions to the "don't use -[NSManagedObject dealloc]" rule?

2010-09-30 Thread Dave DeLong
I'd probably set the managed object as the delegate of your URL connection.  
NSURLConnection retains its delegate, and NSURLConnection is itself retained by 
the run loop, so you don't have to worry about the managed object disappearing 
from underneath you.  Then you can simply clean up the connection in the 
connection:didFailWithError: or connectionDidFinish: delegate methods.

Dave

On Sep 30, 2010, at 7:41 AM, Jonathan del Strother wrote:

> if my model refaults while a connection is in progress,
> the connection ought to carry on uploading.  After the connection has
> uploading, it doesn't actually need the model's attributes, so won't
> trigger a new fetch.  So where am I supposed to release the
> connection?


smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

NSOperation -dealloc not called

2010-09-30 Thread Andreas Grosam
I've subclassed a NSOperation and declared a completion block in the 
initializer as follows:

- (id) initWithParameter:(id)parameter
{
   self = [super init];
   if (self != nil) {
   [self setCompletionBlock:^{
NSLog(@"operation completed"); 
   [someIvar release], someIvar = nil;
   }];

   // ... initialize ivars
   }
   return self;
}


The problem is now, once a completion block has been defined and set as shown 
above, the NSOperation instance will never be dealloced. I noticed, when 
-setCompletionBlock: returns, the retain count of the NSOperation instance has 
been incremented by one. 

When there is no completion block set, the NSOperation object will be 
deallocated as expected some time later when the operation finished.

The -initWithParameter: method is invoked on the main thread.

The code of the completion block is trivial: It logs to the console and simply 
releases certain ivars. So, there should no autoreleased object (namely the 
operation object itself) left in some unknown execution context possibly 
without a pool and hence leaking.


As a side note: according the docs, the exact execution context for the 
completion block is undefined. So, I think this means, we should better use 
synchronization primitives when accessing ivars since the dealloc method might 
still executing, right?


This is running on iOS.


Any hints?



Thanks in advance
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 arch...@mail-archive.com


Re: Acquiring an NSConnection otherwise than by registered name?

2010-09-30 Thread Ken Thomases
On Sep 30, 2010, at 6:21 AM, Oleg Krupnov wrote:

> I have checked the mailing archives and it seems that I am not alone
> with the problem that runInNewThread does not necessarily cause the
> request to be processed in the new thread. Some folks report that
> -removeRunLoop helped them, but my experiments show that
> 
> 1. -removeRunLoop doesn't seem to have any reproducible effect. At
> times it works, other times not.
> 
> 2. Even two subsequents calls via the same NSConnection (for which
> -removeRunLoop: and -runInNewThread was called) are not guaranteed to
> be handled in the same server thread. The server seems to freely pick
> any idle threads that from the ones that are currently running.
> 
> 3. What is curious, the #2 also happens if instead of -runInNewThread,
> I create a thread manually via [NSThread
> detachNewThreadSelector:toTarget:withObject:] and [NSConnection
> addRunLoop:]. This is very weird -- the server utilizes any threads
> you create!

> 2. Can it happen because all connections on the server share the same
> receiving port, which is added to the main run loop?

That's my guess.  I don't think it can pick _any_ thread, just any thread whose 
run loop has the shared receive port scheduled.  I'm surprised it works that 
way, that the receive port is shared, but it is documented.

I'd be curious to know what happens if you use socket ports instead of Mach 
ports.  It may be more efficient to use local-only Unix domain sockets instead 
of TCP/IP sockets, but either would be an interesting test.  Judging from how a 
socket design would work if done "manually" with the BSD/POSIX API, the receive 
port (socket) would not be shared between the connection point and an accepted 
connection.


> 4. Because server threads are assigned to connection requests so
> arbitrary, it seems dangerous to manually quit any thread. It may be
> being used by the server at the moment at its discretion. This means
> effectively, that there is no way to exit unneeded threads on server,
> only to launch new.

This is incorrect.  You should never terminate threads from the outside, you 
should only ever signal them to terminate themselves at a convenient point.  
Given that general guideline, this case is no different.  If the thread is able 
to check your signal, then it's not in the middle of doing anything else and 
can safely exit.


> 1. There is [NSConnection multipleThreadsEnabled] that may be causing
> this behavior. Unfortunately, there is no way to turn it off, there is
> only -enableMultipleThreads, and by default it is on starting from
> 10.5. I wished there were disableMultipleThreads to try!

I don't think this is the culprit.

I repeat my recommendation that you open a developer technical support incident 
with Apple.  You'll end up talking directly to the Apple engineers who 
implemented Distributed Objects and get their best advice for how to implement 
your design.

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: CGEventTap Not Receiving Events after some time

2010-09-30 Thread Erik Aigner
No, i figured out. It was some code in the callback that prevented me from 
identifying
a timeout message (wasn't easy recognizable on the first look).

Regards, Erik

On 30.09.2010, at 14:49, Bill Cheeseman wrote:

> 
> On Sep 30, 2010, at 6:28 AM, Erik Aigner wrote:
> 
>> I already check for these events, but they never occur. I think it might be 
>> that some other
>> app inserts itself again before my (active, not listen only) tap?
>> 
>> The event tap specifically taps system events for the media keys 
>> previous/playpause/next. I guess
>> the new iTunes version probably "reconquers" the event tap?
> 
> 
> I don't know how another application would block the event taps you have 
> enabled, but I suppose it might be possible.
> 
> One possibility for testing these kinds of problems is to use my free Event 
> Taps Testbench developer utility, at 
> .
> 
> --
> 
> Bill Cheeseman - b...@cheeseman.name
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/office%40chocomoko.com
> 
> This email sent to off...@chocomoko.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


Exceptions to the "don't use -[NSManagedObject dealloc]" rule?

2010-09-30 Thread Jonathan del Strother
Hi,

I'm in the process of converting an existing iPhone app to use Core
Data for its backend storage.  I've got a model that manages an upload
of its own attributes to a server - it has a retained NSURLConnection
instance variable.  Traditionally, I'd just release the connection in
the model's dealloc method.  Core Data seems to suggest that if I do
that, my connection will never get released, since dealloc won't get
called, and I should do everything in didTurnIntoFault method.

However, even if my model refaults while a connection is in progress,
the connection ought to carry on uploading.  After the connection has
uploading, it doesn't actually need the model's attributes, so won't
trigger a new fetch.  So where am I supposed to release the
connection?

Or is it that in practice, live Core Data objects that are being
retained by a controller never get refaulted?  There's only a brief
mention of refaulting (in the Core Data glossary), and not much
explanation of when it might happen.  I assumed that on the iPhone in
particular, a memory warning might trigger live objects into
transparently becoming fault objects, but I've not actually seen much
written evidence to back that up.

-Jonathan
___

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

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

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

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


Re: Should I use NSDocument, NSUserDefaults or something else

2010-09-30 Thread Angus Hardie

On 30 Sep 2010, at 12:42, Jonny Taylor wrote:

> My app is a workstation for a type of microscope, which from the point of 
> view of the software consists of several different video cameras and some 
> other devices controlled over USB. Each camera has associated settings (e.g. 
> exposure) that I want to persist between app launches. I am not sure what the 
> best way is of storing this information. There are multiple cameras involved, 
> with each camera having quite a distinct role, so I would like to tie the 
> settings to individual camera serial numbers.
> 
> I had a look into NSUserDefaults but that doesn't sound quite ideal. As far 
> as I can see (and I may be missing something) it is not inherently designed 
> for hierarchical data storage. If I wanted to store, say, QI1438.exposure and 
> PS1451.exposure as separate (flat) keys, then I don't think there would be a 
> way of specifying a default value for the generalized key "exposure" in 
> registerDefaults (regardless of the camera serial number). It could also be 
> argued that these settings are not really "user preferences", particularly 
> since one could imagine having a different bank of settings for different 
> experiments.
> 
> This made me think that an NSDocument might be a more appropriate solution 
> (different document for each experiment, storing a hierarchical dictionary of 
> key/value pairs but implementing my own handling of defaults for missing 
> keys, etc). However this class is understandably a very complex class and I'm 
> finding it hard to drill down to the details of what I would need to do in 
> order to implement this pretty basic functionality - particularly since in 
> some ways it would be a non-standard use of the class, in that the "document" 
> was not associated with one single window, etc. Can anybody point me towards 
> some example code that uses an NSDocument for this sort of application?


One point to note is that you can store an NSDictionary or an NSArray as a 
value in NSUserDefaults. 
That dictionary or array could store other dictionaries or arrays, which gives 
you a hierarchy.


Alternatively you could look at serializing the data to a plist file. If you 
have it in memory as an NSDictionary or NSArray then serializing to a plist is 
fairly simple
writeToURL:atomically: to write the dictionary to disk, 
dictionaryWithContentsOfURL: or initWithContentsOfURL: to read it in.
This is a bit more complicated than user defaults, but it keeps your data 
outside the defaults system (if that's what you want)


I would suggest that NSDocument might be more than you need.
It's more orientated towards user managed documents (e.g TextEdit) , while your 
app sounds more like something that manages the data itself. (More like iTunes)

Unless you intend the user to have sessions of usage and somehow switch between 
them, or distribute them in some way, which might be a reason to use NSDocument.


Angus


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CGEventTap Not Receiving Events after some time

2010-09-30 Thread Bill Cheeseman

On Sep 30, 2010, at 6:28 AM, Erik Aigner wrote:

> I already check for these events, but they never occur. I think it might be 
> that some other
> app inserts itself again before my (active, not listen only) tap?
> 
> The event tap specifically taps system events for the media keys 
> previous/playpause/next. I guess
> the new iTunes version probably "reconquers" the event tap?


I don't know how another application would block the event taps you have 
enabled, but I suppose it might be possible.

One possibility for testing these kinds of problems is to use my free Event 
Taps Testbench developer utility, at 
.

--

Bill Cheeseman - b...@cheeseman.name

___

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

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


Should I use NSDocument, NSUserDefaults or something else

2010-09-30 Thread Jonny Taylor
Thankyou for peoples patience with my recent very basic conceptual cocoa 
questions. I have another where I am trying to understand the best way of 
handling some persistent data storage.

My app is a workstation for a type of microscope, which from the point of view 
of the software consists of several different video cameras and some other 
devices controlled over USB. Each camera has associated settings (e.g. 
exposure) that I want to persist between app launches. I am not sure what the 
best way is of storing this information. There are multiple cameras involved, 
with each camera having quite a distinct role, so I would like to tie the 
settings to individual camera serial numbers.

I had a look into NSUserDefaults but that doesn't sound quite ideal. As far as 
I can see (and I may be missing something) it is not inherently designed for 
hierarchical data storage. If I wanted to store, say, QI1438.exposure and 
PS1451.exposure as separate (flat) keys, then I don't think there would be a 
way of specifying a default value for the generalized key "exposure" in 
registerDefaults (regardless of the camera serial number). It could also be 
argued that these settings are not really "user preferences", particularly 
since one could imagine having a different bank of settings for different 
experiments.

This made me think that an NSDocument might be a more appropriate solution 
(different document for each experiment, storing a hierarchical dictionary of 
key/value pairs but implementing my own handling of defaults for missing keys, 
etc). However this class is understandably a very complex class and I'm finding 
it hard to drill down to the details of what I would need to do in order to 
implement this pretty basic functionality - particularly since in some ways it 
would be a non-standard use of the class, in that the "document" was not 
associated with one single window, etc. Can anybody point me towards some 
example code that uses an NSDocument for this sort of application?

Any advice people have on which of these solutions (or indeed a third one...) I 
should be using would be very welcome.

Cheers
Jonny___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Acquiring an NSConnection otherwise than by registered name?

2010-09-30 Thread Oleg Krupnov
Hi Ken,

I understand that you probably cannot help me any further, but just in
case I am reporting the following, if anyone knows a solution or can
benefit from the information

I have checked the mailing archives and it seems that I am not alone
with the problem that runInNewThread does not necessarily cause the
request to be processed in the new thread. Some folks report that
-removeRunLoop helped them, but my experiments show that

1. -removeRunLoop doesn't seem to have any reproducible effect. At
times it works, other times not.

2. Even two subsequents calls via the same NSConnection (for which
-removeRunLoop: and -runInNewThread was called) are not guaranteed to
be handled in the same server thread. The server seems to freely pick
any idle threads that from the ones that are currently running.

3. What is curious, the #2 also happens if instead of -runInNewThread,
I create a thread manually via [NSThread
detachNewThreadSelector:toTarget:withObject:] and [NSConnection
addRunLoop:]. This is very weird -- the server utilizes any threads
you create!

4. Because server threads are assigned to connection requests so
arbitrary, it seems dangerous to manually quit any thread. It may be
being used by the server at the moment at its discretion. This means
effectively, that there is no way to exit unneeded threads on server,
only to launch new.

I have two assumptions:

1. There is [NSConnection multipleThreadsEnabled] that may be causing
this behavior. Unfortunately, there is no way to turn it off, there is
only -enableMultipleThreads, and by default it is on starting from
10.5. I wished there were disableMultipleThreads to try!

2. Can it happen because all connections on the server share the same
receiving port, which is added to the main run loop?


Thanks,

Oleg.



On Thu, Sep 30, 2010 at 3:04 AM, Ken Thomases  wrote:
> Hi Oleg,
>
> On Sep 29, 2010, at 9:57 AM, Oleg Krupnov wrote:
>
>> I tried -[NSConnection removeRunLoop:[NSRunLoop currentRunLoop]], but
>> it doesn't seem to change anything.
>
> Huh.  I don't know what's going on there.  You might consider opening a 
> developer technical support incident with Apple to ask them for advice on how 
> to achieve what you want.  Those cost money, but probably not as much as your 
> time.
>
>
>> Well, I could live with it, because the server already works as
>> multi-threaded, but the problem is that the new thread that is
>> spawned, is not released if the request is handled in the main thread,
>> when I call -invalidate on the connection. And there does not seem a
>> way to get the thread created by runInNewThread to exit it manually,
>> or is there?
>
> Probably not, but you could re-implement -runInNewThread and make 
> arrangements to terminate the thread on other occasions.
>
> I think that an alternative implementation should just remove the connection 
> from the current run loop and spawn a new thread.  The method of the new 
> thread would add the connection to its run loop and run the run loop 
> indefinitely.  You could change that to add your own signaling mechanism so 
> that, when signaled, the thread would exit instead of looping through the run 
> loop again.
>
> 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: CGEventTap Not Receiving Events after some time

2010-09-30 Thread Erik Aigner
I already check for these events, but they never occur. I think it might be 
that some other
app inserts itself again before my (active, not listen only) tap?

The event tap specifically taps system events for the media keys 
previous/playpause/next. I guess
the new iTunes version probably "reconquers" the event tap?

Regards, Erik


On 30.09.2010, at 11:01, Bill Cheeseman wrote:

> 
> On Sep 29, 2010, at 3:52 PM, Erik Aigner wrote:
> 
>> When I create an event tap with  CGEventTapCreate(..) and add it to the 
>> runloop everything works as expected.
>> However, after some time (I don't know what triggers this) the event tap 
>> doesn't receive events anymore, until
>> I manually call CGEventTapEnable(..) again.
>> 
>> Any clues what could cause this? Are there any notifications for status 
>> changes that i should know about?
> 
> 
> The documentation explains that the system automatically shuts down event 
> taps if events come so quickly that they begin to slow the system down. When 
> this happens,  the last event you receive will be a kCGEventTapDisabled 
> event. Test every event's event type to see whether it is a 
> kCGEventTapDisabledByTimeout event (as opposed to a kCGEventTapDisabledByUser 
> event, or a real event). If so, immediately re-enable the event tap, if 
> that's what you want to do. (And don't pass this event on to other routines 
> or act on it the way you would act on a real event.)
> 
> The documentation is the "Quartz Event Services Reference."
> 
> --
> 
> Bill Cheeseman - b...@cheeseman.name
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/office%40chocomoko.com
> 
> This email sent to off...@chocomoko.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: Button performs action and then stores result to a binding?

2010-09-30 Thread Jonny Taylor
Thanks for your replies Ken.

>> I have a modal dialog which, among other things, contains a number of file 
>> paths. There are "set..." buttons to set which files these are pointing to.
> You should probably by using NSPathControl instead of displaying paths and 
> having "set" buttons.
Ah, I hadn't come across that before. That's a pretty good solution to what I 
want, for minimal effort! Thanks also for your other comments which I have 
taken note of.

Cheers
Jonny___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CGEventTap Not Receiving Events after some time

2010-09-30 Thread Bill Cheeseman

On Sep 29, 2010, at 3:52 PM, Erik Aigner wrote:

> When I create an event tap with  CGEventTapCreate(..) and add it to the 
> runloop everything works as expected.
> However, after some time (I don't know what triggers this) the event tap 
> doesn't receive events anymore, until
> I manually call CGEventTapEnable(..) again.
> 
> Any clues what could cause this? Are there any notifications for status 
> changes that i should know about?


The documentation explains that the system automatically shuts down event taps 
if events come so quickly that they begin to slow the system down. When this 
happens,  the last event you receive will be a kCGEventTapDisabled event. Test 
every event's event type to see whether it is a kCGEventTapDisabledByTimeout 
event (as opposed to a kCGEventTapDisabledByUser event, or a real event). If 
so, immediately re-enable the event tap, if that's what you want to do. (And 
don't pass this event on to other routines or act on it the way you would act 
on a real event.)

The documentation is the "Quartz Event Services Reference."

--

Bill Cheeseman - b...@cheeseman.name

___

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

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