Re: How to get the dispatch queue for the current thread's runloop?

2012-01-28 Thread Wade Tregaskis
> Where do they say that?  That's surely wrong.  The man page says that in that 
> case it returns the default-priority global [serial] queue.

Nevermind, I'm not paying enough attention.  I figured you'd have to return a 
serial queue, so my brain conveniently ignored the fact that the global default 
queues are all concurrent.

FWIW here's the state of affairs on 10.7.2:

Main queue: com.apple.main-thread (0x7fff7c2aa980)

Default concurrent queues:
High priority: com.apple.root.high-priority (0x7fff7c2ab240)
High priority (overcommit): com.apple.root.high-overcommit-priority 
(0x7fff7c2ab300)
Default priority: com.apple.root.default-priority (0x7fff7c2ab0c0)
Default priority (overcommit): 
com.apple.root.default-overcommit-priority (0x7fff7c2ab180)
Low priority: com.apple.root.low-priority (0x7fff7c2aaf40)
Low priority (overcommit): com.apple.root.low-overcommit-priority 
(0x7fff7c2ab000)
Background priority: com.apple.root.background-priority (0x7fff7c2ab3c0)

Current queue as seen by:
Default priority concurrent queue: com.apple.root.default-priority 
(0x7fff7c2ab0c0)
Main thread (outside of dispatch queue): com.apple.main-thread 
(0x7fff7c2aa980)
Random pthread: com.apple.root.default-overcommit-priority 
(0x7fff7c2ab180)
Main queue: com.apple.main-thread (0x7fff7c2aa980)

Note that it returns an over-commit queue if there is no other answer.  
Over-commit queues differ from the normal queues in that they have no limit to 
the number of threads that may be servicing them concurrently (other than the 
general limits on thread numbers).  I expect there's a very deliberate reason 
why this is done, but it does open the possibility for poorly written code to 
over-subscribe the system and bring down the overall performance.
___

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: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-28 Thread Ron Hunsinger

On Jan 26, 2012, at 11:30 AM, Jens Alfke wrote:

> To work around this I suggest using single-quotes instead, and preprocessing 
> the string to insert a backslash in front of any exclamation point or 
> single-quote. I *think* that will be enough.

After a single quote, the *only* character that has a special meaning is 
another single quote, which ends the quotation. Double quotes, back slashes, 
dollar signs, exclamation marks, et al. have absolutely no special significance 
between single quotes..

Thus, the simplest way to safely quote an arbitrary string is to preprocess the 
string to replace each single quote (') with the sequence single quote, 
backslash, single quote, single quote ('\''), and then wrap the resulting 
string in single quotes.

As an (unnecessary) refinement, scan that sequence again, replacing each 
sequence of three consecutive single quotes with one, to shorten the string 
that results when the original string contained consecutive single quotes. As 
another (unnecessary) refinement, pre-scan the original string to see if it 
contains only safe characters, in which case no quoting needs to be done at 
all. It's probably not worth bothering to do either of these.


Almost as easy to program, but generally producing longer quoted strings, is to 
prepend a backslash to any character that is not a lowercase letter or a digit. 
Do not wrap the resulting string in any kind of quotes. (Non-ASCII characters 
are never special to the shell, but I'm not sure what would happen if you 
inserted backslashes in the middle of a multi-byte character, nor whether the 
behavior will change in later versions of the shell, so be sure you're 
prepending backslashes to characters, not bytes.)

-Ron Hunsinger


___

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


Drag and drop in collectionview

2012-01-28 Thread Luc Van Bogaert

I'm implementing drag and drop for a NSCollectionView. The idea is to rearrange 
objects in the collection by dragging them to another location. Having read the 
docs for NSCollectionViewDelegate and NSPasteboard, I still have a few general 
questions about the concept.

The objects themselves conform to both the NSPasteboardWriting and 
NSPasteboardReading protocols.

In the collection view delegate, I have implemented the protocol methods that 
allow me to initiate a dragging session, and to write the dragged items to the 
pasteboard. I'm writing the objects as NSData objects, using NSKeyedArchiver.

I have also implemented the methods to validate and accept the drag operation. 
In the latter, I am reading the dragged items back from the pasteboard, using 
readObjectsForClasses:[NSArray arrayWithObject:[MyObject class]]

It seems that the objects read from the pasteboard are not the same as the 
original dragged objects; they only represent the same data. This seems natural 
to me, as I'm using a archiver in the process, but I'm really not sure if I 
should somehow find a way to retrieve the original objects from the pasteboard. 
Is this at all possible?. 

If I should indeed proceed with these different objects that have been read 
from the pasteboard, I'm wondering how to effectively perform the move in my 
model array:  should I just insert the objects into my array model object at 
the desired location and remove the original ones, or should I try to find a 
way to reference the original objects (using an identifier in the items 
obtained from the pasteboard) and move those around in my model array?

If the latter; what kind of identifier could be used for this? Some kind of 
ivar with a unique value? How to generate something like this?

Thanks for any advice on this
 
-- 
Luc Van Bogaert




___

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: Blocks and Methods...

2012-01-28 Thread Mike Abdullah

On 28 Jan 2012, at 05:32, R wrote:

> I'm writing code in for iOS 5
> 
> Ok, in my async com class, I'm receiving a block in one method and
> want to execute it in the another method.  I've concluded that I need
> to place the block in a property.  The only way that has worked is via
> copy.
> 
> Is this the conventional way to save a block?

Yes, blocks start out life on the stack. You have to copy them if the block is 
needed to be executed later.


___

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: Trying to customize UITableViewCell with IB but having odd exception

2012-01-28 Thread Phillip Mills
On 2012-01-28, at 1:55 AM, James West wrote:

> I get -[UIAccessibiltyBundle setProduct:] unrecognized selector sent to 
> instance

It looks as if the cell has been deallocated and its address reused to hold a 
different kind of object. (UIAccessibiltyBundle)
If it's not obvious how this is happening, I'd try using Instruments to check 
for zombies.


___

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: Recently Opened in Doc

2012-01-28 Thread Brad Stone
I have a shoebox app like iPhoto where the actual filename is irrelevant to the 
user.   I control the file name.  

What I'd like to do is just capture the menu items before they're displayed and 
change the menu titles into something relevant to the user.  In the scheme of 
things it's a minor way to access the info in my app so if I could eliminate 
them that would be OK too.  Changing the filename is not an option at this 
point.


On Jan 27, 2012, at 11:19 PM, James Merkel wrote:

> On 27 Jan 2012 10:20:37 Brad Stone wrote:
>> I'd like to 
>> 1) change the menu titles of the recently opened documents listed in the 
>> dock menu
>> 
>> if I can't do that I'd like to 
>> 
>> 2) remove the list of recently opened documents all together.
>> 
>> I haven't been able to find a way to do this.  Can someone provide guidance?
>> 
>> Thanks
> 
> I don't  have an answer to your question -- but something I didn't notice 
> before.
> If you rename a file, the new filename appears in the recently opened files 
> menu (replacing the old filename).
> However the old filename stays in the doc menu.
> Seems like that's a bug.
> 
> Jim Merkel


