Apple Sample Code WWDC 2010 session 114

2013-11-08 Thread 2551
Hi folks

I’m desperately trying to track down some Apple sample code that was featured 
at the WWDC 2010, related to session 114, entitle d ‘Advanced Cocoa Text Tips 
and Tricks.

The video is available on Apple’s Developer forum and iTunes University, but 
the sample project used in the video is not available on the site. Nor has 
Google returned me any successful hits.

I think the actual Xcodeproj file is called ‘WWDC_2010_114’ and includes a 
number of classes I’m desperate to get hold of (I’ve tried recreating as much 
as I can from the video, but alas I’m not skilled enough in Cocoa yet and I 
can’t figure out the bits I’m missing). The code pertains to implementing 
editor features similar to those seen in Xcode like text folding, line numbers 
and in-line contextual menus.

I’ve seen other code for line numbers elsewhere (Noodlesoft’s stuff here: 
https://github.com/MrNoodle/NoodleKit) but this is not sufficient for what I’m 
after. 

I’d really appreciate it if anyone could provide a link to where the Apple 
sample code might be available, or (long shot!!!) a copy if you happened to 
have been an attendee at WWDC 2010 and downloaded yourself!
 



Phil



___

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

NSCustomImageRep and NSImage setSize

2013-11-08 Thread Mathew Eis
Hello List,

I am trying to get an NSCustomImageRep to properly “react” (e.g. redraw) after 
a NSImage setSize call.

I am writing a NSCustomImageRep class for a resolution independent image format 
(e.g. like NSPDFImageRep and NSEPSImageRep). However, I can’t get it to 
properly account when the size is adjusted through NSImage setSize. So long as 
I call setSize before the first time the image is drawn, everything works 
perfectly, but any subsequent calls to setSize don’t seem to cause my imageRep 
to redraw for the new size.

A call to NSImage recache doesn’t seem to have any effect, and I am especially 
confused because the documentation for NSImage setCacheMode states that 
“NSPDFImageRep and NSEPSImageRep classes use theNSImageCacheAlways mode” How 
can the image reps be always cached and yet respond appropriately (e.g. 
maintain full resolution) when NSImage setSize is called?

Thanks in advance!

-Mathew Eis
___

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

Resolving a file reference from the iTunes plist

2013-11-08 Thread Charles Constant
Hello gang,

I noticed upon upgrading to iTunes 11, that iTunes has changed the manner
in which it remembers the path to its library. This is a bummer, as I wrote
myself a script to juggle my multiple iTunes Libraries, and it does''t work
anymore.

In previous versions, iTunes stored its library location as an 'alias ref',
in the iTunes plist, with the key 'alis:1:iTunes Library Location'. In the
new version, iTunes 11, it stores the location with the key
'RDoc:132:Documents' using some format is a mystery to me.

Is it using the 'bookmark data' format? I gather Apple has positioned
'bookmark data' as a replacement for old-style file aliases.

I've had no success interpreting the data as 'bookmark data' so far. If
it's 'bookmark data' I ought to be able to read it with a Python script
using
NSURL.URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_
 but the result is always null. This makes me suspect it's not bookmark
data after all.

Does anyone here have any idea as to what the mystery format is?

Thanks,

Charles

PS: I've posted a longer explanation here, too:
http://stackoverflow.com/questions/19663069/how-to-switch-to-a-new-itunes-library-location-programmatically
___

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

NSScrollView and autolayout

2013-11-08 Thread Jozef Dransfield
I have seen a previous discussion about this topic in the archives but I seem 
to be having a new problem related to Mavericks.

I have a View Based NSTableView set as the document view of an NSScrollView 
with everything using auto layout.

After upgrading to mavericks my scrollview no longer scrolls the body, it seems 
to know their is additional content waiting to be displayed, as when you resize 
the window the correct scroll bar appears briefly, but as soon as you stop 
resizing, the scrollview clips the tableview to the size of the scroll view’s 
container.

I used one of my dev program support tickets for help, but was informed it was 
a known issue with no work around, I am hoping someone here might have 
experienced this or know some way to get it to work?



___

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: Mutually exclusive item filtering-comparing

2013-11-08 Thread Joseph Dixon
Let’s assume the data source sorts items with one handed weapons at the top of 
the list and two handed weapons at the bottom. Also assume the data source 
knows the row index of the first two handed weapon. Now we can test for one or 
two handed weapons by comparing the row index to that of the first two handed 
weapon. If a user selects a one handed weapon in the left hand, then change 
tableView:numberOfRowsInSection: for the right hand table to show only one 
handed weapons. If the user has chosen a two handed weapon in the left hand, 
then change tableView:numberOfRowsInSecton: for the right hand table to show 
zero. This can be done without any looping at all.

Does this help?

-jwd
// Joseph W. Dixon


On Nov 5, 2013, at 12:17 PM, Chris Paveglio chris_paveg...@yahoo.com wrote:

 What is the most efficient way to compare a list of mutually exclusive items? 
 I know this isn't exactly Cocoa/iOS specific. I have a table that needs to 
 disable certain rows based on what other rows are selected.
 
 I have several objects, let's say weapons in a game. Such as a bow and 
 arrow, a rifle, a bazooka.
 A character can use any of the objects, but some can't be used together. A 
 bazooka is too big and requires 2 hands to carry so you can't select both a 
 bazooka and rifle at the same time. You can select bow  arrow and rifle, but 
 if you select both of those, you can't take the bazooka too. I hope you get 
 the idea.
 
 My exclusions array has many simple objects. Each object has 3 ivars- 
 (int)itemID1, (int)itemID2, (string)isMutuallyExclusive (not my design but 
 could be changed if there is a better way).
 
 The idea I have is whenever a row is selected, I will take the itemID of that 
 item, then iterate with every other itemID in the table- then I do an 
 iteration on every object in the exclusions array. If the selected row itemID 
 is in the exclusion object, and current row itemID being compared are both in 
 the exclusion object, I can get it's exclusion (non-exclusive items won't be 
 in the list).
 So, repeat with 100 items in the table, each table row comparing against the 
 exclusion list which has over 100 entries. It could result in up to 10,000 
 comparisons getting tested until the exclusion is found or exhausted.
 
 It seems extremely process intensive. Is there a better way, or some basic 
 concept I might be missing?
 
 Thanks,
 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/jwdixon%40gmail.com
 
 This email sent to jwdi...@gmail.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: NSCustomImageRep and NSImage setSize

