Re: Write Finder plugin

2012-07-16 Thread Ronald Oussoren

On 13 Jul, 2012, at 18:11, Mark Munz wrote:

> But the OP *could* create a Workflow OS X Services Item that has a Run
> Shell Script action with a python script.

Or use PyObjC.

Ronald

> 
> On Thu, Jul 12, 2012 at 11:16 PM, Eric Schlegel  wrote:
>> 
>> On Jul 12, 2012, at 10:45 PM, Rakesh Singhal  
>> wrote:
>> 
>>> Hi Eric,
>>> 
>>> Thanks. I am trying to do it using Services but I couldn't find any sample 
>>> code.  Can I do it in python?
>> 
>> No, you can only write a Service with Objective C. You can read about 
>> implementing a service here: 
>> https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/introduction.html.
>> 
>> -eric
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://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:
> https://lists.apple.com/mailman/options/cocoa-dev/ronaldoussoren%40mac.com
> 
> This email sent to ronaldousso...@mac.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Binding NSTableView to NSSet

2012-07-16 Thread Koen van der Drift
>> A follow up question: how do I now sort the data in the table? I am showing 
>> three values in the table, and like to sort based on either one of them. The 
>> original data is in an unordered NSSet (from my CD model). I could create an 
>> NSArray in my view controller: NSArray *myArray = [myTagsSet allObjects], 
>> and bind that to the NSArrayController, instead of to the NSSet; then I can 
>> sort the values in the table based on the array using sortDescriptors as 
>> explained here: 
>> https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/SortingTableViews/SortingTableViews.html#//apple_ref/doc/uid/1026i-CH10-SW1.
>> Would that be a good approach?
>>
>> Other alternatives?
>
> Can't you just set the sortDescriptors of the array controller?

Good suggestion, thanks. Once the ArrayController is sorted, it should
also be easy to get the selected object from the table by the row
number.

- Koen.

___

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

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

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

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


Re: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-07-16 Thread Greg Parker

On Jul 13, 2012, at 7:46 PM, Rick Mann  wrote:

> I'm using NSFileHandle in an ARC app on OS X Lion to read from a serial port.
> 
> Everything works fine 'till I go to close the port. I open the port with 
> POSIX calls, set up some stuff, then instantiate an NSFileHandle with the 
> file descriptor I got from open().
> 
> Then I call -readInBackgroundAndNotify, and a second file descriptor gets 
> opened (I see this by using lsof).
> 
> That FD gets closed the moment some data comes in and a notification gets 
> posted, but I just go right back and call -readInBackgroundAndNotify again to 
> get the next data.
> 
> The problem is when I go to close the port. I still have a pending 
> -readInBackgroundAndNotify, and so the port is opened twice. When I call 
> -closeFile on the NSFileHandle, it closes the FD I initially opened, but 
> leaves the second FD open.
> 
> I tried setting the NSFileHandle reference to nil so that ARC would release 
> it, and hopefully call -dealloc on it, but either it's not doing that, or 
> -dealloc doesn't close that second FD either.
> 
> In any case, when I go to open that port again, I get an error saying the 
> resource is busy (if I quit my app, all FDs get closed).
> 
> This sure seems like a bug to me. Am I doing something wrong?


NSFileHandle dups the file descriptor to avoid bugs where the descriptor is 
closed from under it. That's expected.

NSFileHandle retains itself during the background operation to avoid being 
deallocated while it's still in progress. I think the -closeFile call is 
supposed to cancel the background operations which in turn should release that 
extra retain, but perhaps something in there is not working correctly. 

What does the Allocations instrument say about the retain/release history? If 
it looks like -readInBackgroundAndNotify is performing an extra retain that 
doesn't get released then you should file a bug report.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler



___

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

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

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

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


textView, writeCell to clipboard, how to read from clipboard

2012-07-16 Thread Alexander Reichstadt
Hi,

in NSTextView there is a method to handling writing textattachmentcells to the 
clipboard. I implemented the following and it seems to work:

- (NSArray *)textView:(NSTextView *)aTextView 
writablePasteboardTypesForCell:(id )cell
  atIndex:(NSUInteger)charIndex;
{
return [NSArray arrayWithObject:kDataCellTypeUTI];
}

- (BOOL)textView:(NSTextView *)aTextView
   writeCell:(id )cell
 atIndex:(NSUInteger)charIndex
toPasteboard:(NSPasteboard *)pboard type:(NSString *)type;
{
if (type == kDataCellTypeUTI)
[pboard writeObjects:[NSArray arrayWithObject:cell]];

return YES;
}


Both get overridden and my custom textattachmentcell ends up on the pasteboard. 
But when pasting it and even though it does get pasted as a cell, the custom 
properties are the default values and not the ones from the copy on the 
pasteboard. initWithPasteboardPropertyList is never called nor initWithCoder, 
only the standard init method. The cell subclass subscribes to 
NSPastboardReading and -Writing protocol and implements all methods thereof. IS 
there anything else that needs to be done, or are textattachmentcells an 
exception to the pasteboard in some way?

AR
___

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

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

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

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


Re: +bundleForClass: category question

2012-07-16 Thread Jens Alfke

On Jul 15, 2012, at 8:29 PM, David Duncan  wrote:

> The category is a method on the class you specify, therefore [self class] 
> will be that class (whatever it is) and you will get the bundle for that 
> class. In this case, it means your bundle will be the framework bundle.

That's an ambiguous answer since Graham's got his own framework too.

The answer, I think, is the _system_ framework bundle that contains the base 
implementation of the class, not Graham's framework with the category.

—Jens
___

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

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

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

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

Re: +bundleForClass: category question

2012-07-16 Thread Dave DeLong
The answer is simple, and it's answered by the name of the method:

-bundleForClass:

Graham's framework does not define the class.  Therefore, it is not the bundle 
that is returned from the method.  This method returns the bundle that defines 
the class.  In Graham's example, it would be the system framework.

Dave

On Jul 16, 2012, at 2:08 PM, Jens Alfke wrote:

> 
> On Jul 15, 2012, at 8:29 PM, David Duncan  wrote:
> 
>> The category is a method on the class you specify, therefore [self class] 
>> will be that class (whatever it is) and you will get the bundle for that 
>> class. In this case, it means your bundle will be the framework bundle.
> 
> That's an ambiguous answer since Graham's got his own framework too.
> 
> The answer, I think, is the _system_ framework bundle that contains the base 
> implementation of the class, not Graham's framework with the category.
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

NSTextAttachment

2012-07-16 Thread Alexander Reichstadt
Is there any way to have an NSTextView to hold text and custom data-widgets 
that are unrelated to filewrappers? I don't want NSTextAttachmentCell I think, 
because without a file it doesn't work, without tricking around it does not go 
in and out of the pasteboard, and NSTokenAttachment is some private API thing. 
I need to be able to have placeholder fields in a textview that are based on 
NSCell or can be own views. Is there really nothing available? I don't have the 
capacity to write an entire layout editor like pages for that neither.

Thanks
___

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

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

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

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


Re: Core Data Multiuser

2012-07-16 Thread Jens Alfke

On Jul 13, 2012, at 12:38 PM, Flavio Donadio  wrote:

> On chapter 11, the book talks about "distributed Core Data", using 
> Distributed Objects to exchange NSManagedObjects between a client app and a 
> server app. The latter deals with the MOC and the persistent store. Zarra 
> warns about scalability problems, since NSManagedObjectContext is not 
> thread-safe and, the, all clients' data would be dealt with serially... But, 
> what if I used one MOC per client?

In my experience — and yes I have tried it — using DO between multiple 
computers is a nightmare. I know it sounds so simple and appealing, but that's 
because it tries to sweep all the hard problems of networking[1] under the rug. 
The problems remain, and will bite you, hard.