___

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: Blocks and Methods...

2012-01-28 Thread R
I originally chose to hold the block in an array, but that failed.
I'm still confused over that...


On Jan 28, 7:02 am, Mike Abdullah  wrote:
> On 28 Jan 2012, at 05:32, R wrote:
>
> > I'm writing code in for iOS 5
>
> > Ok, in my async com class, I'm receiving a block in one method and
> > want to execute it in the another method.  I've concluded that I need
> > to place the block in a property.  The only way that has worked is via
> > copy.
>
> > Is this the conventional way to save a block?
>
> Yes, blocks start out life on the stack. You have to copy them if the block 
> is needed to be executed later.
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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

Re: Recently Opened in Doc

2012-01-28 Thread Quincey Morris
On Jan 28, 2012, at 08:19 , Brad Stone wrote:

> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
> the user.   I control the file name.  
> 
> What I'd like to do is just capture the menu items before they're displayed 
> and change the menu titles into something relevant to the user.  In the 
> scheme of things it's a minor way to access the info in my app so if I could 
> eliminate them that would be OK too.  Changing the filename is not an option 
> at this point.

It seems to me you can subclass NSDocumentController, then override 
'noteNewRecentDocument:' to do nothing. Presumably this will keep your filename 
off the "Open Recent" submenu, the "Recent Items" item on the Apple menu, and 
the dock menu. Then you should be able to delete the "Open Recent" item itself, 
and be left with no traces of recent items from your app.

If you wanted to go the extra mile, you could create your own recent-items 
implementation, driven from your 'noteNewRecentDocument:' override, and using 
the 'applicationDockMenu:' application delegate method, with whatever document 
identifiers you want.


___

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: Blocks and Methods...

2012-01-28 Thread Ken Thomases
On Jan 28, 2012, at 10:40 AM, R wrote:

> I originally chose to hold the block in an array, but that failed.
> I'm still confused over that...

By itself, an array only retains the block.  A block must be explicitly copied 
if it is to outlive the scope that created it.  And, of course, that copy 
operation has to be balanced with an eventual release.

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

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


Re: How to get the dispatch queue for the current thread's runloop?

2012-01-28 Thread Steve Sisak

At 12:14 PM -0800 1/27/12, Jens Alfke wrote:
I'm really used to using 
-performSelector:withObject:afterDelay: to make 
something happen later. But I'd much rather use 
a block than a target/action. I can't find any 
API for this, however. Am I missing something? 
What I want is basically like

PerformBlockAfterDelay(^{ Šcode hereŠ}, 5.0);


Me too! PerformBlockOnThread would be nice as well.

It looks like I should just call dispatch_async, 
but I'm unsure which dispatch queue to use. 
dispatch_get_main_queue only works for the main 
thread. Can I use dispatch_get_current_queue?


As others have mentioned later in the thread, 
with the exception of the main queue, dispatch 
queues aren't tied to threads -- they execute 
blocks on a pool of threads managed by the system.


Later in the thread:

At 6:00 PM +1100 1/28/12, Shane Stanley wrote:

On 28/01/2012, at 1:41 PM, Ken Thomases wrote:


 Believe it or not, this also works:

 >[(id)^{ ... code here ... } 
performSelector:@selector(invoke) withObject:nil 
afterDelay:5.0];


 That is, you can target 
performSelector:withObject:afterDelay: at a 
block, itself, rather than some other helper 
object.  And, a block implements the -invoke 
selector to, well, invoke itself.


FWIW, on stackoverflow there's a post suggesting 
the use of a block as a target, and using 
-invoke to select it. In the comments is one 
from bbum from last October:


 This "works" by coincidence. It relies on 
private API; the invoke method on Block objects 
is not public and not intended to be used in 
this fashion.


, 
about fourth answer down.


This reminds me that, IIRC, a block (after it's 
copied to the heap) _is_ an object. I was going 
to suggest some form of calling BlockCopy 
manually, but given the example above, you might 
something like:


-(void)executeBlock:((^)(void) block  // <- someone help with this declaration
{
  block();
}

...

[self performSelector:@selector(executeBlock:) 
withObject:(id)^{ ... code here ... } 
afterDelay:5.0];


might work.

I'm still trying to get my head around all these 
issues as well, but hoping this might help you to 
a solution. I'm interested in the solution as 
well.


HTH,

-Steve


___

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: Full-Height Toolbar Item

2012-01-28 Thread Mark Alldritt

On 2012-01-27, at 12:00 PM, Jens Alfke wrote:

> There's probably a private API for that. The bad news is that Apple apps use 
> a lot of private APIs :( The good news is that these APIs often become public 
> in later OS releases, especially if developers file bugs clamoring for them 
> (hint hint).

Done: 10770991

Cheers
-Mark


___

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

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

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

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


Re: How to get the dispatch queue for the current thread's runloop?

2012-01-28 Thread Steve Sisak

At 12:14 PM -0800 1/27/12, Jens Alfke wrote:
I'm really used to using -performSelector:withObject:afterDelay: to 
make something happen later. But I'd much rather use a block than a 
target/action.


At 12:23 PM -0500 1/28/12, Steve Sisak wrote:
This reminds me that, IIRC, a block (after it's copied to the heap) 
_is_ an object. I was going to suggest some form of calling 
BlockCopy manually, but given the example above, you might something 
like:


-(void)executeBlock:((^)(void) block  // <- someone help with this declaration
{
  block();
}


This was interesting enough to stick my head in the documentation and 
build a test program.


The following appears to work:

- (void)performBlock:(void (^)(void)) block
{
block();
}

- (IBAction) doItNow:(id)sender
{
[self performSelector:@selector(performBlock:) withObject:^{
NSLog(@"Done");
}];
}

- (IBAction) doItLater:(id)sender
{
[self performSelector:@selector(performBlock:)
   withObject:^{
NSLog(@"Done Later");
}   afterDelay:1.0];
}

Does anyone see a problem with this technique?

-Steve
___

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: Blocks and Methods...

2012-01-28 Thread R
That is precisely what is giving me the confusion.  If retained the
received block in a NSMutableArray, the block should stick around (via
a strong array pointer) for another method.  It only stays around if I
equate the block to a typedef variable and then put that variable in
the array.  I'm using ARC.

On Jan 28, 9:51 am, Ken Thomases  wrote:
> On Jan 28, 2012, at 10:40 AM, R wrote:
>
> > I originally chose to hold the block in an array, but that failed.
> > I'm still confused over that...
>
> By itself, an array only retains the block.  A block must be explicitly 
> copied if it is to outlive the scope that created it.  And, of course, that 
> copy operation has to be balanced with an eventual release.
>
> Regards,
> Ken
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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

Re: Recently Opened in Doc

2012-01-28 Thread Brad Stone
Thanks Quincey, I've already subclassed my NSDocumentController and I use 
noteNewRecentDocument to prevent my index file from showing up in the list.   
The code never gets past the continue call because every time this method is 
called the only menu item  in [openRecentMenu itemArray] is "Clear Menu" 
(except when I quit out).

- (void)noteNewRecentDocument:(NSDocument *)aDocument {
if ([aDocument isKindOfClass:[PNDocument class]]) {
[super noteNewRecentDocument:aDocument];
}

NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
if (!fileMenu) {
return;
}
NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@"Open Recent"] submenu];
if (!openRecentMenu) {
return;
}
 
for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
NSString *title = [openRecentMenuItem title];
if ([title isEqualToString:@"Clear Menu"]) {
continue;
}
   // code to change the menuItem title

}
}





On Jan 28, 2012, at 11:46 AM, Quincey Morris wrote:

> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
> 
>> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
>> the user.   I control the file name.  
>> 
>> What I'd like to do is just capture the menu items before they're displayed 
>> and change the menu titles into something relevant to the user.  In the 
>> scheme of things it's a minor way to access the info in my app so if I could 
>> eliminate them that would be OK too.  Changing the filename is not an option 
>> at this point.
> 
> It seems to me you can subclass NSDocumentController, then override 
> 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
> filename off the "Open Recent" submenu, the "Recent Items" item on the Apple 
> menu, and the dock menu. Then you should be able to delete the "Open Recent" 
> item itself, and be left with no traces of recent items from your app.
> 
> If you wanted to go the extra mile, you could create your own recent-items 
> implementation, driven from your 'noteNewRecentDocument:' override, and using 
> the 'applicationDockMenu:' application delegate method, with whatever 
> document identifiers you want.
> 
> 

___

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: Recently Opened in Doc

2012-01-28 Thread Quincey Morris
On Jan 28, 2012, at 11:57 , Brad Stone wrote:

> Thanks Quincey, I've already subclassed my NSDocumentController and I use 
> noteNewRecentDocument to prevent my index file from showing up in the list.   
> The code never gets past the continue call because every time this method is 
> called the only menu item  in [openRecentMenu itemArray] is "Clear Menu" 
> (except when I quit out).
> 
> - (void)noteNewRecentDocument:(NSDocument *)aDocument {
> if ([aDocument isKindOfClass:[PNDocument class]]) {
> [super noteNewRecentDocument:aDocument];
> }
> 
> NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
> if (!fileMenu) {
> return;
> }
> NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@"Open Recent"] 
> submenu];
> if (!openRecentMenu) {
> return;
> }
>  
> for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
> NSString *title = [openRecentMenuItem title];
> if ([title isEqualToString:@"Clear Menu"]) {
> continue;
> }
>// code to change the menuItem title
> 
> }
> }