2013-11-08 Thread Graham Cox

On 30 Oct 2013, at 5:14 am, Mathew Eis mat...@eisbox.net wrote:

 I am trying to get an NSCustomImageRep to properly “react” (e.g. redraw) 
 after a NSImage setSize call.


My understanding is that the size property of an image is not directly related 
to the sizes of the reps within it. Initially, the reps that the image 
generates itself (for caching, say) are based on the image size, scaled 
according to the desired resolution of the cache, which is 1x for standard 
screens, 2x for retina screens. Otherwise the ratio between a rep’s size and 
the image size defines the resolution of the image, and therefore how it is to 
be drawn, but there’s no reason that this size change would affect any reps 
within the image other than the private ones that NSImage maintains for caching.

I assume that NSImage has its own way of identifying which reps are part of its 
private cache, but any reps that you add using -addRepresentation: are NOT part 
of its private cache. AFAICS, there’s no way to force NSImage to use an 
externally added rep as an internal cache. I don’t really see why you’d want to 
do that anyway, or why you need to redraw your rep if the NSImage size changes 
- especially if it’s resolution independent. When the NSImage is drawn, its 
size tells you how to scale your rep to suit, but it doesn’t affect the content 
of your rep at all.

—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: Apple Sample Code WWDC 2010 session 114

2013-11-08 Thread 2551
I have now been fortunate to receive a copy of the code from a list member. I’m 
also grateful to several others that also kindly offered me the code. 

I’d been banging my head on the desk over this problem for nearly a week. It 
took 28 minutes for the list to answer my wishes. It took me about ten minutes 
to scan the code and see where I’d been going wrong. You folks are awesome! :)) 

Thanks again to all who responded. :)


Best

Phil