The inconvenient truth is that sending a message over a network is not at all 
the same as sending an Objective-C message between two objects, no matter what 
kind of clever wrapping is used to make it look like it. Network messages are 
orders of magnitude slower, they are unreliable for many different reasons, and 
they're not trustable unless you are very, very careful about authentication 
and sandboxing.

There are basically two realistic ways to do what you want to do:

(1) Client-server. The database lives on one server machine, as does the 
"business logic" (I hate that term) that manages your app. This could 
definitely be implemented with Core Data if you like. The client app just 
focuses on the UI, and there is some protocol by which it talks to the server 
to fetch data and to tell it to do stuff. In other words, the client app will 
not use Core Data.

(2) Synchronized. Every client has a copy of the database, and the app operates 
on the local database. But the clients have to stay in sync by sending messages 
to the server whenever they make changes, and receiving notifications from the 
server when some other client makes a change. If conflicting changes are made, 
there has to be a way to resolve them.

The bad news: Approach #1 is straightforward but means you have to abandon Core 
Data on the client, and design and implement your own network protocol, which 
is time-consuming. Approach #2 is lovely when it works but I assure you from 
experience that synchronization is very, very difficult to implement from 
scratch.

I hate to make this post sound like an ad, but I'm developing (for my employer, 
Couchbase) a framework that implements #2. It's based on CouchDB[2], a very 
popular nonrelational ("NoSQL") distributed database that is really, really 
good at synchronization. My framework, TouchDB,[3] lets Mac or iOS or Android 
apps store databases locally, operate on them locally, and then replicate in 
real time with a CouchDB server. If there are multiple clients syncing with the 
same server, it's exactly the solution #2 I outlined above.

Now, TouchDB isn't compatible with Core Data. But it does have a pretty solid 
Cocoa API that has an object-model layer a bit like a simplified Core Data. The 
people who've been using it like it a lot.

—Jens

[1]: http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Computing
[2]: http://couchdb.apache.org
[3]: http://touchdb.org
___

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

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

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

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

Re: NSTextAttachment

2012-07-16 Thread Jens Alfke

On Jul 16, 2012, at 2:15 PM, Alexander Reichstadt  wrote:

> Is there any way to have an NSTextView to hold text and custom data-widgets 
> that are unrelated to filewrappers? I don't want NSTextAttachmentCell I 
> think, because without a file it doesn't work

I have used NSTextAttachmentCell for things that are not files. Note the 
comment in NSTextAttachment.h that says "An NSTextAttachment *usually* has a 
fileWrapper" (emphasis mine). It doesn't *have* to have one.

Unfortunately it's been enough years that I don't remember the details. It may 
be that you can initialize an NSTextAttachment with a nil fileWrapper, or to 
set the fileWrapper property to nil after initialization. If not, you may just 
be able to pass in an arbitrary path to some file, and then the 
NSTextAttachmentCell methods such that they don't care what the file is.

—Jens
___

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

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

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

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

How to determine an NSSlider's thumb position onscreen?

2012-07-16 Thread Sean McBride
Hi all,

Anyone know how to get the screen position of an NSSlider's thumb?

NSSliderCell has a method knobRectFlipped: which works perfectly, though I note 
the docs say "You should never invoke this method explicitly. It’s included so 
you can override it".  I don't see any other way though...

(Since someone will ask: I want to position a custom floating window adjacent 
to a slider's thumb when the user drags the thumb.  The window would act a bit 
like a tool tip, showing the numerical value of the thing being adjusted.  I 
suppose I could abuse the tooltip, but I'm already using it to explain what the 
control is for.)

Thanks,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada

___

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

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

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

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

Re: NSTextAttachment

2012-07-16 Thread Alexander Reichstadt
There is a blog that outlines how to do this with help of Douglas Davidson:
http://www.dejal.com/blog/2007/11/cocoa-custom-attachment-text-view

The suggestion here is to use a textStorage delegate to insert the custom 
attachment cell into the text. It actually relies on what seems like a bug:

if ([attachment isKindOfClass:[NSTextAttachment class]] &&
![[attachment attachmentCell] 
isKindOfClass:[TATextAttachmentCell class]])
{


This is happening in

- (void)textStorageWillProcessEditing:(NSNotification *)note

What I don't understand is that before it's a TATextAttachment with a 
TATextAttachmentCell, being my subclasses, and afterwards when pasting/dropping 
and looking at the debugger, the objects become NSTextAttachment and its cell 
respectively. Why? And how can I make it stop it from turning my subclasses 
into their superclasses?



Am 16.07.2012 um 23:51 schrieb Jens Alfke:

> 
> On Jul 16, 2012, at 2:15 PM, Alexander Reichstadt  wrote:
> 
>> Is there any way to have an NSTextView to hold text and custom data-widgets 
>> that are unrelated to filewrappers? I don't want NSTextAttachmentCell I 
>> think, because without a file it doesn't work
> 
> I have used NSTextAttachmentCell for things that are not files. Note the 
> comment in NSTextAttachment.h that says "An NSTextAttachment *usually* has a 
> fileWrapper" (emphasis mine). It doesn't *have* to have one.
> 
> Unfortunately it's been enough years that I don't remember the details. It 
> may be that you can initialize an NSTextAttachment with a nil fileWrapper, or 
> to set the fileWrapper property to nil after initialization. If not, you may 
> just be able to pass in an arbitrary path to some file, and then the 
> NSTextAttachmentCell methods such that they don't care what the file is.
> 
> —Jens

___

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

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

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

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

Re: Core Data Multiuser

2012-07-16 Thread Flavio Donadio
On 16/07/2012, at 18:39, Jens Alfke wrote:

> In my experience — and yes I have tried it — using DO between multiple 
> computers is a nightmare. I know it sounds so simple and appealing, but 
> that's because it tries to sweep all the hard problems of networking[1] under 
> the rug. The problems remain, and will bite you, hard.
> 
> [...]
> 
> The bad news: Approach #1 is straightforward but means you have to abandon 
> Core Data on the client, and design and implement your own network protocol, 
> which is time-consuming. Approach #2 is lovely when it works but I assure you 
> from experience that synchronization is very, very difficult to implement 
> from scratch.

Well... This is one of the more down-to-earth arguments about why I should 
steer away from this technique. Coming from you, Jens, I can't ignore it.


> I hate to make this post sound like an ad, but I'm developing (for my 
> employer, Couchbase) a framework that implements #2. It's based on 
> CouchDB[2], a very popular nonrelational ("NoSQL") distributed database that 
> is really, really good at synchronization. My framework, TouchDB,[3] lets Mac 
> or iOS or Android apps store databases locally, operate on them locally, and 
> then replicate in real time with a CouchDB server. If there are multiple 
> clients syncing with the same server, it's exactly the solution #2 I outlined 
> above.

I've just took a look at the links you sent and I'm downloading TouchDB. I'll 
have a careful look at it soon.


> Now, TouchDB isn't compatible with Core Data. But it does have a pretty solid 
> Cocoa API that has an object-model layer a bit like a simplified Core Data. 
> The people who've been using it like it a lot.

To be honest, I know a little about Cocoa and can write almost any simple app 
you can imagine. Core Data is not, by any measure, a simple framework. I think 
I understand it, so it feels comfortable for me to try and stick with it. But 
it doesn't have to be Core Data. It must be Cocoa, though.


Cheers,
Flavio
___

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

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

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

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

Re: Core Data Multiuser

2012-07-16 Thread Jens Alfke

On Jul 16, 2012, at 4:11 PM, Flavio Donadio  wrote:

> To be honest, I know a little about Cocoa and can write almost any simple app 
> you can imagine. Core Data is not, by any measure, a simple framework. I 
> think I understand it, so it feels comfortable for me to try and stick with 
> it. But it doesn't have to be Core Data. It must be Cocoa, though.