There's a couple of things I don't understand here.

If your document is a PNDocument, then you never add it to the menu via the 
super call, so of course there's no item there to have its name changed.

OTOH, unless your app has multiple doc classes AND the others use regular file 
names AND you're trying to mix regular file names and your special names on the 
same menu, then why are you bothering to leverage the document controller 
mechanism? Just opt out, and create your own Recent Items mechanism to use 
instead.

The problem with trying to integrate into any of document controller's standard 
behavior is that you might end up "fixing" the menu, but that won't solve 
anything for the dock menu, which was your original question.

___

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: How to get the dispatch queue for the current thread's runloop?

2012-01-28 Thread Jens Alfke

On Jan 28, 2012, at 11:35 AM, Steve Sisak wrote:

> [self performSelector:@selector(performBlock:)
>withObject:^{
> NSLog(@"Done Later");
> }   afterDelay:1.0];

Don't you need to copy the block? Or is -performSelector:withObject:afterDelay: 
smart enough to know to call -copy instead of -retain on the block?

Also, I'm not entirely happy with this solution because it's tied to an object 
when it shouldn't need to be. So your -doItLater: method only works in the 
class you declare it in, and it has the side effect of keeping the receiver 
alive until the block runs, even if it doesn't need to be (i.e. if the block 
doesn't refer to 'self' at all.)

Someone else had a solution that involved adding a category method to NSObject 
to invoke the block, but that seems a bit kludgy too.

—Jens

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: Open a new terminal tab or window from a Cocoa app at a certain directory without using NSAppleScript?

2012-01-28 Thread Jens Alfke

On Jan 28, 2012, at 1:17 AM, Ron Hunsinger wrote:

> After a single quote, the *only* character that has a special meaning is 
> another single quote, which ends the quotation.

…or a newline :)

[And yes, I have encountered filenames with newlines in them. It happened after 
I downloaded a PDF with a non-mnemonic filename, then opened it in Preview, 
copied the title of the paper, and pasted it into the filename in the Finder. 
Unfortunately the line break in the title got pasted in too. I found out later 
because several apps, including Dropbox, were very unhappy with the resulting 
file.]

—Jens



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: Blocks and Methods...

2012-01-28 Thread Mikkel Islay
On 28 Jan 2012, at 20:50, R wrote:

> That is precisely what is giving me the confusion.  If retained the
> received block in a NSMutableArray, the block should stick around (via
> a strong array pointer) for another method.  It only stays around if I
> equate the block to a typedef variable and then put that variable in
> the array.  I'm using ARC.

Blocks are allocated on the stack, unlike other objective-C objects. As a 
consequence, they cannot be retained and are destroyed with the stack. That 
means they must be copied to the heap explicitly to be available beyond the 
scope they were created in, as Ken Thomases wrote.  
With ARC, blocks are normally copied to the heap automatically as required. 
However, adding an object to a container implicitly casts it to id, which is 
not automatically copied with ARC. Hence, you must copy it explicitly.

Mikkel
___

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: Blocks and Methods...

2012-01-28 Thread Ben Kennedy
On 28 Jan 2012, at 8:51 am, Ken Thomases wrote:

> By itself, an array only retains the block.  A block must be explicitly 
> copied if it is to outlive the scope that created it.

If so, isn't that a fundamental semantic change to the meaning of "retain"?  On 
any other object a retain will cause it to outlive the scope that created it.

(Admittedly I still have much reading and head-wrapping to do w/rt the 
mechanics of blocks)

b


___

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

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

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

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


Re: Blocks and Methods...

2012-01-28 Thread R
To all,