On 5 Nov 2013, at 19:40, 2551 2551p...@gmail.com wrote:

 Hi folks
 
 I’m desperately trying to track down some Apple sample code that was featured 
 at the WWDC 2010, related to session 114, entitle d ‘Advanced Cocoa Text Tips 
 and Tricks.
 


___

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: SKIndexAddDocument crashing

2013-11-08 Thread Mark Wright
FWIW it crashes on mine too (not too surprising, same Xcode and OS).

It doesn’t crash if you replace the crashing line with:

SKIndexAddDocumentWithText(searchIndexFile, doc, NULL, false);

I don’t know if that’s any use to you (never used the framework).

I think it’s failing because it’s not recognising the file type as text (see 
the docs - option click the function).

It doesn’t crash if you supply the mimeTypeHint:

SKIndexAddDocument( searchIndexFile, doc, (__bridge CFStringRef)@txt, 
false );

…




On 07 Nov 2013, at 12:18, Eric Gorr mail...@ericgorr.net wrote:

 The values are all valid. There is not much more to the sample test project 
 then the code I posted if you wanted to check this out yourself. The sample 
 project is just the default cocoa app. At least one other person did and saw 
 the same behavior 
 
 Sent from my iPhone
 
 On Nov 7, 2013, at 12:12 AM, Jerry Krinock je...@ieee.org wrote:
 
 Forgive me if you’ve already done this, Eric, but you didn’t say if you did 
 this…
 
 When a function in an SDK crashes, the first thing you should do is check 
 the parameters you’re feeding it.  In this case, are your local variables 
 searchIndexFile and doc valid?  At least, not NULL?
 
 
 ___
 
 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/mailist%40ericgorr.net
 
 This email sent to mail...@ericgorr.net
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/blue.buconero%40virgin.net
 
 This email sent to blue.bucon...@virgin.net

___

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

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

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

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

Re: Why IBOutlet don't work under NSTableCellView?

2013-11-08 Thread Bryan Vines
Hello,

I'm just beginning to explore view-based tableviews myself.

When I build and run this project, Xcode shows two warnings of interest:
  - Outlet 'ref' of 'My Image' is connected to 'My Reference,' an invalid 
destination (Objects inside view based table views may only be connected to the 
table view's delegate.)
  - Outlet 'delegate' of 'Text Field - Table View Cell' is connected to 'My 
Reference,' an invalid destination (Objects inside view based table views may 
only be connected to the table view's delegate.)

The linked tutorial, below, has helped me a great deal with regard to 
view-based tableviews.


http://gentlebytes.com/blog/2011/08/30/view-based-table-views-in-lion-part-1-of-2/

Hope that helps!
--
Bryan Vines

On Oct 30, 2013, at 4:49 AM, 周章林 zhanglin.z...@gmail.com wrote:

 Hi, all,
 
 I am trying to use NSTableView in our project, and I customized class which
 inherit NSImageView, that's MyImage. In MyImage, I declared a property
 (IBOutlet) ref. Then I insert this customized view to NSTableCellView in
 Interface Builder, and I connect ref with a customized
 class-MyReference object . The problem is ref is always nil in the
 MyImage instance.
 
 I have tried to set breakpoint in the -[MyImage initWithFrame:] and
 -[MyImage setRef:], and found the former method is invoked 2 times, but the
 later only once. Can anybody explain why this happen? And I want to make
 the ref outlet work, what should I do?
 
 I also attached the sample project in attachment.

___

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: Why IBOutlet don't work under NSTableCellView?

2013-11-08 Thread Charles Srstka
On Oct 30, 2013, at 4:49 AM, 周章林 zhanglin.z...@gmail.com wrote:

 Hi, all,
 
 I am trying to use NSTableView in our project, and I customized class which
 inherit NSImageView, that's MyImage. In MyImage, I declared a property
 (IBOutlet) ref. Then I insert this customized view to NSTableCellView in
 Interface Builder, and I connect ref with a customized
 class-MyReference object . The problem is ref is always nil in the
 MyImage instance.
 
 I have tried to set breakpoint in the -[MyImage initWithFrame:] and
 -[MyImage setRef:], and found the former method is invoked 2 times, but the
 later only once. Can anybody explain why this happen? And I want to make
 the ref outlet work, what should I do?
 
 I also attached the sample project in attachment.
 tabletest.zip___
 
 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/cocoadev%40charlessoft.com
 
 This email sent to cocoa...@charlessoft.com

Views inside view-based table views can't have references, whether through 
outlets or bindings, with anything but the table view's delegate. If you give 
your object an outlet to the table's delegate, and then give the table's 
delegate an outlet to your ref object, then that will work.

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

Re: Why IBOutlet don't work under NSTableCellView?

2013-11-08 Thread Kyle Sluder
On Nov 8, 2013, at 8:06 AM, Charles Srstka cocoa...@charlessoft.com wrote:

 
 Views inside view-based table views can't have references, whether through 
 outlets or bindings, with anything but the table view's delegate. If you give 
 your object an outlet to the table's delegate, and then give the table's 
 delegate an outlet to your ref object, then that will work.

If you think about it, this makes some sense, until you think abut it some 
more. :)