To be honest, I never really got comfortable with Core Data. It always seemed 
to be very complex to do anything real with it, and there was a lot of 
boilerplate to set it up. (That was 5+ years ago, though. Maybe it's gotten 
simpler ;-)

One of the nice things about CouchDB-like databases is that everything is JSON, 
which is a kissing cousin of a PList, so you can treat your data like 
property-lists if you want. Or alternatively, the CouchModel class lets you 
treat data items as objects with custom properties, which can often make the 
code cleaner. But the choice is yours, and you can in fact mix the two 
approaches.

(I did a presentation about this a few months ago: 
. Just wherever it says "Couchbase 
Mobile", think "TouchDB".)

—Jens
___

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

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

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

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

Perplexing crash in iOS app, on observing an NSOperation

2012-07-16 Thread Gavin Stokes
I added some new operation-handling in my app, and it's now crashing quite
frequently in background threads with EXC_BAD_ACCESS and this:

1   Foundation0x306cdd46
-[NSObject(NSKeyValueObservingPrivate)
_changeValueForKey:key:key:usingBlock:] + 438

2   Foundation0x306cdb84
-[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:usingBlock:] + 24

3   Foundation0x30752260
NSOQDelayedFinishOperations_block_invoke_0 + 84

4   Foundation0x306cdd46
-[NSObject(NSKeyValueObservingPrivate)
_changeValueForKey:key:key:usingBlock:] + 438

5   Foundation0x306cdb84
-[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:usingBlock:] + 24

6   Foundation0x307521d4 __NSOQDelayedFinishOperations
+ 128

7   libdispatch.dylib 0x377df9a2 _dispatch_after_timer_callback
+ 6

8   libdispatch.dylib 0x377e2252 _dispatch_source_invoke + 510

9   libdispatch.dylib 0x377dfb1e
_dispatch_queue_invoke$VARIANT$up + 42

10  libdispatch.dylib 0x377e0784 _dispatch_worker_thread2 + 208

11  libsystem_c.dylib 0x346afdf4 _pthread_wqthread + 288

12  libsystem_c.dylib 0x346afcc8 start_wqthread + 0

The thing is, I'm not updating the UI from this background thread, and I
don't see any difference between the new code and essentially identical
code that has been running crash-free for months.

Is there some other common pitfall here (aside from updating the UI in a
background thread) that could be responsible?

Thanks for any ideas.

Gavin
___

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

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

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

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


Re: Perplexing crash in iOS app, on observing an NSOperation

2012-07-16 Thread Gavin Stokes
Never mind.  I was double-releasing an operation.

Thanks anyway!
___

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

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

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

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


Re: +bundleForClass: category question

2012-07-16 Thread Graham Cox

On 17/07/2012, at 7:15 AM, Dave DeLong wrote:

> The answer is simple, and it's answered by the name of the method:
> 
> -bundleForClass:
> 
> Graham's framework does not define the class.  Therefore, it is not the 
> bundle that is returned from the method.  This method returns the bundle that 
> defines the class.  In Graham's example, it would be the system framework.


That was my assumption, so the answer was what I expected. But I also wondered 
whether it was possibly a bit smarter and used the full category name as the 
class name.

What I'm trying to do is to add a couple of cursors to NSCursor using a 
category which are created by loading images from the framework's resources. 
Unfortunately it doesn't work when implemented in a simple way because 
+bundleForClass returns the bundle containing NSCursor. Instead I have to 
declare an intermediate class that loads the image resource for me - I was just 
hoping to avoid that extra step but seems not.

--Graham


___

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

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

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

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


Re: +bundleForClass: category question

2012-07-16 Thread Kyle Sluder
On Tue, Jul 17, 2012, at 11:02 AM, Graham Cox wrote:
> 
> What I'm trying to do is to add a couple of cursors to NSCursor using a
> category which are created by loading images from the framework's
> resources. Unfortunately it doesn't work when implemented in a simple way
> because +bundleForClass returns the bundle containing NSCursor. Instead I
> have to declare an intermediate class that loads the image resource for
> me - I was just hoping to avoid that extra step but seems not.

Since the identifier of the bundle is known at compile time, we have a
compile-time define that we use whenever we need to provide an NSBundle
in a situation like this:
https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniBase/OBUtilities.h#L64

Basically, we define OMNI_BUNDLE_IDENTIFIER in the Xcode project, use
the "Preprocess Info.plist" option to insert it into the
CFBundleIdentifier property, and use OMNI_BUNDLE whenever we need to
provide a "this-bundle"-relative NSBundle argument. OMNI_BUNDLE
essentially expands to [NSBundle bundleWithIdentifier:OMNI_BUNDLE].

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: +bundleForClass: category question

2012-07-16 Thread Jens Alfke

On Jul 16, 2012, at 6:02 PM, Graham Cox  wrote:

> What I'm trying to do is to add a couple of cursors to NSCursor using a 
> category which are created by loading images from the framework's resources. 
> Unfortunately it doesn't work when implemented in a simple way because 
> +bundleForClass returns the bundle containing NSCursor. Instead I have to 
> declare an intermediate class that loads the image resource for me - I was 
> just hoping to avoid that extra step but seems not.

Why not just make a subclass of NSCursor and put the accessor methods on that? 
It's safer than a category since you don't run the risk of colliding with a 
method name added by another framework/bundle in the same process, or by a 
future version of NSCursor itself.

—Jens
___

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

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

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

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

Re: Core Data Multiuser

2012-07-16 Thread Chris Hanson
On Jul 16, 2012, at 2:39 PM, Jens Alfke  wrote:

> (1) Client-server. The database lives on one server machine, as does the 
> "business logic" (I hate that term) that manages your app. This could 
> definitely be implemented with Core Data if you like. The client app just 
> focuses on the UI, and there is some protocol by which it talks to the server 
> to fetch data and to tell it to do stuff. In other words, the client app will 
> not use Core Data.

Another option for client-server is to create an NSIncrementalStore subclass to 
use on the client, regardless of what you use on the server.

The server could be an XML or JSON-based REST web service written using any of 
a variety of frameworks, the server could be a Mac running a Core Data-based 
server using a custom protocol you design, the server could be an old mainframe 
running COBOL... Your NSIncrementalStore subclass can act as an adaptor between 
it and the rest of your application, allowing your application to be written 
using Core Data and allowing it to take advantage of its features.

  -- Chris

___

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

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

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

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


Sensible NSMultipleValuesMarker placeholder alternatives?

2012-07-16 Thread Markus Spoettl

Hello,

  I have a UI where the user selects objects and edits them in a separate 
(popup) window. The window opens, displays various combo boxes, text fields, and 
so on all bound to the model objects through an NSArrayController via the 
selection proxy. Also, when the editing window opens up, the topmost edit field 
is made first responder.


When one object is being edited, this UI works well - nothing unexpected 
happens. However, when multiple objects are being edited, and those objects have 
different values, the text fields and combo boxes display the multiple values 
placeholder.


Of course that's expected but it's not intuitive for the user. I find that a 
list of values (those of the different objects selected) displayed in a "nice 
way" would be more helpful, but let's accept that for the moment.


What is more problematic is that if an edit field which displays the placeholder 
looses first responder, the model values are set to nil.


Now, together with my default UI behavior that the topmost field becomes first 
responder when the window opens, it effectively kills the existing model values 
for that field because the user can't close the window without existing the text 
field.


I think there should be a conscious decision and action involved by the user 
before the text values for a multi-selection get changed. Much like the behavior 
of a checkbox button. Tabing through the UI and killing all values along the 
path surely isn't very sensible.


That doesn't seem to be possible using bindings, I'm wondering how others solve 
this?


Regards
Markus
--
__
Markus Spoettl

___

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

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

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

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