Thanks for taking the time to post advice. I think I now
understand much better! --Ron

On Jan 28, 12:50 pm, R  wrote:
> That is precisely what is giving me the confusion.  If retained the
> received block in a NSMutableArray, the block should stick around (via
> a strong array pointer) for another method.  It only stays around if I
> equate the block to a typedef variable and then put that variable in
> the array.  I'm using ARC.
>
> On Jan 28, 9:51 am, Ken Thomases  wrote:
>
>
>
>
>
>
>
>
>
> > On Jan 28, 2012, at 10:40 AM, R wrote:
>
> > > I originally chose to hold the block in an array, but that failed.
> > > I'm still confused over that...
>
> > By itself, an array only retains the block.  A block must be explicitly 
> > copied if it is to outlive the scope that created it.  And, of course, that 
> > copy operation has to be balanced with an eventual release.
>
> > Regards,
> > Ken
>
> > ___
>
> > Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> > This email sent to cocoa-dev-garchive-98...@googlegroups.com
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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

Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread Mikael Wämundson
Hi,

Background:

I have put an NSMutableArray (dataObjectArray) in my class 
DataObjectCollection. I have also made it possible to add objects to 
DataObjectCollection and hence the array by implementing
- (void)addDataObject:(DataObject *)theDataObject
{
NSIndexSet *loneIndex = [NSIndexSet indexSetWithIndex:[[self 
dataObjectArray] count]];
[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
forKey:@"dataObjectArray"];
[dataObjectArray addObject:theDataObject];
[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
forKey:@"dataObjectArray"];
}

In InterfaceBuilder I have put an ArrayController with ContentArray bound to 
"myAppDelegate".theDataObjectCollection.dataObjectArray
I have created bindings between the ArrayController and the columns of an 
NSTableView is

Problem:
Programmatically adding objects to my DataObjectCollection is not observed by 
the ArrayController.

I earlier had the dataObjectArray directly in my AppDelegate and then the key 
value observing worked.

Is there something I need to do with my class DataObjectCollection to make the 
observing work, i.e. to make it KVO compliant?

Thanks!
/Mikael
___

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: How to get the dispatch queue for the current thread's runloop?

2012-01-28 Thread Steve Sisak

At 12:39 PM -0800 1/28/12, Jens Alfke wrote:

On Jan 28, 2012, at 11:35 AM, Steve Sisak wrote:


[self performSelector:@selector(performBlock:)
   withObject:^{
NSLog(@"Done Later");
}   afterDelay:1.0];



Don't you need to copy the block? Or is 
-performSelector:withObject:afterDelay: smart enough to know to call 
-copy instead of -retain on the block?


My understanding is that copying the block happens implicitly when 
you call a function which takes a block as a parameter and doesn't 
return synchronously -- and/or it's the callee's responsibility to 
copy the block if it doesn't call it synchronously.


I would not be surprised if calling retain on a block passed as an 
(id) does this as a side effect. (Sorry, I don't know the exact 
implementation details)


Also, I'm not entirely happy with this solution because it's tied to 
an object when it shouldn't need to be.


Agreed -- just trying to find a way to solve the problem with the API 
available.


So your -doItLater: method only works in the class you declare it 
in, and it has the side effect of keeping the receiver alive until 
the block runs, even if it doesn't need to be (i.e. if the block 
doesn't refer to 'self' at all.)


You (theoretically) could use any object which implements 
-performBlock: as the target -- for instance you could have a 
singleton BlockServer object which implements -performBlock: and use 
that for the target of all requests.


Someone else had a solution that involved adding a category method 
to NSObject to invoke the block, but that seems a bit kludgy too.


That would also work -- and you'd need to worry about collisions in 
Obj-C's flat name space.


I'm still trying to figure this all out and poke around the boundary 
conditions too. I'd love to hear from "someone who 'knows'". :-)


-Steve
___

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: Drag and drop in collectionview

2012-01-28 Thread Luc Van Bogaert
Follow up :
Reading some more, I've found that I could just use a custom representation for 
my objects, containing their index in the model array, to write to the 
pasteboard, and then use that index to perform to move when the dragging 
session is accepted.


On 28 Jan 2012, at 13:35, Luc Van Bogaert wrote:

> 
> I'm implementing drag and drop for a NSCollectionView. The idea is to 
> rearrange objects in the collection by dragging them to another location. 
> Having read the docs for NSCollectionViewDelegate and NSPasteboard, I still 
> have a few general questions about the concept.
> 
> The objects themselves conform to both the NSPasteboardWriting and 
> NSPasteboardReading protocols.
> 
> In the collection view delegate, I have implemented the protocol methods that 
> allow me to initiate a dragging session, and to write the dragged items to 
> the pasteboard. I'm writing the objects as NSData objects, using 
> NSKeyedArchiver.
> 
> I have also implemented the methods to validate and accept the drag 
> operation. In the latter, I am reading the dragged items back from the 
> pasteboard, using readObjectsForClasses:[NSArray arrayWithObject:[MyObject 
> class]]
> 
> It seems that the objects read from the pasteboard are not the same as the 
> original dragged objects; they only represent the same data. This seems 
> natural to me, as I'm using a archiver in the process, but I'm really not 
> sure if I should somehow find a way to retrieve the original objects from the 
> pasteboard. Is this at all possible?. 
> 
> If I should indeed proceed with these different objects that have been read 
> from the pasteboard, I'm wondering how to effectively perform the move in my 
> model array:  should I just insert the objects into my array model object at 
> the desired location and remove the original ones, or should I try to find a 
> way to reference the original objects (using an identifier in the items 
> obtained from the pasteboard) and move those around in my model array?
> 
> If the latter; what kind of identifier could be used for this? Some kind of 
> ivar with a unique value? How to generate something like this?