By default, the File's Owner when loading a table view cell or row view is the 
table view's delegate. So connections to that object will be able to be 
restored by the nib loading machinery. It's just really confusing that IB shows 
you all the objects from the top-level nib while editing the embedded nib—it 
would be much better if the Object Hierarchy were replaced with the contents of 
the embedded nib. (That would also make it possible to add top-level objects 
like object controllers to the embedded nib.)

Furthermore, the delegate being File's Owner is a *default*, not a *guarantee.* 
If the sidebar changed to accurately represent the embedded nib, one could 
connect to the embedded nib's File's Owner proxy and it would work with 
whatever object is passed to -makeViewWithIdentifier:owner:.

I've filed this in the past as rdar://problem/9583635. Feel free to dupe :)

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

How to tell if a file is writable in sandboxed mode?

2013-11-08 Thread Oleg Krupnov
I’m trying to use -[NSFileManager isWritableFileAtPath:], but when it
returns NO, I’d like to know if it’s “no” because the app simply
doesn’t have access to this path due to sandboxing, or is it “no
because the file doesn’t have write permissions set in its file
attributes?

Is there a way to discriminate these two cases?

Or more generally, is there a way to tell that an app does or does not
have access to some file because of *sandboxing* (as opposed to file
attributes)?

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: NSCustomImageRep and NSImage setSize

2013-11-08 Thread Graham Cox
Hi Mathew,

I think you need to set it to NSImageCacheNever. This turns off all of the 
internal caching mechanism, so your rep, if it’s the only rep in the image, 
will always be the one to draw. It’ll only be as pixellated as your 
implementation allows, which should be not at all, right?

—Graham


On 8 Nov 2013, at 4:46 pm, Mathew Eis mat...@eisbox.net wrote:

 Hi Graham,
 
 Thanks for the reply… That’s more or less the crux of the issue; I can’t 
 figure out how to make the rep resolution independent”.
 
 If I draw it once at, say, 100x100, then I draw it again at 200x200, the 
 second will be pixellated because the NSImage is using a cached (bitmap?) 
 copy of it…   If I drew it the first time at 200x200, the cached version has 
 the correct resolution - but it isn’t truly resolution independent because it 
 still seems to be caching a bitmap somewhere.
 
 Regards,
 
 -Mathew Eis


___

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 mouse clicks when the main loop is busy

2013-11-08 Thread Graham Cox
Hi all,

I have the need to display a progress dialog while I open a huge file. The file 
may be opened on the main thread, and the progress notifications are sent 
synchronously.

Since the main thread is blocked doing the file opening work, I force the 
window to redraw by directly calling its -displayIfNeeded method, and that 
indeed works as expected. However, I would like to be able to click a ‘Cancel’ 
button in this window. So, I thought I could just allow normal mouse click 
events to be handled by calling the -runUntilDate: method of the main runloop. 
By using a date value of -distantPast, this method shouldn’t sleep and so this 
occasional tickle of the runloop doesn’t slow down the file opening.

Unfortunately, it doesn’t work: the mouse clicks are not received and/or 
processed (I’m not sure which). The Cancel button is just an ordinary button, 
and if the dialog is displayed as a window without doing any work, I can click 
the button as normal.

I’ve also tried running the runloop as above, then immediately trying to handle 
any events for the window directly (which seems unnecessary, but I tried it 
anyway). That doesn’t help.

What’s the proper way to do this? I *can* open the file on another thread and 
let the main thread run normally, and that’s fine, but I do need a solution 
that works for when the file is opened on the main thread.

—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: Getting mouse clicks when the main loop is busy

2013-11-08 Thread Kyle Sluder
 On Nov 8, 2013, at 9:16 AM, Graham Cox graham@bigpond.com wrote:
 
 Unfortunately, it doesn’t work: the mouse clicks are not received and/or 
 processed (I’m not sure which). The Cancel button is just an ordinary button, 
 and if the dialog is displayed as a window without doing any work, I can 
 click the button as normal.

It’s -[NSApplication run] that is responsible for dispatching events, not 
NSRunLoop. It sounds like you want to be pumping the event loop yourself. Try 
using -sendEvent: and -nextEventMatchingMask:untilDate:nil inMode: dequeue:YES.

 
 I’ve also tried running the runloop as above, then immediately trying to 
 handle any events for the window directly (which seems unnecessary, but I 
 tried it anyway). That doesn’t help.

I don't know if this is the same as what I described above. You shouldn’t have 
to run the runloop yourself; -nextEventMatchingMask: will run it for you.

--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: Getting mouse clicks when the main loop is busy

2013-11-08 Thread Fritz Anderson
On 8 Nov 2013, at 11:16 AM, Graham Cox graham@bigpond.com wrote:

 What’s the proper way to do this? I *can* open the file on another thread and 
 let the main thread run normally, and that’s fine, but I do need a solution 
 that works for when the file is opened on the main thread.

With the humblest intention in the world, and admitting I don't know your use 
case…

You seem to suggest that opening the file on the main thread might be 
unavoidable. Is this because the process of identifying, opening, reading, 
processing, and closing the file might be confined to a third-party library 
that isn't thread-safe? I can't imagine another way you couldn't pass a path, 
URL, or file descriptor into a thread. (I have a limited imagination.)

If you're not in that situation, I suggest doing whatever you prudently can to 
load the file on a background thread every time. It factors your app by cutting 
your code paths in half, and you don't have to rely on cooperative multitasking 
to keep up a responsive UI. If you're just filling a buffer or interpreting a 
stream from a file, and don't need to display partial results other than 
progress, you're in about the least-hard thread-confinement situation you can 
have.

That's my esthetic. There are excellent developers who use a cooperative 
runloop with good results.

— F


___

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: Apple Sample Code WWDC 2010 session 114 (2551)

2013-11-08 Thread Brian Clark

On Nov 8, 2013, at 11:18 AM, 2551 2551p...@gmail.com wrote:

 I have now been fortunate to receive a copy of the code from a list member. 
 I’m also grateful to several others that also kindly offered me the code.

I'm sure there are others interested in this code, if not now than for future 
reference. Is it available for download anywhere? 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: Getting mouse clicks when the main loop is busy

2013-11-08 Thread Graham Cox
Hi Fritz, Kyle.

First off, Kyle is quite right, it’s the -nextEventMatchingMask: I needed. In 
fact that’s where I started, but didn’t quite get all the pieces lined up. I 
was only fetching mouse down events, and passing them directly to the button 
for tracking. That worked, except that the highlighting wasn’t visible, because 
nothing was given a chance to update the graphics while the button did its 
tracking. So instead, asking for all events and letting -sendEvent: process 
them, I had good responsiveness and graphics updates.

There were two problems with that approach. First, it was too broad, in that 
clicks in other windows were being processed which I don’t want - I only need 
the progress window’s clicks. But If you use the NSWindow variants of the NSApp 
methods for fetching and dispatching events, first you find the documentation 
says that you should “never invoke” -[NSWindow sendEvent:] even though it 
worked more or less fine, but I also found that clicks in other windows were 
not quite being rejected as I expected, and events seem to queue up gradually 
killing performance as my file is opened.