-- 
Luc Van Bogaert

___

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: Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread Keary Suska
On Jan 28, 2012, at 2:28 PM, Mikael Wämundson wrote:

> Is there something I need to do with my class DataObjectCollection to make 
> the observing work, i.e. to make it KVO compliant?

Implement and use collection accessor methods:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/AccessorConventions.html#//apple_ref/doc/uid/20002174-178830-BAJEDEFB

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

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

Re: Recently Opened in Doc

2012-01-28 Thread James Merkel
On 28 Jan 2012 08:46:48 -0800 Quincey Morris wrote:

> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
> 
>> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
>> the user.   I control the file name.  
>> 
>> What I'd like to do is just capture the menu items before they're displayed 
>> and change the menu titles into something relevant to the user.  In the 
>> scheme of things it's a minor way to access the info in my app so if I could 
>> eliminate them that would be OK too.  Changing the filename is not an option 
>> at this point.
> 
> It seems to me you can subclass NSDocumentController, then override 
> 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
> filename off the "Open Recent" submenu, the "Recent Items" item on the Apple 
> menu, and the dock menu. Then you should be able to delete the "Open Recent" 
> item itself, and be left with no traces of recent items from your app.
> 
> If you wanted to go the extra mile, you could create your own recent-items 
> implementation, driven from your 'noteNewRecentDocument:' override, and using 
> the 'applicationDockMenu:' application delegate method, with whatever 
> document identifiers you want.


My app is not document based so I call noteNewRecentDocumentURL: directly to 
add the filename to the Open Recent submenu list.
If I comment that line of code out then the document is not added to the list 
as expected. Also, the Dock menu "Show Recents" shows nothing and the filename 
is not added to  the Dock menu list. 

So yes, noteNewRecentDocument; (which calls noteNewRecentDocumentURL: ) is the 
key to the whole thing.

Jim Merkel
___

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: Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread Quincey Morris
On Jan 28, 2012, at 13:28 , Mikael Wämundson wrote:

> I have put an NSMutableArray (dataObjectArray) in my class 
> DataObjectCollection. I have also made it possible to add objects to 
> DataObjectCollection and hence the array by implementing
> - (void)addDataObject:(DataObject *)theDataObject
> {
>NSIndexSet *loneIndex = [NSIndexSet indexSetWithIndex:[[self 
> dataObjectArray] count]];
>[self willChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> forKey:@"dataObjectArray"];
>[dataObjectArray addObject:theDataObject];
>[self didChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> forKey:@"dataObjectArray"];
> }
> 
> In InterfaceBuilder I have put an ArrayController with ContentArray bound to 
> "myAppDelegate".theDataObjectCollection.dataObjectArray
> I have created bindings between the ArrayController and the columns of an 
> NSTableView is
> 
> Problem:
> Programmatically adding objects to my DataObjectCollection is not observed by 
> the ArrayController.
> 
> I earlier had the dataObjectArray directly in my AppDelegate and then the key 
> value observing worked.
> 
> Is there something I need to do with my class DataObjectCollection to make 
> the observing work, i.e. to make it KVO compliant?

Well, you're doing this the wrong way. Here are the steps, starting over from 
the beginning:

1. Add a NSMutableArray* 'dataObjectArray' instance variable to your 
DataObjectCollection class. This is part of the private implementation, and 
shouldn't be visible to the clients of the class. To make sure of this, 
override '+accessesInstanceVariables' in DataObjectCollection to return NO.

2. Decide on a client-visible (public) property name for your indexed 
collection property. Use a plural noun, such as "dataObjects". Choosing a name 
different from the instance variable name emphasizes the difference between the 
property (public API) and the variable (private backing store).

3. Define a *readonly* "dataObjects" @property for DataObjectCollection, with 
type 'NSArray*' (NOT 'NSMutableArray*'), and implement the getter to return 
'dataObjectArray'.

4. Implement the basic indexed accessor methods:

-insertObject:inDataObjectsAtIndex:
-removeObjectFromDataObjectsAtIndex:

5a. If you want a convenience method like 'addDataObject:', implement it like 
this:

- (void) addDataObject: (DataObject*) dataObject {
[self insertObject: dataObject inDataObjectsAtIndex: 
self.dataObjects.count];
}

5b. I happen to prefer not to create such convenience methods (because you 
often end up creating lots of them to parallel the NSArray methods). I usually 
create an auxiliary method:

@property (readonly) NSMutableArray* mutableDataObject;