So, finally I realised that what I really needed was a modal session for the 
progress, which dequeues events destined for other windows and beeps on clicks 
that do not target the modal window. Using runModalSession: I get everything I 
wanted.


The more philosophical question is why do this on the main thread?

Part of it has to do with keeping my options open - I can use a thread or not. 
The situation is in fact handling the file read for NSDocument, so setting 
+canConcurrentlyReadDocumentsOfType: selects whether a thread is used or not. 
However, I’ve discovered that if you do allow it to use a thread, there are two 
unpleasant usability side effects.

If the file is small and can be read quickly, it really doesn’t make much 
difference either way whether it’s threaded or not. But if it’s a large file, 
there may be some time (even minutes) between clicking ‘Open’ in the 
NSOpenPanel and the document opening its window. During that time, there is no 
feedback whatsoever that anything is happening. It acts, for all intents and 
purposes, as if the ‘Open’ click was ignored. Because the app remains 
responsive, you might try again, and now you have the same file being opened on 
two threads (unless something takes care to prevent this with NSDocument, I 
haven’t investigated). The user simply thinks your app is broken. But then, 
bang, the document windows open unexpectedly at some indeterminate future time. 
It was trying to mitigate this terrible lack of feedback that motivated having 
a progress indicator for file opening. But in fact, simply not opening them 
concurrently and just blocking the main thread while they open is much better 
from the user’s point of view - they can tell that something is happening, even 
if they have to wait until it’s done. The app may be unresponsive, but at least 
it doesn’t seem broken. And having the app responsive while a file is opening 
is of minimal benefit it seems to me - the user wanted to work on another file, 
that’s why they opened it - so the time waiting for this file to open on a 
thread is not time that is likely to be fruitfully spent editing some other 
file.

The other reason, which is more surprising, is that my assumption was that the 
Versions browser would work better if the documents were opened on a background 
thread. The reality is, it works far worse. It seems to ask the app to start 
decoding as many files as it can when you enter Versions, and pretty soon my 
machine is blowing its fans and is so stuttery it’s impossible to use. When the 
document is opening its files on the main thread, this doesn’t happen - it 
seems Versions is happy enough to let it open one file at a time and only goes 
back to the app to decode a file as it is displayed. This appears to be a much 
lower workload, as my laptop stays cool and Versions remains nice and 
responsive. (Incidentally it would have been a lot nicer if Versions could have 
worked by asking your app to return some sort of image representing the file or 
window content rather than getting it to decode the actual file. The Versions 
browser is totally at the mercy of your app, and sometimes it’s simply not 
possible to decode a file in a short time. Grabbing a screenshot of the window 
which Versions could cache would be far more deterministic - it would only then 
need to ask your app to open an actual file when Versions was closed with a 
different document choice).

All in all, we found that turning OFF concurrent document opening was a better 
user experience overall.

And that is why the progress dialog needs to integrate with the main thread.

—Graham


On 8 Nov 2013, at 7:04 pm, Fritz Anderson fri...@manoverboard.org wrote:

 On 8 Nov 2013, at 11:16 AM, Graham Cox graham@bigpond.com wrote:
 
 What’s the proper way to do this? I *can* open the file on another thread 
 and 

Re: Resolving a file reference from the iTunes plist

2013-11-08 Thread Jens Alfke

On Nov 2, 2013, at 10:39 AM, Charles Constant charlesism@gmail.com wrote:

 In previous versions, iTunes stored its library location as an 'alias ref',
 in the iTunes plist, with the key 'alis:1:iTunes Library Location'. In the
 new version, iTunes 11, it stores the location with the key
 'RDoc:132:Documents' using some format is a mystery to me.

Are you looking for the library folder or the media folder? The library is 
found by looking in the prefs/defaults domain “com.apple.iApps” for a key 
“iTunesRecentDatabases” whose value is an array of URLs; the first URL points 
to the current XML database file, and the parent directory is the library 
directory.

This is independent of the location of the media folder, i.e. where all the 
audio files go. I’m not sure how you find that (although of course the XML file 
points to the full URLs of all the audio files, so generally you don’t need to 
know.)

—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

CGAffineTransformScale does not send it's scale when using UIDynamicAnimator

2013-11-08 Thread colo0logo
I am simply trying to understand the way to use updateItemUsingCurrentState
and how to send a scaled UIView or UIImageView to the animator so I can
have a large box and small box for physics tests on viewDidLoad. I want to
learn how to pass it this info so I can dynamically change the size later
in other events.

I saw a post about updateItemUsingCurrentState from a stackoverflow
question and within Apples docs for it, but I can't find a hard example
using scale with it. The docs at Apple say it updates the rotation.

Im sure ill find out that I need to change the bounds or something else
later, but for now I just wanna get past this barrier.

Sample code below:

@property (strong, nonatomic) IBOutlet UIView *CatBox;


@property (strong, nonatomic) IBOutlet UIImageView *catFishBox;

@property (nonatomic) UIDynamicAnimator* animator;


@property (strong, nonatomic) IBOutlet UIView *wrapperWolfBox;


@end


@implementation CatFishViewController


UIDynamicAnimator* _animator;

UIGravityBehavior* _gravity;

UICollisionBehavior* _collision;


- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.



_animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];

_gravity = [[UIGravityBehavior alloc] initWithItems:@[_wrapperWolfBox]];

[_animator addBehavior:_gravity];



_collision = [[UICollisionBehavior alloc]

  initWithItems:@[_wrapperWolfBox]];

_collision.translatesReferenceBoundsIntoBoundary = YES;

[_animator addBehavior:_collision];

//

//



CGAffineTransform maybeGetTransform = CGAffineTransformScale(
_wrapperWolfBox.transform, 2.2, 2.2);

_wrapperWolfBox.transform = maybeGetTransform;



[_animator updateItemUsingCurrentState:self.wrapperWolfBox];









//_animator.updateItemUsingCurrentState:self.catFishBox;




}
___

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

NSStackView basics

2013-11-08 Thread Tom Harrington
I'm trying to use NSStackView in what should be the most basic way
possible. I create the stack view and add two subviews. But only one of
them is ever visible.

I'm creating the stack view in code (in my app delegate, for purposes of a
test project):

NSStackView *stackView = [NSStackView stackViewWithViews:@[self.subview1,
self.subview2]];

stackView.orientation = NSUserInterfaceLayoutOrientationVertical;

stackView.alignment = NSLayoutAttributeCenterX;

stackView.spacing = 0;

[self.window.contentView addSubview:stackView];

[self.window.contentView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@H:|-(50)-[stackView]-(50)-|


options:0


metrics:nil


  views:NSDictionaryOfVariableBindings(stackView)]];

[self.window.contentView addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@V:|-(50)-[stackView]-(50)-|


options:0


metrics:nil


  views:NSDictionaryOfVariableBindings(stackView)]];

The two subviews subview1 and subview2 are just plain NSViews, each with an
NSTextField label subview constrained to be in the center.

At run time, only one subview is visible-- the last one in the array. It's
resized to fill the entire stack view. If I resize the window, the stack
view and the one visible subview also resize, but no window size ever gets
both subviews showing.

Obviously I'm missing something basic about stack views, but I don't know
what. I've been looking at Apple's InfoBarStackView demo app but haven't
worked out which detail it has that I don't (Apple's demo:
https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html
)

-- 
Tom Harrington
atomicb...@gmail.com
AIM: atomicbird1
___

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: Apple Sample Code WWDC 2010 session 114 (2551)

2013-11-08 Thread 2551
For all those interested:

https://www.dropbox.com/s/nqdsguiap4qs9ec/WWDC_2010_114.zip

Best

Phil
http://applehelpwriter.com

On 9 Nov 2013, at 01:54, Brian Clark ba-cl...@comcast.net wrote:

 
 On Nov 8, 2013, at 11:18 AM, 2551 2551p...@gmail.com wrote:
 
 I have now been fortunate to receive a copy of the code from a list member. 
 I’m also grateful to several others that also kindly offered me the code.
 
 I'm sure there are others interested in this code, if not now than for future 
 reference. Is it available for download anywhere? 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