implemented like this:

- (NSMutableArray*) mutableDataObjects {
return [self mutableArrayValueForKey: @"dataObjects"];
}

so you can add an object like this:

[dataObjectCollection.mutableDataObjects addObject];

6. Bind your array controller's content to 
myAppDelegate.theDataObjectCollection.dataObjects.

If you follow these steps, your array property is 100% KVO compliance, *and* it 
cannot be tampered with non-KVO-compliantly from outside, either 
programmatically or via KVC.

(All code typed in Mail, so apologies for any typos and omissions.)


___

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: afterDelay not working?

2012-01-28 Thread GW Rodriguez
Just an update:
Thanks for the help guys.  I found out I wasn't running on the current loop and 
didn't realize that time based methods and classes wont work.  My flash method 
was being called in the background.

Thanks
GW
___

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

Is NSRuleEditor worth the learning curve?

2012-01-28 Thread Erik Stainsby
Hello list folks,

I'm struggling with the abstraction and sketchy documentation that surround 
NSRuleEditor. I feel a need to know that the effort is worthwhile, versus 
cobbling together something in a table or outline view instead.

The domain I am working in really fits well within the structured rule editor 
model. I have many lists of finite scope which have an inherent hierarchy and 
each choice made implies filters for the remaining options.

But I am really confused by the highly flexible model of the rule editor. The 
toughest part right now is that I am unable to see how the NSRuleEditor 
instance populates a given row, based on having received either a stringValue, 
a menuItem or a control/view.  Where in all of this have I the opportunity to 
establish the layout and orientation of the various widgets for a given row?  

One example I have found (NibBasedSpotlightSearcher.xcodeproj - circa 2006) 
presents a window in the nib which holds clusters of related controls in a 
single view. I'm doing the gasping guppy trying to see where in the code those 
individual controls are addressed, loaded and applied. 

Has anyone got a nakedly simple example of a minimalist use of the NSRuleEditor 
they could point me to? 

Cheers,
Erik
___

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: Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread R
Mikael,

I think all you need is:

- (void)addDataObject:(DataObject *)theDataObject
{
dataObjectArrayKVC=[self
mutableArrayValueForKey:@"dataObjectArray"];
[dataObjectArrayKVC addObject:theDataObject];
}

dataObjectArrayKVC is a proxy for dataObjectArray.  Objects added/
removed to/from dataObjectArrayKVC will be sent directly to
dataObjectArray and your array controller will be alerted.  This is
the same as feeding your objects through your array controller.







On Jan 28, 2:28 pm, Mikael Wämundson  wrote:
> Hi,
>
> Background:
>
> I have put an NSMutableArray (dataObjectArray) in my class 
> DataObjectCollection. I have also made it possible to add objects to 
> DataObjectCollection and hence the array by implementing
> - (void)addDataObject:(DataObject *)theDataObject
> {
>     NSIndexSet *loneIndex = [NSIndexSet indexSetWithIndex:[[self 
> dataObjectArray] count]];
>     [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> forKey:@"dataObjectArray"];
>     [dataObjectArray addObject:theDataObject];
>     [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> forKey:@"dataObjectArray"];
>
> }
>
> In InterfaceBuilder I have put an ArrayController with ContentArray bound to 
> "myAppDelegate".theDataObjectCollection.dataObjectArray
> I have created bindings between the ArrayController and the columns of an 
> NSTableView is
>
> Problem:
> Programmatically adding objects to my DataObjectCollection is not observed by 
> the ArrayController.
>
> I earlier had the dataObjectArray directly in my AppDelegate and then the key 
> value observing worked.
>
> Is there something I need to do with my class DataObjectCollection to make 
> the observing work, i.e. to make it KVO compliant?
>
> Thanks!
> /Mikael
> ___
>
> Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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

Re: Key Value Observing of NSMutableArray inside an object

2012-01-28 Thread R
More appropriate:

- (void)addDataObject:(DataObject *)theDataObject
{
NSMutableArray *dataObjectArrayKVC=[self
mutableArrayValueForKey:@"dataObjectArray"];
[dataObjectArrayKVC addObject:theDataObject];
}

On Jan 28, 8:19 pm, R  wrote:
> Mikael,
>
> I think all you need is:
>
> - (void)addDataObject:(DataObject *)theDataObject
> {
>     dataObjectArrayKVC=[self
> mutableArrayValueForKey:@"dataObjectArray"];
>     [dataObjectArrayKVC addObject:theDataObject];
>
> }
>
> dataObjectArrayKVC is a proxy for dataObjectArray.  Objects added/
> removed to/from dataObjectArrayKVC will be sent directly to
> dataObjectArray and your array controller will be alerted.  This is
> the same as feeding your objects through your array controller.
>
> On Jan 28, 2:28 pm, Mikael Wämundson  wrote:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > Background:
>
> > I have put an NSMutableArray (dataObjectArray) in my class 
> > DataObjectCollection. I have also made it possible to add objects to 
> > DataObjectCollection and hence the array by implementing
> > - (void)addDataObject:(DataObject *)theDataObject
> > {
> >     NSIndexSet *loneIndex = [NSIndexSet indexSetWithIndex:[[self 
> > dataObjectArray] count]];
> >     [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> > forKey:@"dataObjectArray"];
> >     [dataObjectArray addObject:theDataObject];
> >     [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:loneIndex 
> > forKey:@"dataObjectArray"];
>
> > }
>
> > In InterfaceBuilder I have put an ArrayController with ContentArray bound 
> > to "myAppDelegate".theDataObjectCollection.dataObjectArray
> > I have created bindings between the ArrayController and the columns of an 
> > NSTableView is
>
> > Problem:
> > Programmatically adding objects to my DataObjectCollection is not observed 
> > by the ArrayController.
>
> > I earlier had the dataObjectArray directly in my AppDelegate and then the 
> > key value observing worked.
>
> > Is there something I need to do with my class DataObjectCollection to make 
> > the observing work, i.e. to make it KVO compliant?
>
> > Thanks!
> > /Mikael
> > ___
>
> > Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> > This email sent to cocoa-dev-garchive-98...@googlegroups.com
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@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/cocoa-dev-garchive-...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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

getting a nsurl file size

2012-01-28 Thread Eric Smith
All,

I'm trying to determine the size of a file on a server.  If I send the 
following message to an NSURL named "path", I get:

[path getResourceValue:&value forKey:@"content-length" error:&error];

value comes back nil.  If I send:

value = [path propertyForKey:@"content-length"];

which is deprecated, I get the correct file size.  What is the proper way to 
get a file size for a file specified with a web address?

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

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


Re: CoreData, and design of document model

2012-01-28 Thread Jerry Krinock

On 2012 Jan 27, at 01:07, David Mirabito wrote:

> Right now am working with the notion that when the document is created I add 
> one System managedObject if one doesnt exist, and then never add another in 
> the document's lifetime. Right now in MyDocument's -didLoadNib whilst 
> experimenting but maybe later I'll find a better delegate method for that.

I suppose -didLoadNib would work, but in Apple's DepartmentAndEmployees sample 
code, DepartmentAndEmployees, they insert their document's 'Department' 
singular object in -[NSDocument initWithType:error:].  That is where I do it 
and would seem to be more robust.  I've never had any trouble with it.


___

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: getting a nsurl file size

2012-01-28 Thread Ken Thomases
On Jan 28, 2012, at 11:53 PM, Eric Smith wrote:

> I'm trying to determine the size of a file on a server.  If I send the 
> following message to an NSURL named "path", I get:
> 
> [path getResourceValue:&value forKey:@"content-length" error:&error];
> 
> value comes back nil.

Two things:

* Did the method return TRUE or FALSE?  If FALSE, what error did you get back?

* The keys that are valid for that method are those listed in the NSURL 
documentation.  They may bear no relation to HTTP response header fields.  So, 
I see no reason to believe that "content-length" is a valid key.  Have you 
tried NSURLFileSizeKey?


> If I send:
> 
> value = [path propertyForKey:@"content-length"];
> 
> which is deprecated, I get the correct file size.

That may be fluke.

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

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


Re: getting a nsurl file size

2012-01-28 Thread Charles Srstka
On Jan 29, 2012, at 12:21 AM, Ken Thomases wrote:

> * The keys that are valid for that method are those listed in the NSURL 
> documentation.  They may bear no relation to HTTP response header fields.  
> So, I see no reason to believe that "content-length" is a valid key.  Have 
> you tried NSURLFileSizeKey?
> 
> 
>> If I send:
>> 
>> value = [path propertyForKey:@"content-length"];
>> 
>> which is deprecated, I get the correct file size.
> 
> That may be fluke.

NSURL’s now deprecated -propertyForKey: method existed long before any of those 
NSURL*Key constants did, so it’s difficult to imagine what could have been 
passed to it other than HTTP response header field names.

At any rate, this should do what you want:

NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];

req.HTTPMethod = @"HEAD";
[req setValue:@"" forHTTPHeaderField:@"Accept-Encoding"];

void (^completionBlock)(NSURLResponse *resp, NSData *data, NSError *error) = 
^(NSURLResponse *resp, NSData *data, NSError *error) {
if([resp isKindOfClass:[NSHTTPURLResponse class]]) {
NSLog(@"length is %@", [((NSHTTPURLResponse *)resp).allHeaderFields 
objectForKey:@"Content-Length"]);
}
};

[NSURLConnection sendAsynchronousRequest:req queue:[NSOperationQueue mainQueue] 
completionHandler:completionBlock];

Charles
___

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

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

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

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

How to parse multipart/form-data?

2012-01-28 Thread Kai Cao
Hi,

I'm using CocoaHTTPServer to upload files from computer to iOS devices. But the 
result NSData received from the browser is multipart form data, which is really 
hard to parse manually. I know I can write a parser from scratch, however, it's 
time consuming and bug prone. I'm wondering wether there's a sophisticated 
library/framework for this. Any help would be appreciated. Thanks in advance. 

Best regards,

Kai
nonamel...@me.com

sent from Mobile Me
___

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