Re: Best Xcode machine mid-2019?

2019-06-28 Thread Dave Fernandes via Cocoa-dev
Not a comprehensive list, but a start...
https://github.com/ashfurrow/xcode-hardware-performance

> On Jun 28, 2019, at 2:02 PM, Steve Mykytyn via Cocoa-dev 
>  wrote:
> 
> My main Xcode machine is a late 2013 27-inch iMac, 24GB RAM, 3.5 GHz Core
> i7 with 500GB SSD.
> 
> It works fine, but I'm wondering if an iMac Pro or a top-of-the-line 2019
> iMac would be a life-changing experience.  Or just, "that's nice."
> 
> The Geekbench numbers are somewhat informative, but hoping for commentary
> based on personal, direct experience.

___

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: NSManagedObject.managedObjectContext is nil???

2019-03-27 Thread Dave Fernandes
Just to clarify, the moc exists, but the reference to it is nil? Or has the 
moc, itself, been deallocated?

> On Mar 27, 2019, at 3:40 PM, Rick Mann  wrote:
> 
> This is proving very hard to diagnose, as it doesn't always happen. I tried 
> observing -managedObjectContext, but it never gets called with a nil value. 
> Moreover, my entity's -dealloc method is sometimes called even though none of 
> the -awake methods gets called. This is a complex app with a lot of async 
> operation, so this entity gets created and destroyed often, making it that 
> much harder to figure out exactly what's going on.
> 
> I can bulletproof the place where the crash occurs when the moc is nil, but 
> I'd really like to track down the underlying problem.
> 
>> On Mar 27, 2019, at 12:17 , Mike Abdullah  wrote:
>> 
>> Given the number of objects Core Data is designed to juggle, managing that 
>> number of weak references might well affect performance. Besides, wouldn’t 
>> you still the same result, that your object has a nil reference to the 
>> context because the context has been deallocated?
>> 
>> Furthermore, I think you can also observe this affect on deleted objects 
>> once the context has been saved, if you’re still holding a reference to any 
>> such objects.
>> 
>> Mike.
>> 
>> Sent from my iPhone
>> 
>>> On 26 Mar 2019, at 21:57, Rick Mann  wrote:
>>> 
>>> The implication there is that an object has a weak reference to the MOC? 
>>> Ah, in the header I see it's `assign`. I wonder why they do that and not 
>>> `weak`.
>>> 
>>> Thanks, I'll look into it.
>>> 
 On Mar 26, 2019, at 14:50 , Richard Charles  wrote:
 
 You have retained the managed object outside the managed object context.
 
 --Richard Charles
 
 
> On Mar 26, 2019, at 1:04 PM, Rick Mann  wrote:
> 
> I'm seeing a situation where my NSManagedObject's managedObjectContext is 
> nil. It doesn't happen all the time though. Any idea why? Thanks!
> 
> -- 
> Rick Mann
> rm...@latencyzero.com
 
>>> 
>>> 
>>> -- 
>>> Rick Mann
>>> rm...@latencyzero.com
>>> 
> 
> 
> -- 
> Rick Mann
> rm...@latencyzero.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: Need a direction. App crash in CoreData while loading a window's nib

2018-11-04 Thread Dave Fernandes


> On Nov 4, 2018, at 2:24 PM, Motti Shneor  wrote:
> 
> Hi Dave and thanks for the reply.
> 
> As you can see in the stack - there isn’t actually any “code” per-se that 
> runs at that time. Here is the actual method that fails:
> 

> As for modifying the persistent store - I guess I don’t because the 
> database-document does not become “dirty”. If I double click one of the 
> “sample” entities that can be open - and the window is shown as expected, 
> then I close the document - there are no autosaves or changes recorded. The 
> modification time of the persistent store does not change.
> 
> However - you’re right to point at 
> NSManagedObjectContextDidChangeNotification — how could I get it to pop? 

Set up an observer for that notification for your MOC and set a breakpoint in 
that observer.

> 
> 3 of my NSTableColumn do have a formatter for the number presented - but why 
> should this affect the context, The columns are not “editable” in-place. 

Just trying to narrow this down without assuming too much.

> 
> I will attempt to delete these columns and try again… 
> 

___

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: Need a direction. App crash in CoreData while loading a window's nib

2018-11-04 Thread Dave Fernandes
Does your code modify anything in the persistent store during loading 
(NSManagedObjectContextDidChangeNotification)? Maybe it is rounding some values 
for display? This might cause infinite recursion with bindings.

> On Nov 4, 2018, at 2:42 AM, Motti Shneor  wrote:
> 
> Thanks Richard. 
> 
> The data is OK. Not corrupt. I can import and export it to .csv, and I do run 
> several sanity test (heavy calculations based on that data pass OK and 
> provide expected results). Most important - the production build of the 
> software (built half year ago), opens the same database and doesn't crash on 
> the same data. It IS hanging about  a second when opening those items but 
> “survives” it. 
> 
> I cannot save it as XML easily - it is a rather big database about 500MB with 
> tens of millions of entities, in 20 interrelated tables (LOTS of complicated 
> relations). Most of the logic of this software is in its schema.
> 
> More things I’ve done:
> 1. I tested, double-clicking different items - it seems quite consistent. 
> Anything over ~2500 items to show in that window will crash while smaller 
> relation sets “survive”
> 
> 2. I put a symbolic breakpoint on -[NSSQLiteConnection connect]  and 
> double-clicked an item that opens without crashing (about 1000 related items 
> to show). The behaviour is weird. I hit the breakpoint time and again, with a 
> stack that looks exactly like the one I described - except that in the first 
> stop there is only ONE iteration of that binding thing, next break I’ll see 2 
> nested iterations of the binding calls, then 3, 4, 5 — and the stack gets 
> longer and longer each hit. I did not survive to free it a 1000 times, but I 
> think the rule is - it will iterate  1000 times, each time going deeper, 
> until it either “survives” to open the window, or crashes for (what I think 
> of as) stack overflow.
> 
> 3. I tried to build with Xcode 9.4.1 (MacOS SDK 10.13) then with Xcode 10 
> (MacOS SDK 10.14) - same thing. I only have my MacOS 10.13 to try running on. 
> I cannot run the original Xcode (8.x) with which the production version was 
> built. It won’t run on my OS.
> 
> I just do not know how to go about resolving this.
> 
> Another idea I had — I’m using AutoLayout in the .xib file. Maybe — for 
> pre-caculating the “needed” space for some table column, it needs to know in 
> advance the widths of all texts it should ever display there, hence it is 
> forced to scan the whole data via some bindings before it can finally show 
> the table? 
> 
> If so - this cannot (of course) survive longer tables. Still the question why 
> older builds do survive.
> 
> Motti Shneor
> 
> 
>> On 4 Nov 2018, at 4:18, Richard Charles  wrote:
>> 
>> 
>>> On Nov 3, 2018, at 2:47 PM, Motti Shneor  wrote:
>>> 
>>> Can anyone suggest a way to start bisecting the issue or an idea where to 
>>> look for?
>> 
>> You may have bad or corrupted data in your core data persistent store. Save 
>> the file out as an xml and see if you find anything suspicious. 
>> 
>> You could also open the sqlite file with the Base.app by Menial and see what 
>> happens and take a look at the data.
>> 
>> --Richard 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/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca

___

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: NSManagedObjectContext's undoManager is nil on macOS

2018-09-06 Thread Dave Fernandes
Ah - thank you! I should read those release notes more carefully. Will close 
the bug I just filed.

> On Sep 6, 2018, at 3:56 PM, Jeff Nadeau  wrote:
> 
> This behavior changed in 10.12  for applications linked against that SDK or 
> later. It’s listed in the “Behavioral changes” section of the Core Data 
> release notes for that year: 
> https://developer.apple.com/library/archive/releasenotes/General/WhatNewCoreData2016/ReleaseNotes.html#//apple_ref/doc/uid/TP40017342-CH1-DontLinkElementID_10
>  
> <https://developer.apple.com/library/archive/releasenotes/General/WhatNewCoreData2016/ReleaseNotes.html#//apple_ref/doc/uid/TP40017342-CH1-DontLinkElementID_10>
> 
> There's a documentation bug to correct the information on the 
> NSManagedObjectContext class doc. I’ll give it a little bump.
> 
> Going forward, you can set the undoManager property with your own 
> NSUndoManager after you’ve initialized the context.
> 
> - Jeff
> 
>> On Sep 5, 2018, at 7:33 PM, Dave Fernandes > <mailto:dave.fernan...@utoronto.ca>> wrote:
>> 
>> The docs say:
>> "In macOS, a context provides an undo manager by default; on iOS, the undo 
>> manager is nil by default.”
>> 
>> However, I am finding on macOS 10.13.6, the undoManager is always nil when 
>> creating a MOC. Is this new behavior expected for High Sierra, or is it a 
>> bug?
>> _
___

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


NSManagedObjectContext's undoManager is nil on macOS

2018-09-05 Thread Dave Fernandes
The docs say:
"In macOS, a context provides an undo manager by default; on iOS, the undo 
manager is nil by default.”

However, I am finding on macOS 10.13.6, the undoManager is always nil when 
creating a MOC. Is this new behavior expected for High Sierra, or is it a bug?
___

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: file encription/decriptoin iOS

2017-06-29 Thread Dave Fernandes
Ah. Thinking about the new device use case helps. Everything must be accessible 
and decryptable using only the iCloud passphrase. But if the same passphrase is 
used both to authorize access to the data and to decrypt it, then Apple has the 
passphrase to decrypt each time the user logs in, do they not? So encryption 
prevents against third parties seeing the data, but not Apple itself. Or 
perhaps the passphrase is used to generate two independent secrets and the 
passphrase itself is never sent over the wire?

> On Jun 29, 2017, at 12:27 AM, Jens Alfke <j...@mooseyard.com> wrote:
> 
> 
>> On Jun 28, 2017, at 8:04 PM, Dave Fernandes <dave.fernan...@utoronto.ca 
>> <mailto:dave.fernan...@utoronto.ca>> wrote:
>> 
>> So everything is protected by the iCloud Drive service key, but what does 
>> “which is then stored with the user’s iCloud account” mean? Is it stored on 
>> the device or in iCloud? That makes all the difference.
> 
> I agree it’s vague. The way I read it is that the service key is stored with 
> other account data in iCloud, but the account data is itself encrypted via 
> the user’s passphrase (which is not known to Apple.)
> 
> If the service key were stored locally, that would beg the question of how it 
> gets from one device to another. You have to be able to access everything 
> from a new device by logging into iCloud, so any secrets have to be stored 
> online. But by encrypting them using the passphrase, Apple prevents anyone 
> else (including themselves) from reading them.
> 
> —Jens

___

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

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

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

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


Re: file encription/decriptoin iOS

2017-06-28 Thread Dave Fernandes

> On Jun 28, 2017, at 12:17 PM, Jens Alfke  wrote:
> 
> 
>> On Jun 28, 2017, at 6:33 AM, Sandor Szatmari  
>> wrote:
>> 
>> I thought there were both local and iCloud Notes, no?
> 
> Not sure what you’re asking, but: Anything saved to iCloud goes through 
> end-to-end encryption, so there’s no way to read it on the iCloud servers 
> without using keys stored on your device (derived from your iCloud password.) 
> So again, it’s not necessary to add any extra encryption.
> 
> —Jens
> ___

I didn’t realize this, and went to the iOS Security Guide to get more details, 
but I am left more confused than when I started. The Security Guide has this to 
say (CloudKit works the same way):

iCloud Drive

iCloud Drive adds account-based keys to protect documents stored in iCloud. As 
with existing iCloud services, it chunks and encrypts file contents and stores 
the encrypted chunks using third-party services. However, the file content keys 
are wrapped by record keys stored with the iCloud Drive metadata. These record 
keys are in turn protected by the user’s iCloud Drive service key, which is 
then stored with the user’s iCloud account. Users get access to their iCloud 
documents metadata by having authenticated with iCloud, but must also possess 
the iCloud Drive service key to expose protected parts of iCloud Drive storage. 


So everything is protected by the iCloud Drive service key, but what does 
“which is then stored with the user’s iCloud account” mean? Is it stored on the 
device or in iCloud? That makes all the difference.

- Dave
___

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 headaches

2016-10-27 Thread Dave Fernandes
The managed objects exist in a MOC whether you have a reference to that MOC or 
not. You can get a reference to the MOC that an MO “belongs to" from the 
-[NSManagedObject managedObjectContext] instance method. Since the properties 
you need are so few and simple, why don’t you just pass these in to the 
NSOperation when you create it on the main thread instead of giving it the 
managed object? Then the MO will never be accessed off the main queue.

> On Oct 28, 2016, at 12:02 AM, Steve Mills <sjmi...@mac.com> wrote:
> 
> On Oct 27, 2016, at 22:49:15, Dave Fernandes <dave.fernan...@utoronto.ca> 
> wrote:
>> 
>> But what managed object are you dealing with? Is the Asset a managed object? 
>> If so, you can only access its properties from the queue of its managed 
>> object context. So if it is a main queue context, you can only access the 
>> MO’s properties from the main queue. If it is a private queue context, you 
>> use performBlock on the MO’s context to execute a block of code in the 
>> context’s queue and you must access the MO’s properties from inside that 
>> block. If I’m stating something you already know, forgive me. It is not 
>> clear from your post. Example code would help.
> 
> Yes, the Asset is an NSManagedObject. In this call chain, there is no 
> NSManagedObjectContext in sight. The NSCollectionView is simply creating item 
> views to display for each Asset. It asks the Asset to create an image 
> thumbnail. The Asset does so in via the steps I outlined before.
> 
> Now way back in the document's init method, I set up an 
> NSManagedObjectContext with type NSMainQueueConcurrencyType. So yes, there is 
> a main queue type context, but the code that is requesting the thumbnails 
> knows nothing about it or even cares.
> 
>>> On Oct 27, 2016, at 11:24 PM, Steve Mills <sjmi...@mac.com> wrote:
>>> 
>>> I'll explain what's going on. Each NSCollectionViewItem in the 
>>> NSCollectionView is being assigned its representedObject (the Asset, which 
>>> is a reference to an image file). At that point, I ask the Asset to 
>>> requestPreviewImageAtSize:, which creates an NSBlockOperation (and adds it 
>>> to an NSOperationQueue), whose block creates a CGImageSourceRef. Before it 
>>> can create the CGImageSourceRef, it needs to get the url. It does this by 
>>> asking for its .folder and .name properties. Those are nonatomic properties 
>>> of the Asset. Once it has the url and the CGImageSourceRef, it creates the 
>>> CGImageRef, converts that to an NSImage, and finally assigns that to the 
>>> Asset's atomic .thumb property.
>>> 
>>> The folder and name properties were generated by mogenerator, a tool for 
>>> creating document model classes for CoreData .xcdatamodeld files. The thumb 
>>> property is something I added manually to cache the thumbnail, and the 
>>> AssetItemView's NSImageView's Value binds to it as well.
>>> 
>>> So I'm not directly dealing with any NSManagedObjectContext here. That's 
>>> all taken care of when the items are added to it or when a document is 
>>> opened. All I'm doing is generating a preview for each managed object.
> 
> --
> Steve Mills
> Drummer, Mac geek
> 
> 
> ___
> 
> 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/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca


___

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 headaches

2016-10-27 Thread Dave Fernandes
But what managed object are you dealing with? Is the Asset a managed object? If 
so, you can only access its properties from the queue of its managed object 
context. So if it is a main queue context, you can only access the MO’s 
properties from the main queue. If it is a private queue context, you use 
performBlock on the MO’s context to execute a block of code in the context’s 
queue and you must access the MO’s properties from inside that block. If I’m 
stating something you already know, forgive me. It is not clear from your post. 
Example code would help.

> On Oct 27, 2016, at 11:24 PM, Steve Mills <sjmi...@mac.com> wrote:
> 
> On Oct 27, 2016, at 19:00:14, Dave Fernandes <dave.fernan...@utoronto.ca> 
> wrote:
>> 
>> Are you accessing the properties from within a 
>> NSManagedObjectContext.performBlock block? Sounds like you may be accessing 
>> the managed objects from the wrong queue.
> 
> I'll explain what's going on. Each NSCollectionViewItem in the 
> NSCollectionView is being assigned its representedObject (the Asset, which is 
> a reference to an image file). At that point, I ask the Asset to 
> requestPreviewImageAtSize:, which creates an NSBlockOperation (and adds it to 
> an NSOperationQueue), whose block creates a CGImageSourceRef. Before it can 
> create the CGImageSourceRef, it needs to get the url. It does this by asking 
> for its .folder and .name properties. Those are nonatomic properties of the 
> Asset. Once it has the url and the CGImageSourceRef, it creates the 
> CGImageRef, converts that to an NSImage, and finally assigns that to the 
> Asset's atomic .thumb property.
> 
> The folder and name properties were generated by mogenerator, a tool for 
> creating document model classes for CoreData .xcdatamodeld files. The thumb 
> property is something I added manually to cache the thumbnail, and the 
> AssetItemView's NSImageView's Value binds to it as well.
> 
> So I'm not directly dealing with any NSManagedObjectContext here. That's all 
> taken care of when the items are added to it or when a document is opened. 
> All I'm doing is generating a preview for each managed object.
> 
> --
> Steve Mills
> Drummer, Mac geek


___

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 headaches

2016-10-27 Thread Dave Fernandes

> On Oct 27, 2016, at 5:24 PM, Steve Mills  wrote:
> 
> I have an app that uses CoreData to store document data, and an 
> IKImageBrowserView to display the items in the CoreData. Finding that 
> IKImageBrowserView is being deprecated, and since Xcode 8 causes a goofy 
> scrolling bug that the user can't work around, I decided to move away from 
> IKImageBrowserView and reimplement the display as an NSCollectionView. OK, 
> that works. In order to match the speed at which IKImageBrowserView builds 
> thumbnails in the background, I used an NSOperationQueue in which to load 
> each thumbnail via CGImageSourceCreateThumbnailAtIndex. This mostly works 
> fine, except I get random crashes when accessing properties of a 
> NSManagedObject (the image file's folder's url and image file's name). Any 
> suggestions for making this work correctly? I'm just hacking at it right now 
> by adding @synchronize() wrappers around code, but it's not helping.

Are you accessing the properties from within a 
NSManagedObjectContext.performBlock block? Sounds like you may be accessing the 
managed objects from the wrong queue.

> 
> Since CoreData and managed objects are full of so much voodoo (and because 
> it's been a long time since I originally wrote this app, so the CoreData 
> stuff is pretty fuzzy by now), I wonder if there isn't a better system I 
> could use to store document data. The app is an image organizer that can 
> store references to thousands of images and movies (not the actual images), 
> sort and filter them any number of ways (which is all handled by an 
> NSArrayController), and tag them with keywords (also NSManagedObject).
> 
> What does CoreData give me that I can't get by simply archiving an array of 
> NSDictionary? Well, aside from undo, writing only changed objects to the 
> file, and all the rest of the stuff it does.

I think you just answered your own question. The relationship management and 
delete rules are also helpful — there is less bookkeeping for you to do.

> 
> The previous version of the app used my own file format. I don't recall it 
> being particularly slow or featureless. Hmm.

If you aren’t dealing with large numbers of objects, then all the optimizations 
in Core Data may not be important to you.

> 
> --
> Steve Mills
> Drummer, Mac geek
> 
> 
> ___
> 
> 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/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca


___

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

2016-10-07 Thread Dave Fernandes
> 
> In practice, you’d actually initialize the semaphore like this:
> 
>>  dsema = dispatch_semaphore_create (0); // start with a zero count
>>  dispatch_semaphore_signal (dsema); // increment to the number of 
>> resources in the pool.
> 
> That’s because if you create the semaphore with a non-zero count, then later 
> try to release the semaphore object when its count is something different 
> (which can happen if you have a more complex loop that you break out of), 
> your app will crash. The API design assumption is that if you didn’t free all 
> the original resources, your app has a bug (which I happen to think is bogus 
> reasoning, but anyway…).

Wow, I’ve never come across that issue. But I don’t see how incrementing it 
after creating it is any different from creating it with a non-zero count. 
Either way, if you have resources available, the count will be non-zero, and 
you will crash if you try to deallocate. But I’m somewhat sure I’ve never seen 
a crash like that. Maybe I was just lucky?
___

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: iOS - how to make documents visible in iTunes

2016-03-19 Thread Dave Fernandes
I have a related question -
If you share documents between apps in an app group, is there a way to download 
the shared folder from Xcode? It only gets the app’s local documents.

> On Mar 19, 2016, at 3:21 PM, Quincey Morris 
>  wrote:
> 
> On Mar 19, 2016, at 11:24 , Gerriet M. Denkmann  wrote:
>> 
>> I have an iOS app (9.2.1) (not document based) which contains stuff in:
>> /private/var/mobile/Containers/Data/Application/55…F0/Documents, which is 
>> the NSDocumentDirectory in NSUserDomainMask. 
>> 
>> I want to see these files in iTunes → my iOS Device → Apps → File Sharing
>> But my app does not even make it to this list of Apps.
>> 
>> Is there any magic needed in Info.plist (or where else)?
> 
> If you want to see those files that way, then you’re going to have to declare 
> the document types in your info.plist like any UIDocument-based app.
> 
> If you want to examine the container for debugging purposes, you can go to 
> the Xcode Devices window, select your app and choose (e.g.) Download 
> Container from the utility popup menu.
> 
> ___
> 
> 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/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca


___

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: Detecting when a text view becomes First Responder

2015-11-11 Thread Dave Fernandes
Doh! It’s iOS. Wasn’t paying attention.

> On Nov 11, 2015, at 6:16 PM, Graham Cox <graham@bigpond.com> wrote:
> 
> 
>> On 12 Nov 2015, at 10:12 AM, Dave Fernandes <dave.fernan...@utoronto.ca> 
>> wrote:
>> 
>> textFieldDidBeginEditing
> 
> 
> Sounds promising, but I can’t find that anywhere in the documentation. Where 
> is it defined? (n.b. I should make clear this is on Mac OS, if that’s iOS 
> only I can’t use it).
> 
> —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: Is NSTreeController good with Cocoa Bindings and Core Data now?

2015-08-23 Thread Dave Fernandes
It’s been working pretty well since Snow Leopard. Haven’t had any weird undo 
issues in a while.

 On Aug 23, 2015, at 4:56 PM, Jerry Krinock je...@ieee.org wrote:
 
 A long time ago, I was advised to use an old-fashioned data source on my 
 outline views for Core Data trees, because NSTreeController did not work the 
 way it should have.
 
 Have those issues now been resolved now?  I’m working on a new app, with Core 
 Data and Cocoa Bindings.  The new app will require OS X 10.10 or 10.11 
 minimum.
 
 Thank you,
 
 Jerry
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Dave Fernandes
Depending on what you are doing, you could either put doSomething and 
doSomethingElse inside the performBlock, or you could use performBlockAndWait

 On Jul 28, 2015, at 10:14 AM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 
 If I do use performBlock and have to do several things:
 
 This code is sitting inside a completion block for a URL downloader
 {
[self doSomething];
[myContext performBlock (do more stuff)];
[self doSomethingElse];
 }
 
 
 Since the perform block will run in a different thread, how can I make sure
 the do more stuff is finished before calling doSomethingElse?
 
 Or in this case would using NSConfinementConcurrencyType be better since it
 is all within a completion block and presumably on it's own thread anyway.
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: NSPrivateQueueConcurrencyType working outside of performBlock

2015-07-28 Thread Dave Fernandes

“Setter methods on queue-based managed object contexts are thread-safe. You can 
invoke these methods directly on any thread”

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/index.html

 On Jul 28, 2015, at 11:49 PM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 
 So what has to be called though performBlock??
 
 NSManagedObjectContext* privateContext = [[NSManagedObjectContext alloc]
 initWithConcurrencyType:NSPrivateQueueConcurrencyType];
 
 
 // Are these legal to call without using performBlock?
 [privateContext setPersistentStoreCoordinator:myCoordinator];
 [privateContext setUndoManager:nil];
 


___

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 remove iPad popover?

2015-04-14 Thread Dave Fernandes
You can dismiss the master popover using -[UIPopoverController 
dismissPopoverAnimated:]

However, getting the popover controller in the first place is a bit of a pain. 
The only way I know is to provide a UISplitViewControllerDelegate object to the 
UISplitViewController (I instantiate one in the storyboard); and then in 
splitViewController:willHideViewController:withBarButtonItem:forPopoverController:,
 record the popover controller in a property, which you can use later.

You can also use this popover controller to programmatically show the popover 
when you need to.

If there is an easier way, I would love to hear about it.

Cheers,
Dave

 On Apr 14, 2015, at 10:13 PM, Gerriet M. Denkmann gerr...@mdenkmann.de 
 wrote:
 
 
 On 15 Apr 2015, at 08:59, Roland King r...@rols.org wrote:
 
 
 On 15 Apr 2015, at 09:49, Gerriet M. Denkmann gerr...@mdenkmann.de wrote:
 
 On iPad (portrait orientation) there is on the left a MasterView, 
 overlapping the DetailView.
 (i.e. splitViewController.displayMode = 
 UISplitViewControllerDisplayModePrimaryOverlay)
 
 When I tap on the DetailView, the MasterView slides away.
 (i.e. splitViewController.displayMode → 
 UISplitViewControllerDisplayModePrimaryHidden)
 
 How can I do this from code?
 
 The obvious way would be:
 splitViewController.displayMode = 
 UISplitViewControllerDisplayModePrimaryHidden;
 but displayMode is readonly.
 
 iOS 8.3
 
 Gerriet.
 
 
 
 Let’s see if the documentation contains any hints here .. documentation on 
 UISplitViewController’s displayMode ..
 
 To change the current display mode, change the value of the 
 preferredDisplayMode property.”
 
 I’d probably try that
 
 I read this as meaning “set the general behaviour”.
 Indeed: when I set preferredDisplayMode = 
 UISplitViewControllerDisplayModePrimaryHidden then the Primary stays hidden, 
 even if I rotate the iPad to landscape.
 This is NOT what I want.
 
 I want: [ splitViewController 
 hideThePrimaryViewExactlyAsWhenOneTappsOnTheSecondaryView ];
 
 Kind regards,
 
 Gerriet.
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Force IKImageBrowserView to regenerate a cell's image?

2015-03-02 Thread Dave Fernandes
Oops, yes imageVersion is what you should use. It’s been a long time since I 
looked at this code (Leopard, I think).

 On Mar 2, 2015, at 4:13 PM, Mike Abdullah mabdul...@karelia.com wrote:
 
 Or you can bump up the -imageVersion
 
 On 2 Mar 2015, at 21:54, Steve Mills sjmi...@mac.com wrote:
 
 On Mar 2, 2015, at 14:23:03, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 Your IKImageBrowserItem must change its returned imageUID when the 
 imageRepresentation changes so that the IKImageBrowserView knows to recache 
 the image.
 
 Ah. I was using a shorter string because using the full path seemed wasteful 
 and slow, especially when there could be tens of thousands of images in the 
 browser that all begin with the same very long path. But, it's what Apple 
 suggests, and it does fix the problem, so I'll go with that. Thanks!
 
 --
 Steve Mills
 Drummer, Mac geek
 
 
 ___
 
 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/mabdullah%40karelia.com
 
 This email sent to mabdul...@karelia.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: Force IKImageBrowserView to regenerate a cell's image?

2015-03-02 Thread Dave Fernandes
Your IKImageBrowserItem must change its returned imageUID when the 
imageRepresentation changes so that the IKImageBrowserView knows to recache the 
image.

Dave

 On Mar 2, 2015, at 12:37 PM, Steve Mills sjmi...@mac.com wrote:
 
 Is there any way to force IKImageBrowserView to throw out a cached thumbnail 
 and regenerate it on a changed imageRepresentation? I can definitely see that 
 imageRepresentation is returning a different url, but the browser still draws 
 the old one, even after calling reloadData.
 
 --
 Steve Mills
 Drummer, Mac geek
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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

Re: Core Data concurrency during import of folder contents

2015-02-03 Thread Dave Fernandes
NSPersistentDocument is not designed to work with “modern” features like 
private queue MOCs. So I expect you are going to be playing whack-a-mole if you 
go this route. I just switched to Mike Abdullah’s BSManagedDocument. It is like 
UIManagedDocument, but for OS X. If you don’t have any customers on this app 
yet, BSManagedDocument is pretty much a drop-in replacement for 
NSPersistentDocument. If you have customers, you will need to migrate them, but 
that is straightforward and probably much lower risk than trying to get 
NSPersistentDocument to support something it is not designed for.

 On Feb 3, 2015, at 1:48 AM, Steve Mills sjmi...@mac.com wrote:
 
 On Feb 2, 2015, at 17:36:22, Roland King r...@rols.org wrote:
 
 get the NSManagedObjectContext the document creates for you with [ super 
 managedObjectContext ], get the store coordinator with [ 
 managedObjectContext persistentStoreCoordinator ], create your own MOCs on 
 that store, hold on to the MOC you have just created, ignore the one super 
 created (or perhaps you can nil it, not sure) and then return it. 
 
 That sounds interesting. I've tried it, and it causes my managedObjectContext 
 override to be called twice during document creation. The 2nd call is caused 
 by my managedObjectContext override calling [super managedObjectContext], and 
 super tries to set up the undo manager for its managedObjectContext. I don't 
 know if this is harmless or OK.
 
 So since no exceptions are thrown during the creating of my own MOCs, I go 
 ahead and add objects to a temp private MOC whose parent is my 
 managedObjectContext. That works and my table view is populated after it 
 completes. But when I try to save at the end of my concurrent object-adding 
 block, it throws:
 
 CoreData: error: Illegal attempt to save to a file that was never opened. 
 This NSPersistentStoreCoordinator has no persistent stores (unknown).  It 
 cannot perform a save operation.. No last error recorded.
 An uncaught exception was raised
 This NSPersistentStoreCoordinator has no persistent stores (unknown).  It 
 cannot perform a save operation.
 (
   0   CoreFoundation  0x7fff8569b66c 
 __exceptionPreprocess + 172
   1   libobjc.A.dylib 0x7fff87dfd76e 
 objc_exception_throw + 43
   2   CoreData0x7fff898b7eb3 
 -[NSPersistentStoreCoordinator 
 _coordinator_you_never_successfully_opened_the_database_so_saving_back_to_it_is_kinda_hard:]
  + 51
   3   CoreData0x7fff898b810d 
 -[NSPersistentStoreCoordinator _introspectLastErrorAndThrow] + 77
   4   CoreData0x7fff898b8236 
 __65-[NSPersistentStoreCoordinator 
 executeRequest:withContext:error:]_block_invoke + 166
   5   CoreData0x7fff898c331b 
 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 171
   6   libdispatch.dylib   0x000100025d43 
 _dispatch_client_callout + 8
   7   libdispatch.dylib   0x0001000270b1 
 _dispatch_barrier_sync_f_invoke + 348
   8   CoreData0x7fff898b2312 _perform + 
 194
   9   CoreData0x7fff89804395 
 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 533
   10  CoreData0x7fff898043c4 
 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 580
   11  CoreData0x7fff8982eb3b 
 -[NSManagedObjectContext save:] + 1291
   12  Image Chest 0x00012291 -[Document 
 unsafeSaveContext:] + 113
   13  Image Chest 0x0001213a 
 __24-[Document saveContext:]_block_invoke + 42
   14  CoreData0x7fff8984a246 
 developerSubmittedBlockToNSManagedObjectContextPerform + 182
   15  libdispatch.dylib   0x000100025d43 
 _dispatch_client_callout + 8
   16  libdispatch.dylib   0x000100029fb3 
 _dispatch_queue_drain + 1804
   17  libdispatch.dylib   0x00010002bfc0 
 _dispatch_queue_invoke + 223
   18  libdispatch.dylib   0x000100028f5e 
 _dispatch_root_queue_drain + 666
   19  libdispatch.dylib   0x00010003acd0 
 _dispatch_worker_thread3 + 106
   20  libsystem_pthread.dylib 0x7fff92a82637 
 _pthread_wqthread + 729
   21  libsystem_pthread.dylib 0x7fff92a8040d 
 start_wqthread + 13
 )
 
 The save model is based on Jerry's YaBT sample mentioned earlier in the 
 thread, which has a rootContext (NSPrivateQueueConcurrencyType), mainContext 
 (NSMainQueueConcurrencyType), and tempContext (NSPrivateQueueConcurrencyType) 
 in a chain of children. I'm guessing it's because the document has not been 
 saved to disk yet, whereas the YaBT sets up a file for the 

Re: licence key validation method

2015-01-12 Thread Dave Fernandes
 On Jan 12, 2015, at 6:39 AM, Uli Kusterer witness.of.teacht...@gmx.net 
 wrote:
 
 On 12 Jan 2015, at 10:52, 2551 2551p...@gmail.com wrote:
 Given that my licences are being generated with OpenSSL in the FastSpring 
 website,
 
 Didn't FastSpring have an SDK that you just drop into your app to validate 
 their licenses?

No, they support a couple third party solutions out of the box, or let you 
supply your own generator script. They were also nice enough to add a 
JavaScript API for me to support my own scheme since AquaticPrime and CocoaFOB 
didn’t work for me. Very helpful folks!

 
 does that mean I HAVE TO use OpenSSL to validate them? I'm thinking the 
 DUH answer here has to be YES, but given my lack of knowledge about this 
 topic, I'm taking nothing for granted. 
 
 OpenSSL is just a security library that implements several standards and 
 algorithms. You can use any other library that implements the same standard 
 and algorithm as you are using. I.e. Windows AFAIK has its own security 
 library, yet can still read browser certificates that are (were?) validated 
 using OpenSSL on Mac and other platforms.

If you use AquaticPrime, unfortunately, it does not generate standard 
signatures. It manually hashes and then encrypts using the private key. This 
sounds like a normal signature, but it is missing some information stored in 
standard PKCS #1 v2.0 signatures. This means that Security.framework WILL NOT 
be able to verify an AquaticPrime signature. The verify transform does not work 
for the above reason; and the decrypt transform does not work either because 
that would require you to decrypt using the public key. Security.framework 
enforces cryptographic hygiene - you can only decrypt with a private key and 
verify a signature with a public key.

 LibreSSL is essentially OpenSSL, just a fixed version, so you should just 
 hear LibreSSL when anyone suggests using OpenSSL for anything and you'll be 
 fine. Security.framework is what Apple recommends and supports, so sounds 
 like a good idea. The only problem is that it is very limited. If it does 
 what you need it to (i.e. offers whatever algorithm FastSpring use), it's 
 probably the best choice as long as you don't plan going cross-platform 
 anytime soon.
 
 -- Uli
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: licence key validation method

2015-01-12 Thread Dave Fernandes

 On Jan 12, 2015, at 12:05 PM, Jens Alfke j...@mooseyard.com wrote:
 
 
 Somebody (Dave Fernandes, apparently) wrote:
 
 If you use AquaticPrime, unfortunately, it does not generate standard 
 signatures. It manually hashes and then encrypts using the private key. 
 This sounds like a normal signature, but it is missing some information 
 stored in standard PKCS #1 v2.0 signatures. This means that 
 Security.framework WILL NOT be able to verify an AquaticPrime signature. 
 The verify transform does not work for the above reason; and the decrypt 
 transform does not work either because that would require you to decrypt 
 using the public key. Security.framework enforces cryptographic hygiene - 
 you can only decrypt with a private key and verify a signature with a 
 public key.
 
 The Security Transform API won't let you do that. But there are lower level 
 functions in the framework (the CDSA API) that allow it.
 
 —Jens

Yes, but aren’t they all deprecated?


___

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: licence key validation method

2015-01-12 Thread Dave Fernandes

 On Jan 12, 2015, at 11:53 AM, Tamas Nagy tamas.lov.n...@gmail.com wrote:
 
 
 If you use AquaticPrime, unfortunately, it does not generate standard 
 signatures. It manually hashes and then encrypts using the private key. This 
 sounds like a normal signature, but it is missing some information stored in 
 standard PKCS #1 v2.0 signatures. This means that Security.framework WILL 
 NOT be able to verify an AquaticPrime signature. The verify transform does 
 not work for the above reason; and the decrypt transform does not work 
 either because that would require you to decrypt using the public key. 
 Security.framework enforces cryptographic hygiene - you can only decrypt 
 with a private key and verify a signature with a public key.
 
 
 Are you sure about that? The latest version of CF based AquaticPrime on 
 GitHub using Security.framework: 
 https://github.com/bdrister/AquaticPrime/pull/32

Interesting. I haven’t checked in a while.
___

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 disable volume ramp when playing audio with AVPlayer?

2014-08-01 Thread Dave Fernandes
I’m using an AVPlayer to play an audio track and synchronize playback with an 
AVSynchronizedLayer. It is all working fine, but there is some default 
behavior” that I would like to change. When you start playback, the volume 
always ramps up to the value that has been set. This is a problem because the 
user may pause and resume playback rapidly, and each time they do, the volume 
drops and ramps back up.

Is there any way to prevent this ramp or decrease the default ramp time? I have 
tried setting the volume using the AVPlayer’s volume property, versus using a 
ramp set in an AVMutableAudioMixInputParameters. But I get the same behavior 
either way when pausing and resuming playback.

Thanks in advance.

Dave
___

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 do I temporary retain self, under ARC?

2014-07-17 Thread Dave Fernandes

On Jul 17, 2014, at 11:01 PM, Jens Alfke j...@mooseyard.com wrote:

 Every once in a while I run into a bug in my code that’s triggered by self 
 getting dealloced in the middle of a method. It’s usually something like
   - (void) someMethod {
   doSomeStuff;
   [self.delegate object: self didSomeStuff: yeah];
   doSomeMoreStuff;
   }
 where it turns out that the delegate method clears its reference to me, and 
 that was the last reference, causing self to get dealloced during the 
 delegate call, causing doSomeMoreStuff to crash.
 
 Once I’ve identified such a bug, the fix is easy: put a [[self retain] 
 autorelease] at the top of the method. Except now I’m using ARC, and I can’t 
 find a simple way of doing it. I tried adding
   __unused id retainedSelf = self;

[Conjecture] I haven’t tried it, but maybe the following would work:

__unused id retainedSelf __attribute__((objc_precise_lifetime)) = self;

Now retainedSelf should be retained until it goes out of scope. But I don’t 
know whether the optimizer is still allowed to mess with this.

 but the optimizer recognizes that retainedSelf isn’t used and strips it out, 
 making this a no-op. The only thing I’ve found that works is
   CFRetain((__bridge CFTypeRef)self);
 at the top of the method, and a corresponding CFRelease at the end, but this 
 is pretty ugly and could cause leaks if the method returns early.
 
 Am I missing some convenient way of doing this? I looked through the ARC 
 docs, at least those I could find, and didn’t see anything relating to this.
 
 —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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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

Re: Core Data migration and non-optional transient relationships

2014-05-20 Thread Dave Fernandes
During migration you have a bare NSManagedObject and not your custom subclass. 
So any custom code has to be in a migration policy.

Sent from my iPhone

 On May 20, 2014, at 12:07 PM, Mike Abdullah mabdul...@karelia.com wrote:
 
 
 On 20 May 2014, at 15:21, Sean McBride s...@rogue-research.com wrote:
 
 Hi all,
 
 Doing a Core Data migration (not the lightweight kind) I hit an error at the 
 end:
 
 foo is a required value.
 
 the 'foo' relationship it complains about is transient and so not present in 
 the store.  Normally, I recreate the relationship in awakeFromFetch, but it 
 doesn't seem to call that during migration.  As a test I made the 
 relationship optional, then it no longer complains.
 
 This seems to mean that transient relationships must always be optional?!  
 At least if you ever want to migrate.  That seems odd.  Am I missing 
 something here?
 
 How about -awakeFromInsert? During a migration, new objects are being 
 created, based on the existing ones. Thus -awakeFromInsert gets called on 
 them rather than -awakeFromFetch.
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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: GCD killed my performance

2014-04-26 Thread Dave Fernandes

On Apr 26, 2014, at 5:36 PM, Jens Alfke j...@mooseyard.com wrote:

 OS X implemented GCD at kernel level which introduced lots of syscalls which 
 are super expensive. The old school method is largely user land so it may 
 help a little by keeping syscalls to a minimum. @synchronized uses 
 Objective-C runtime functions which was once code behind those old school 
 classes.
 
 That's the opposite of what the docs say: A dispatch semaphore works like a 
 traditional semaphore, except that when the resource is available, it takes 
 less time to acquire a dispatch semaphore. The reason is that Grand Central 
 Dispatch does not call into the kernel for this particular case. It calls 
 into the kernel only when the resource is not available and the system needs 
 to park your thread until the semaphore is signaled.” —Concurrency 
 Programming Guide

They say this for dispatch semaphores, but it doesn’t necessarily apply to 
dispatch queues. (If I were less lazy, I suppose I could check the source.)
___

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: GCD killed my performance

2014-04-24 Thread Dave Fernandes
What’s the CPU utilization? Are you actually getting full use of them, or are 
your threads blocked waiting for something?

On Apr 24, 2014, at 11:14 PM, Jens Alfke j...@mooseyard.com wrote:

 I’m writing an Objective-C API around a database library, and trying to add 
 some optimizations. There’s a lot of room for parallelizing, since tasks like 
 indexing involve a combination of I/O-bound and CPU-bound operations. As a 
 first step, I made my API thread-safe by creating a dispatch queue and 
 wrapping the C database calls in dispatch_sync blocks. Then I did some 
 reorganization of the code so different parts run on different queues, 
 allowing I/O and computation to run in parallel.
 
 On my MacBook Pro this gave me a nice speedup of 50% or more.
 
 But when I tested the code on my iPhone 5 today, I found performance had 
 dropped by about a third. Profiling shows that most of the time is being 
 spent in thread/queue management or Objective-C refcount bookkeeping. It 
 looks as though adding GCD introduced a lot of CPU overhead, and the two 
 cores on my iPhone aren’t enough to make up for that, while the eight cores 
 in my MacBook Pro make it worthwhile.
 
 I tried backing out all the restructuring of my code, so there’s no actual 
 parallelism going on, just the dispatch_sync calls. Predictably, performance 
 is even worse; slightly more than half as fast as without them.
 
 So, I’m pretty disappointed. I know that dispatch queues aren’t free, but I 
 wasn’t expecting them to be this expensive! I’m not doing anything silly like 
 wrapping dispatch_sync around trivial calls. The APIs I’m using it on do 
 things like reading and writing values from the persistent store. I was 
 expecting the cost of thread-safety to be lost in the noise compared to that.
 
 Any suggestions on what to try next?
 
 —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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: GCD killed my performance

2014-04-24 Thread Dave Fernandes
Is there any way to batch up more work to do in each block? Then your ratio of 
real work to overhead would go up.

On Apr 25, 2014, at 12:35 AM, Jens Alfke j...@mooseyard.com wrote:

 
 On Apr 24, 2014, at 9:04 PM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 What’s the CPU utilization? Are you actually getting full use of them, or 
 are your threads blocked waiting for something?
 
 Fairly high — I think 175% or so (out of 200% possible). The problem is that 
 a large fraction of that is taken up with busywork. In the CPU profile list 
 from Instruments, the top 25 or so stack frames are all system 
 infrastructure; you have to read down quite a ways to find any application 
 code at all.
 
 —Jens

___

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

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

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

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

Re: Prevent autoloading of last opened document

2014-02-13 Thread Dave Fernandes
Try returning nil for the document in [NSDocumentController 
reopenDocumentForURL]’s completion handler, and also return the following 
error in the completion handler:

[NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError 
userInfo:nil]

On Feb 13, 2014, at 6:57 PM, Mike Abdullah mabdul...@karelia.com wrote:

 
 On 13 Feb 2014, at 23:39, Eric Gorr mail...@ericgorr.net wrote:
 
 
 
 On Feb 13, 2014, at 6:22 PM, Mike Abdullah mabdul...@karelia.com wrote:
 
 
 On 13 Feb 2014, at 21:12, Eric Gorr mail...@ericgorr.net wrote:
 
 What I want to do seems like it should be fairly straightforward, but 
 doesn't seem to be. All I want to do is with a standard NSDocument Based 
 (with Core Data) is prevent the last document opened from opening 
 automatically the next time the application is launched.
 
 What is the best way to accomplished this?
 
 It seemed as if it might be as simple as overriding reopenDocumentForURL 
 and having it do nothing, but that only seems to break creating new 
 documents or opening the document normally.
 
 I could probably disable all of the window restoration functionality and 
 handle it all myself by using:
 
 [window setRestorationClass:Nil];
 [window setRestorable:NO];
 [window invalidateRestorableState];
 
 but this seems to be overkill and not really what I want to do as when I 
 open the document via File-Open, I want it to restore without the need 
 for me to handle it myself.
 
 Is there some easy way to make this work?
 
 The deployment target is 10.7.
 
 I have a sample test project at:
 
  https://github.com/ericgorr/autoload.git
 
 Perhaps you want to override -[NSDocumentController 
 reopenDocumentForURL:withContentsOfURL:display:completionHandler:]
 
 
 Yes, as I mentioned, I tried that, but it wasn't clear exactly what I should 
 do. I tried to simply have it do nothing, but that broke other 
 functionality. I tried a couple of other things as well, like passing nil to 
 the super's method, but the app just crashed.
 
 Oops, sorry, missed that bit of your original message.
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Prevent autoloading of last opened document

2014-02-13 Thread Dave Fernandes
Good point. I guess if the document URL is nil, you should think twice about 
this.

On Feb 13, 2014, at 8:38 PM, Kyle Sluder k...@ksluder.com wrote:

 On Thu, Feb 13, 2014, at 05:21 PM, Dave Fernandes wrote:
 Try returning nil for the document in [NSDocumentController
 reopenDocumentForURL]’s completion handler, and also return the
 following error in the completion handler:
 
 [NSError errorWithDomain:NSCocoaErrorDomain code:NSUserCancelledError
 userInfo:nil]
 
 This sounds like a great way to lose documents that were autosaved at
 quit but never manually saved.
 
 They won't be restored, and then they'll be deleted from the autosave
 directory.
 
 Eric, why are you trying to avoid restoring documents?
 
 --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: Import old Core Data Model?

2014-02-10 Thread Dave Fernandes
Perhaps there is an elegant way, but this also works:

Make a new model in Xcode.
Close the project.
Open the packages of the old and new models in the Finder (Show Package 
Contents of the .xcdatamodel packages inside the .xcdatamodeld package).
Copy the ‘contents’ file of the old package into the new.

On Feb 10, 2014, at 11:15 PM, Rick Mann rm...@latencyzero.com wrote:

 I decided to write the newest version of an iOS app from scratch, copying and 
 pasting big chunks of code from the old project.
 
 In the new app I added a copy of the old app's Core Data model, and proceeded 
 to modify it. Unfortunately, I didn't first make a new version. I'd like to 
 add the old model in again as an older version that it can use for 
 lightweight migration, but I can't figure out how. Editor-Import… doesn't 
 allow me to choose a model file (nor can I find help on the feature).
 
 I tried adding a new version to make the .xcdatamodeld, but I can't drag the 
 old file into that. Dragging it to the package in the Finder doesn't seem to 
 help, either.
 
 Is there any way to do this?
 
 Thanks,
 
 -- 
 Rick
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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

Re: Binding not setting model property

2014-01-18 Thread Dave Fernandes
How are you setting up the binding? Normally you bind to the value property of 
the NSTextField (not stringValue). See Cocoa Bindings Reference (NSTextField 
Bindings).

On Jan 18, 2014, at 9:41 PM, Roland King r...@rols.org wrote:

 I have a model object with a codeURL property which is readwrite and is an 
 NSURL. 
 
 I have an NSTextField in the NSView subclass with the value bound to the 
 codeURL property with a custom transform which turns a URL into a string (and 
 deals with nil and another edge case). 
 
 The transform is reversible, returns YES for allowsReverseTransform and has 
 an implemented reverseTransformedValue: method. 
 
 There's a browse button on the UI which lets the user select a file and then 
 sets the stringValue: property of the NSTextField to the url.path of the file 
 selected. 
 
 What I expected is that setting the stringValue would invoke the transformer 
 in the reverse direction and set the codeURL property to the reverse 
 transformed value, thus binding the codeURL property in both directions. 
 
 What actually happens is nothing. The transformer reverse method isn't called 
 and the codeURL isn't changed. It works in the forward but not the reverse 
 direction. I have a checkbox similarly bound (with no transform) and that 
 works fine both ways. 
 
 This is my first foray into bindings .. what could I be doing wrong? Do I 
 need to express a simple NSString property on the model object and bind that 
 instead and do the NSString/NSURL conversion there? 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: RSA and libcrypto (sorry - typos fixed)

2014-01-12 Thread Dave Fernandes
On OS X, you can use security transforms to do RSA encryption/decryption and 
signing/verification. On iOS, security transforms are not available.

On Jan 12, 2014, at 5:07 PM, jonat...@mugginsoft.com wrote:

 
 I am trying to wean my app off libcrypto via security.framework and common 
 crypto.
 
 My last dependency is on RSA.
 Is there an alternative non openssl api or will I have to pursue linking a 
 static instance of libcrypto?
 
 Thanks 
 
 Jonathan
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: RSA and libcrypto (sorry - typos fixed)

2014-01-12 Thread Dave Fernandes
(Sigh) That’s what I get for relying on memory. I guess I’ve only ever used it 
for signing/verifying. Thanks for correcting.

On Jan 12, 2014, at 7:26 PM, Charles Srstka cocoa...@charlessoft.com wrote:

 On Jan 12, 2014, at 6:16 PM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 On OS X, you can use security transforms to do RSA encryption/decryption and 
 signing/verification.
 
 Not true:
 
 https://developer.apple.com/library/mac/documentation/security/conceptual/SecTransformPG/EncryptionandDecryption/EncryptionandDecryption.html
 
 Note: The security transforms API supports only symmetric encryption and 
 decryption. For asymmetric encryption and decryption, you must use a 
 lower-level API, such as [the deprecated] CDSA. For more information, see the 
 CryptoSample sample project.
 
 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: Threaded drawing

2013-12-11 Thread Dave Fernandes
Is there any way to zoom in just one dimension?

On Dec 11, 2013, at 6:05 PM, David Duncan david.dun...@apple.com wrote:

 On Dec 11, 2013, at 8:05 AM, Jeffrey Oleander jgo...@yahoo.com wrote:
 
 * (The posted snippet from sample code was as clear as mud to me.  Why 
 powers of 4 (and -4) instead of 5 when we're talking about 5 levels of 
 detail?
 1/(2^2) - 2^2 = (1/4) - 4  means ...levelsOfDetail should be set to 5?!? 
 It needs more words, more context.)
 
 
 The base level of detail is a zoom level of 2^0 (1 level of detail only 
 allows for a single representation like that). Each additional level of 
 detail is a zoom level half that size smaller (thus a 2nd level if 2^-1x or 
 1/2x, then 2^-2x or 1/4x, etc). The bias adds to the base level’s exponent, 
 thus a bias of 2 means the base level if 2^2x (4x) zoom instead of 2^0x zoom.
 
 There are no powers of 4, (or 5 or any other except for 2). The level of 
 detail is range of the exponent, not the base.
 --
 David Duncan
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Can't get NSManagedObject subclass to release objects

2013-08-09 Thread Dave Fernandes
As Jerry said, you can't force the MOC to release a managed object. However, 
you CAN force it to turn managed objects into faults. Then in your override of 
-[NSManagedObject didTurnIntoFault], you can release the transient object. You 
will have to recreate the transient object on demand if the managed object is 
faulted back in.

On 2013-08-09, at 8:38 AM, Jerry Krinock je...@ieee.org wrote:

 
 
 On 2013 Aug 09, at 00:59, Rick Mann rm...@latencyzero.com wrote:
 
 I've tried calling -refreshObject:mergeChanges: on it, but that only seems 
 to reduce the retain count on my object by one.
 
 I presume that Xcode's Product  Profile  Leaks is available in iOS 
 projects.  You could run it and make sure you don't have a memory leak.
 
 What I really want is for Core Data to just let my objects go when I'm no 
 longer strongly referencing them.
 
 I vaguely recall that maybe Core Data is not guaranteed to release managed 
 objects until their owning managed object context is deallocced.  You may 
 need to fetch objects you want released in a different, temporary moc.
 
 Anyhow, maybe my wild guesses will inspire someone to jump in and correct 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: IOS floating point performance

2013-08-08 Thread Dave Fernandes

On 2013-08-08, at 1:26 PM, David Rowland rowla...@sbcglobal.net wrote:

 The functions are probably very carefully written and could not be improved 
 by table lookups, vector libraries, etc. That is barking up the wrong tree. 

vForce is a library of highly optimized transcendental functions (e.g. sin, 
cos, exp). In cases where a large amount of data needs to be processed by 
applying the same transcendental function, vForce routines can provide 
significant performance enhancements.

https://developer.apple.com/library/mac/#featuredarticles/AccelerateFrameworkData/_index.html
___

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: Recomputing non-standard Core Data attributes when child MOC is saved?

2013-06-19 Thread Dave Fernandes

On 2013-06-19, at 3:21 AM, Rick Mann rm...@latencyzero.com wrote:

 
 On Jun 18, 2013, at 22:42 , Dave Fernandes dave.fernan...@utoronto.ca wrote:
 
 The foolproof way to do it is to have the transient attributes recalculated 
 each time they are accessed. In other words, they are simply getter methods. 
 But if they are expensive to compute, this might not work well. If you are 
 using bindings or KVO, you then have a class method + 
 (NSSet*)keyPathsForValuesAffectingAttributeName that ensures observers of 
 the transient attribute are notified when underlying non-transient 
 attributes change.
 
 In this case, it's not accessed terribly frequently, so that's what I ended 
 up doing. I do use KVO a lot, although I don't see how that helps in this 
 case (to trigger re-computing the transient value).

It's not useful if you want to pre-compute and cache the transient values. It 
is just useful if the transient is a getter, and you need to notify the 
observers.

 
 Pity there's not an update method that can be overridden in 
 NSManagedObjectSubclasses when this happens. I guess my objects could KVO 
 themselves…
 
 -- 
 Rick
 
 
 


___

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

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

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

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

Re: core data lightweight migration woes

2013-06-18 Thread Dave Fernandes
cc'ing the list this time…

On 2013-06-18, at 2:26 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote:

 
 On Jun 18, 2013, at 08:08 AM, Jerry Krinock je...@ieee.org wrote:
 
 
 On 2013 Jun 17, at 21:13, Martin Hewitson martin.hewit...@aei.mpg.de wrote:
 
 I did try making a mapping model (this is something I've done in the past 
 in other apps) but I got the same error message.
 
 Oh, well.
 
 Is the idea that the auto-migration magic will pick up the mapping model 
 and use it, if it finds it? 
 
 Yes.  I think the only three things you need do are to specify the current 
 version, and add .xcdatamodel and .xcmappingmodel files to your app target.  
 Xcode compiles the .xcdatamodel files into .mom files that all get put into 
 a .momd folder which also contains a VersionInfo.plist that specifies the 
 current version and the hashes for the entities in each version; also it 
 compiles each .xcmappingmodel files into a .cdm file.  Finally, the .momd 
 folder and all the .cdm files get packaged into your product's Resources.  
 Given those pieces, it's a pretty easy reverse-engineering exercise to 
 figure out what the auto-migration magic must be doing.
 
 According to your description, my app bundle's in good shape. I tried making 
 a mapping model and the cdm file shows up in Resources, as expected. The momd 
 folder contains all the expected mom and one omo file.
 
 
 Lately, Xcode has also been adding a .omo file, just one, named for the 
 current version, to the .momd.  On Stack Overflow, 'Bobson' guessed that 
 this was the same data [as the .mom file], organized differently.  
 Probably not a bad guess.  Maybe optimized for faster access by Mountain 
 Lion or something.
 
 Yes, I just noticed this ono file in the app bundle. I was wondering what 
 that was...
 
 snip
 
 Then I go to open an existing document and I get the dreaded  migration 
 failed, missing source managed object model error.
 
 
 After writing this message, you know I think it's more likely that you 
 screwed up and did this…
 
 • Change the data model a little.
 • Create a document, E.
 • Get interrupted by a fire drill.
 • Change the data model a little more.
 • Build.
 
 In this case, indeed *no* version of your app will ever be able to open that 
 document E.  If this is your existing document, the migration failed, 
 missing source managed object model error is expected.
 
 I don't think this is the case since I can still drop back to version 11 and 
 open the 'existing' document. I just made a test app and managed to perform a 
 lightweight migration much like the one I'm trying here, so I guess I'm doing 
 something wrong. I'll try to absorb your other detailed comments and see if I 
 can get some more debug output to figure out what's going on. 
 
 I just had another thought I have another core data model in the app. I 
 wonder if the NSPersistentDocument infrastructure is picking up the wrong 
 model? As I'm looking through the project, I realise I don't know how the 
 document knows which core data model to use OK, back to the documentation 
 on NSPersistentDocument.
 

By default it will merge all models in the main bundle. So if the other model 
changed, you would also have a problem. If you want to specify only one model 
for the document, you should override [NSPersistentDocument managedObjectModel].


 Thanks again,
 
 Martin
 
 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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

Re: core data lightweight migration woes

2013-06-18 Thread Dave Fernandes
What does your 
configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:
 do?

On 2013-06-18, at 5:09 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote:

 Another question on this problem: does anyone know if 
 NSStoreModelVersionIdentifiers is used in looking for a source model to infer 
 a mapping model from?
 
 To recap:
 
 1) Loading an existing document with the version 11 model works
 2) Adding a new version (12) with a single new boolean property on one entity 
 triggers an automatic migration but the source model is not found
 3) During the failure, all hashes match between the XML store and the current 
 model version except for the one entity I modified (so the migration is 
 correctly triggered)
 4) I've confirmed the source model can be loaded in principle by using 
 -metadataForPersistentStoreOfType: and 
 -mergedModelFromBundles:forStoreMetadata:
 5) With the new version 12 model I can successfully create new documents then 
 save and load them.
 6) Overriding -managedObjectModel in my NSPersistentDocument to ensure the 
 correct momd is loaded doesn't fix the problem.
 
 I'm at a bit of a loss what to try next
 
 Martin
 
 
 On Jun 18, 2013, at 08:38 AM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 cc'ing the list this time…
 
 On 2013-06-18, at 2:26 AM, Martin Hewitson martin.hewit...@aei.mpg.de 
 wrote:
 
 
 On Jun 18, 2013, at 08:08 AM, Jerry Krinock je...@ieee.org wrote:
 
 
 On 2013 Jun 17, at 21:13, Martin Hewitson martin.hewit...@aei.mpg.de 
 wrote:
 
 I did try making a mapping model (this is something I've done in the past 
 in other apps) but I got the same error message.
 
 Oh, well.
 
 Is the idea that the auto-migration magic will pick up the mapping model 
 and use it, if it finds it? 
 
 Yes.  I think the only three things you need do are to specify the current 
 version, and add .xcdatamodel and .xcmappingmodel files to your app 
 target.  Xcode compiles the .xcdatamodel files into .mom files that all 
 get put into a .momd folder which also contains a VersionInfo.plist that 
 specifies the current version and the hashes for the entities in each 
 version; also it compiles each .xcmappingmodel files into a .cdm file.  
 Finally, the .momd folder and all the .cdm files get packaged into your 
 product's Resources.  Given those pieces, it's a pretty easy 
 reverse-engineering exercise to figure out what the auto-migration magic 
 must be doing.
 
 According to your description, my app bundle's in good shape. I tried 
 making a mapping model and the cdm file shows up in Resources, as expected. 
 The momd folder contains all the expected mom and one omo file.
 
 
 Lately, Xcode has also been adding a .omo file, just one, named for the 
 current version, to the .momd.  On Stack Overflow, 'Bobson' guessed that 
 this was the same data [as the .mom file], organized differently.  
 Probably not a bad guess.  Maybe optimized for faster access by Mountain 
 Lion or something.
 
 Yes, I just noticed this ono file in the app bundle. I was wondering what 
 that was...
 
 snip
 
 Then I go to open an existing document and I get the dreaded  migration 
 failed, missing source managed object model error.
 
 
 After writing this message, you know I think it's more likely that you 
 screwed up and did this…
 
 • Change the data model a little.
 • Create a document, E.
 • Get interrupted by a fire drill.
 • Change the data model a little more.
 • Build.
 
 In this case, indeed *no* version of your app will ever be able to open 
 that document E.  If this is your existing document, the migration 
 failed, missing source managed object model error is expected.
 
 I don't think this is the case since I can still drop back to version 11 
 and open the 'existing' document. I just made a test app and managed to 
 perform a lightweight migration much like the one I'm trying here, so I 
 guess I'm doing something wrong. I'll try to absorb your other detailed 
 comments and see if I can get some more debug output to figure out what's 
 going on. 
 
 I just had another thought I have another core data model in the app. I 
 wonder if the NSPersistentDocument infrastructure is picking up the wrong 
 model? As I'm looking through the project, I realise I don't know how the 
 document knows which core data model to use OK, back to the 
 documentation on NSPersistentDocument.
 
 
 By default it will merge all models in the main bundle. So if the other 
 model changed, you would also have a problem. If you want to specify only 
 one model for the document, you should override [NSPersistentDocument 
 managedObjectModel].
 
 
 Thanks again,
 
 Martin
 
 
 
 
 
 ___
 
 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

Re: core data lightweight migration woes

2013-06-18 Thread Dave Fernandes
Looks pretty standard, but I would try commenting out the call to 
setMetadataForStoreAtURL:
Besides that, I don't know what to suggest.

On 2013-06-18, at 11:14 AM, Martin Hewitson martin.hewit...@aei.mpg.de wrote:

 The code is below. Anything look suspicious there?
 
 Thanks,
 
 Martin
 
 - (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL*)url 
   ofType:(NSString*)fileType
   modelConfiguration:(NSString*)configuration
 storeOptions:(NSDictionary*)storeOptions
error:(NSError**)error
 {
  NSMutableDictionary *options = nil;
  if (storeOptions != nil) {
options = [storeOptions mutableCopy];
  } else {
options = [[NSMutableDictionary alloc] init];
  }
   
  options[NSMigratePersistentStoresAutomaticallyOption] = @YES;
  options[NSInferMappingModelAutomaticallyOption] = @YES;  
  BOOL result = [super configurePersistentStoreCoordinatorForURL:url
  ofType:fileType
  modelConfiguration:configuration
storeOptions:options
   error:error];
  options = nil;
 
  if (result) {
NSPersistentStoreCoordinator *psc = [[self managedObjectContext] 
 persistentStoreCoordinator];
NSPersistentStore *pStore = [psc persistentStoreForURL:url];
id existingMetadata = [psc metadataForPersistentStore:pStore][(NSString 
 *)kMDItemKeywords];
if (existingMetadata == nil) {
  result = [self setMetadataForStoreAtURL:url];
}  
  }
 
  return result;
 }
 
 
 
 
 On Jun 18, 2013, at 05:04 PM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 What does your 
 configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:
  do?
 
 On 2013-06-18, at 5:09 AM, Martin Hewitson martin.hewit...@aei.mpg.de 
 wrote:
 
 Another question on this problem: does anyone know if 
 NSStoreModelVersionIdentifiers is used in looking for a source model to 
 infer a mapping model from?
 
 To recap:
 
 1) Loading an existing document with the version 11 model works
 2) Adding a new version (12) with a single new boolean property on one 
 entity triggers an automatic migration but the source model is not found
 3) During the failure, all hashes match between the XML store and the 
 current model version except for the one entity I modified (so the 
 migration is correctly triggered)
 4) I've confirmed the source model can be loaded in principle by using 
 -metadataForPersistentStoreOfType: and 
 -mergedModelFromBundles:forStoreMetadata:
 5) With the new version 12 model I can successfully create new documents 
 then save and load them.
 6) Overriding -managedObjectModel in my NSPersistentDocument to ensure the 
 correct momd is loaded doesn't fix the problem.
 
 I'm at a bit of a loss what to try next
 
 Martin
 
 
 On Jun 18, 2013, at 08:38 AM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 cc'ing the list this time…
 
 On 2013-06-18, at 2:26 AM, Martin Hewitson martin.hewit...@aei.mpg.de 
 wrote:
 
 
 On Jun 18, 2013, at 08:08 AM, Jerry Krinock je...@ieee.org wrote:
 
 
 On 2013 Jun 17, at 21:13, Martin Hewitson martin.hewit...@aei.mpg.de 
 wrote:
 
 I did try making a mapping model (this is something I've done in the 
 past in other apps) but I got the same error message.
 
 Oh, well.
 
 Is the idea that the auto-migration magic will pick up the mapping 
 model and use it, if it finds it? 
 
 Yes.  I think the only three things you need do are to specify the 
 current version, and add .xcdatamodel and .xcmappingmodel files to your 
 app target.  Xcode compiles the .xcdatamodel files into .mom files that 
 all get put into a .momd folder which also contains a VersionInfo.plist 
 that specifies the current version and the hashes for the entities in 
 each version; also it compiles each .xcmappingmodel files into a .cdm 
 file.  Finally, the .momd folder and all the .cdm files get packaged 
 into your product's Resources.  Given those pieces, it's a pretty easy 
 reverse-engineering exercise to figure out what the auto-migration magic 
 must be doing.
 
 According to your description, my app bundle's in good shape. I tried 
 making a mapping model and the cdm file shows up in Resources, as 
 expected. The momd folder contains all the expected mom and one omo file.
 
 
 Lately, Xcode has also been adding a .omo file, just one, named for the 
 current version, to the .momd.  On Stack Overflow, 'Bobson' guessed that 
 this was the same data [as the .mom file], organized differently.  
 Probably not a bad guess.  Maybe optimized for faster access by Mountain 
 Lion or something.
 
 Yes, I just noticed this ono file in the app bundle. I was wondering what 
 that was...
 
 snip
 
 Then I go to open an existing document and I get

Re: Recomputing non-standard Core Data attributes when child MOC is saved?

2013-06-18 Thread Dave Fernandes
The foolproof way to do it is to have the transient attributes recalculated 
each time they are accessed. In other words, they are simply getter methods. 
But if they are expensive to compute, this might not work well. If you are 
using bindings or KVO, you then have a class method + 
(NSSet*)keyPathsForValuesAffectingAttributeName that ensures observers of the 
transient attribute are notified when underlying non-transient attributes 
change.

On 2013-06-18, at 10:08 PM, Rick Mann rm...@latencyzero.com wrote:

 
 On Jun 18, 2013, at 19:07 , Laurent Daudelin laur...@nemesys-soft.com wrote:
 
 Just a wild guess but what about awakeFromInsert?
 
 Well, I think that only gets called when you first create the object. In my 
 case, objects already exist.
 
 -- 
 Rick
 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: App store reject on asl log. How else do I get at the log messages?

2013-05-30 Thread Dave Fernandes
Not sure if this meets sandboxing requirements, but you can redirect the 
console log in main.c:

freopen([APP_LOG_PATH fileSystemRepresentation], a, stderr); 

Surround this in @autoreleasepool{} if you need ARC memory management to create 
your path string.

On 2013-05-30, at 5:46 PM, Gideon King gid...@novamind.com wrote:

 Hi,
 
 My app was rejected from the store because I wanted the entitlement:
 
 com.apple.security.temporary-exception.files.absolute-path.read-only - 
 /private/var/log/asl/ 
 
 I need this so I can use the asl_new, asl_set_query, asl_search, 
 aslresponse_next, asl_get, and aslresponse_free to be able to get the log 
 messages for my application when people submit a bug report.
 
 The app store rejection told me that I need to investigate other ways of 
 implementing the desired functionality.
 
 Are there other ways of getting at the console log entries for my app so I 
 can get them sent to me with bug reports?
 
 
 Regards
 
 Gideon
 
 
 
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: rate limiting calls

2013-05-28 Thread Dave Fernandes
I use the GCD serial queue approach. On each update from the slider, cancel all 
operations in the queue and then add a new operation with the latest slider 
value. However, the NSOperation subclass should NOT check whether it is 
cancelled once it starts executing. That way, once it starts, it is assured to 
complete and you will get periodic updates.

On 2013-05-28, at 12:29 PM, Torsten Curdt tcu...@vafer.org wrote:

 Hm - this does not seem to work and I cannot see why not.
 
 The cancel and perform selector calls are being called but updateValue
 is only performed when I release the slider handle.
 I don't quite get why.
 
 Would still be eager to know why but a GCD implementation was super
 simple and works.
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: rate limiting calls

2013-05-28 Thread Dave Fernandes
Er, that would be NSOperationQueue. Haven't had my coffee yet today.

On 2013-05-28, at 1:17 PM, Kyle Sluder k...@ksluder.com wrote:

 On May 28, 2013, at 10:12 AM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 I use the GCD serial queue approach. On each update from the slider, cancel 
 all operations in the queue and then add a new operation with the latest 
 slider value. However, the NSOperation subclass should NOT check whether it 
 is cancelled once it starts executing. That way, once it starts, it is 
 assured to complete and you will get periodic updates.
 
 So which are you using, NSOperationQueue or GCD?
 
 --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: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Dave Fernandes
Forgive the basic question, but do you still have the old version of the model 
present in your versioned model?

On 2013-05-28, at 10:18 PM, Rick Mann rm...@latencyzero.com wrote:

 In the past, Core Data was able to deal with a simple addition of a property 
 to an Entity. Now, every time I add a property, I get Can't find model for 
 source store errors during auto update.
 
 I'm using the following options when creating the persistent store 
 coordinator:
 
   NSDictionary* options = @{ NSMigratePersistentStoresAutomaticallyOption 
 : @true,
   NSInferMappingModelAutomaticallyOption 
 : @true };
 
 Am I doing something wrong?
 
 Thanks,
 
 -- 
 Rick
 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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


Re: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Dave Fernandes
I think I have gotten away with that for development purposes in the past, but 
that isn't the way it is supposed to work. And things have definitely been 
tightened up as Core Data has evolved. If you want to open old persistent 
stores, you will need to have a copy of the model that goes with it.

On 2013-05-29, at 12:02 AM, Rick Mann rm...@latencyzero.com wrote:

 
 On May 28, 2013, at 20:50 , Dave Fernandes dave.fernan...@utoronto.ca wrote:
 
 Forgive the basic question, but do you still have the old version of the 
 model present in your versioned model?
 
 That's an excellent question, and no, I don't. But I still thought I've 
 successfully added properties without actually making different versions. 
 During development, I'm making lots of such changes, and I never make a new 
 file until the previous one has been released in the wild.
 
 -- 
 Rick
 
 
 


___

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: Shape of a knotty(?) threading problem

2013-03-25 Thread Dave Fernandes
Correct me if my understanding is incorrect:
Your input logic processes some input on thread 1 until it settles. It then 
signals the 6502 object that input is available and waits until the 6502 
picks up (copies) this data. The 6502 picks up the input data, and starts 
processing it on thread 2; and also tells the input logic that it can start 
processing the next round of input.

If this is the case, then you can handle the synchronization with a shared 
dispatch semaphore. The 6502 thread waits on this semaphore, and the input 
logic thread signals the semaphore when it has settled. Once it signals the 
semaphore, it exits, and a new input logic operation is queued 
(dispatch_async) by the 6502 once it has copied the state from the input logic. 
Once the 6502 has finished processing its input, it again waits on the 
semaphore.

On 2013-03-25, at 8:45 PM, Graham Cox graham@bigpond.com wrote:

 Hi,
 
 I'm trying to solve a fairly complicated problem, and I think threading will 
 be a solution, but it's not something I'm a great expert on, so I'm hoping 
 that someone will be kind enough to help me form the general shape of the 
 solution. At first this might not seem to be a Cocoa question but it is, 
 because everything I will describe is implemented in Cocoa and the solution 
 must be too.
 
 I have a largeish body of code that implements the data model for a digital 
 logic simulator. This simulator simulates down to the gate level (e.g. the 
 simplest functional block is a single NOT gate)  and is a cycle-based 
 simulator. The exact details of its operation aren't that important, but 
 broadly it consists of two kinds of objects, devices and inputs. A device is 
 a functional block, such as a gate, but could be anything that implements 
 some logical function in terms of inputs, outputs, time and its own state. If 
 that sounds vague it probably is, but the idea is that more complex functions 
 can be simulated in code for performance - in other words it is not 
 *required* to simulate at the gate level, but it can. Inputs represent a 
 single logic signal in the system, i.e. 1 bit or wire. Outputs are a subclass 
 of inputs and form the network of connections between devices, passing data 
 from output to input(s) representing logic level signals.
 
 The simulation runs in a cycle, which is a great big loop that iterates over 
 the devices and tells each one to evaluate its inputs + current time + 
 current state as needed and set its outputs. The outputs drive further inputs 
 and so on. Note that changing an input does not immediately trigger 
 evaluation of a device's function. This allows arbitrary feedback loops in a 
 network without creating infinite recursion in code (where setting an output 
 sets an input which in turn sets the same output, etc). The cycling ensures 
 everything proceeds in an orderly fashion and feedback connections work 
 correctly without any special kludges (as an aside a very popular logic 
 simulator doesn't do this but has a nasty kludge that detects if a function 
 recurses more than 99 times before telling the user they're a bozo. Needless 
 to say it severely limits the kinds of circuits that can be simulated). It 
 also means that the cycle time of the whole simulation is a sort of atomic 
 time which sets a lower limit on how fast a device can respond, and as a 
 circuit grows in complexity the time for the simulation to settle to its 
 final correct state can vary quite a lot. This is fine, because it can be 
 taken to simulate, roughly, real-world propagation delays and settling times. 
 However, it is rather indeterminate, since the simulation has no concept of 
 the order in which devices need to be evaluated - indeed, devices are held 
 by an NSSet so the evaluation order is arbitrary. Worst case, the state of a 
 system might only settle after n cycles where n is the number of devices, 
 best case it would settle in 1 cycle. Typically it's somewhere in between. 
 This doesn't have any bearing on the functional correctness of the 
 simulation, but it does for the problem I'm working around to. (If this 
 sounds wrong to you, consider that most circuits don't have any order once 
 you have feedback and loops - where do you jump in?). Note that an 
 optimisation in the system means that devices skip evaluation if their inputs 
 haven't changed since the previous iteration, but if they are time-sensitive 
 this optimisation can be opted out of. I mention this for completeness, I 
 don't think it matters for the problem. Another thing to be aware of is that 
 the simulation cycle itself can either be run on its own thread, or hitch a 
 ride on the main thread. The simulator works beautifully and so far hasn't 
 failed to correctly simulate any logic circuit I've put together with it.
 
 Now, I want to add a device to the system that can emulate a microprocessor. 
 (I happen to have chosen the venerable 6502 to start, but this is a generic 
 problem). I 

Re: Shape of a knotty(?) threading problem

2013-03-25 Thread Dave Fernandes

On 2013-03-25, at 11:03 PM, Graham Cox graham@bigpond.com wrote:

 
 On 26/03/2013, at 1:31 PM, Dave Fernandes dave.fernan...@utoronto.ca wrote:
 
 Correct me if my understanding is incorrect:
 Your input logic processes some input on thread 1 until it settles. It 
 then signals the 6502 object that input is available and waits until the 
 6502 picks up (copies) this data. The 6502 picks up the input data, and 
 starts processing it on thread 2; and also tells the input logic that it can 
 start processing the next round of input.
 
 If this is the case, then you can handle the synchronization with a shared 
 dispatch semaphore. The 6502 thread waits on this semaphore, and the input 
 logic thread signals the semaphore when it has settled. Once it signals the 
 semaphore, it exits, and a new input logic operation is queued 
 (dispatch_async) by the 6502 once it has copied the state from the input 
 logic. Once the 6502 has finished processing its input, it again waits on 
 the semaphore.
 
 
 I think that sounds about right - one problem for me is that I'm not 
 super-familiar with the terminology. (e.g. shared dispatch semaphore). Is 
 that a mutex?

Sorry - sloppy terminology. I meant a GCD semaphore that is shared by both 
threads to synchronize them. GCD semaphores are counting semaphores rather than 
mutexes. In this case, it is only counting between 0 and 1. The consumer thread 
(6502) waits on the semaphore as long as the semaphore's count is 0. When the 
count is incremented by the producer thread (input logic), the 6502 thread 
unblocks and knows that it has data available.

This is all C API (GCD). There is no Cocoa involved.

// Create the semaphore.
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);

// Give a reference to both tasks that need it…

// Wait on the semaphore in the 6502 thread.
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);

// You can wait less than forever here if you want to check periodically 
whether you should cancel.

// Increment the semaphore's count in the producer thread.
dispatch_semaphore_signal(semaphore);

// The producer thread should exit or stop producing further output until the 
6502 has copied the produced data.

.
.
.
// Delete the semaphore when you are done.
dispatch_release(semaphore);

 
 What Cocoa object corresponds to that? I thought NSConditionLock but having 
 had a stab at an implementation using it it doesn't seem quite right - I get 
 errors logged that it is being unlocked from a different thread than the one 
 that locked it. Hmmm, yes, I thought that was the point but perhaps not. More 
 suitable might be NSCondition. Or.?
 
 
 --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

Syncing CATiledLayer drawInContext: with setAffineTransform:

2013-03-01 Thread Dave Fernandes
I'm using a CATiledLayer to plot a stream of data points in real-time on iOS 6. 
When the user pinches to zoom in either X or Y, I need to zoom the plot. To 
avoid lots of flashing during redraws, I use an affine transform *during* the 
zoom gesture, but then redraw the plot after the gesture is complete.

This works, but there is an instant where I need to transition from the 
zoomed-by-transform plot to the zoomed-by-redrawing plot. Where is the 
appropriate place to reset the transform to the identity transform? Doing it in 
drawInContext: seems to work most but not all of the time (sometimes it flashes 
or fails to redraw correctly - presumably a race condition). Ditto for a 
dispatch_async to the main queue.

Note: all drawing in drawInContext is done using CGContextXXX methods.

I am going about this the wrong way?

Thanks,
Dave
___

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: converting coredata files

2013-02-07 Thread Dave Fernandes
Can you post the exact error message or error code you get?

I don't remember how migration worked in Leopard (I skipped from Tiger to Snow 
Leopard), but can you post the code snippet that does the migration?

On 2013-02-07, at 9:34 AM, Amy Gibbs a...@willowtreecrafts.co.uk wrote:

 I've installed 10.5 and Xcode 3 on an external drive to try and solve this. 
 I've created a new data model changing the Idea.description to 
 Idea.ideaDescription and created a mapping model to manage the change, 
 however when I try to run it with the data file it says it is missing the 
 persistent store, the same happens when I try to simply delete the 
 Idea.description and create a mapping model as well.
 
 Anyone any idea how I can fix this? My data is in an sql store which makes it 
 difficult to manipulate.
 
 I don't mind loosing all of the Idea entities, but I have other entities that 
 I really don't want to loose.
 
 Many Thanks,
 
 Amy
 
 On 2 Feb 2013, at 7:28PM, Dave Fernandes dave.fernan...@utoronto.ca wrote:
 
 
 On 2013-02-02, at 2:09 PM, Amy Heavey a...@willowtreecrafts.co.uk wrote:
 
 Hi,
 
 I've got an app that I write for myself (I am the only user). I made a 
 mistake when creating the datamodel in xcode 3 (targeting 10.5), I used 
 description as an attribute name. I have now upgraded and the current 
 xcodes do not like the project file at all. 
 
 I've got quite a lot of data in this app that I really don't want to loose. 
 It uses an sql store.
 
 Somehow I need to create a new app for 10.8 that will use the old file, or 
 find a way to convert the old file to work with a new app. The new app will 
 be almost the same but only have the current datamodel.
 
 Can I create an intermediate datamodel in xcode 3 that removes the error 
 from the file, and create an app. Open the file with this version to 
 upgrade it to the current datamodel. Then create an xcode project without 
 the old datamodels and use that?
 
 Yes, this makes sense.
 
 I'm not sure if you also need to run your converter app on an older version 
 of the OS.
 
 
 Does this make sense?
 
 Many Thanks,
 
 Amy
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.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: converting coredata files

2013-02-07 Thread Dave Fernandes

On 2013-02-07, at 2:38 PM, Charles Srstka cocoa...@charlessoft.com wrote:

 On Feb 2, 2013, at 1:09 PM, Amy Heavey a...@willowtreecrafts.co.uk wrote:
 
 I've got an app that I write for myself (I am the only user). I made a 
 mistake when creating the datamodel in xcode 3 (targeting 10.5), I used 
 description as an attribute name. I have now upgraded and the current 
 xcodes do not like the project file at all. 
 
 I've got quite a lot of data in this app that I really don't want to loose. 
 It uses an sql store.
 
 Somehow I need to create a new app for 10.8 that will use the old file, or 
 find a way to convert the old file to work with a new app. The new app will 
 be almost the same but only have the current datamodel.
 
 Can I create an intermediate datamodel in xcode 3 that removes the error 
 from the file, and create an app. Open the file with this version to upgrade 
 it to the current datamodel. Then create an xcode project without the old 
 datamodels and use that?
 
 Things like this are part of why the concept of CoreData makes me a bit 
 uncomfortable — you don't have control of your own file format. If the format 
 for this were open, building a converter to fix your problem would be a snap.
 
 Since your problem is relatively simple, though, it might not be too hard to 
 reverse-engineer. You could just go through one of your files with the 
 /usr/bin/sqlite3 tool, figure out where it's storing the description 
 attribute name, and then make a program using libsqlite3 to make a new sqlite 
 database and copy everything exactly from the old one to the new one, with 
 the exception that it changes the description attribute name to something 
 else when it comes across it.

You can also convert the store to XML without migrating the model and make 
changes there.

 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

Do CALayer filters apply to non-image drawing?

2013-02-05 Thread Dave Fernandes
I'm trying to apply a bloom effect to shapes drawn in a CALayer subclass 
(drawInContext: method). This is on iOS 6 in the simulator. The CIBloom filter 
is created, but it doesn't seem to affect the layer's rendering. My 
understanding is that CALayer's filters property should work on iOS 6. But 
perhaps it only applies to the contents object and not other drawing? Can 
anyone confirm whether this should work?

Thanks,
Dave

Code to add the filter in the layer subclass's init method:

CIFilter* filter = [CIFilter filterWithName:@CIBloom];
[filter setDefaults];
self.filters = @[filter];


___

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: Do CALayer filters apply to non-image drawing?

2013-02-05 Thread Dave Fernandes
OK. Thanks for the quick and definitive reply. I'll file a bug report on the 
CALayer class reference - it is a bit misleading.

Dave

On 2013-02-05, at 3:55 PM, David Duncan david.dun...@apple.com wrote:

 On Feb 5, 2013, at 12:29 PM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 My understanding is that CALayer's filters property should work on iOS 6.
 
 
 Unfortunately this is incorrect. The filter properties on CALayer do not 
 work, which is why you don't get the bloom effect.
 
 For the record, on OS X where they do work, the way you get content into the 
 layer does not matter.
 --
 David Duncan
 


___

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: converting coredata files

2013-02-02 Thread Dave Fernandes

On 2013-02-02, at 2:09 PM, Amy Heavey a...@willowtreecrafts.co.uk wrote:

 Hi,
 
 I've got an app that I write for myself (I am the only user). I made a 
 mistake when creating the datamodel in xcode 3 (targeting 10.5), I used 
 description as an attribute name. I have now upgraded and the current 
 xcodes do not like the project file at all. 
 
 I've got quite a lot of data in this app that I really don't want to loose. 
 It uses an sql store.
 
 Somehow I need to create a new app for 10.8 that will use the old file, or 
 find a way to convert the old file to work with a new app. The new app will 
 be almost the same but only have the current datamodel.
 
 Can I create an intermediate datamodel in xcode 3 that removes the error from 
 the file, and create an app. Open the file with this version to upgrade it to 
 the current datamodel. Then create an xcode project without the old 
 datamodels and use that?

Yes, this makes sense.

I'm not sure if you also need to run your converter app on an older version of 
the OS.

 
 Does this make sense?
 
 Many Thanks,
 
 Amy
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: FileWrapper iCloud

2012-12-01 Thread Dave Fernandes

On 2012-12-01, at 11:42 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote:
 One way to look at it is that NSPersistentDocument pretty much painted 
 itself into a corner from day 1, and it's too messy for Apple to untangle 
 that.
 
 Can you elaborate?
 
 Well it makes the assumptions that your document:
 
 - is comprised of a single Core Data store
 - has a single managed object context
 
 This definitely limits your options. But, is it necessary to support file 
 wrappers and iCloud? (Just trying to educate myself about how documents 
 work.)
 
 I don't understand your question here. Are you asking if my list of 
 assumptions are necessary conditions for iCloud and file wrapper support?

Yes, that was basically the question. For example, what if you were just using 
file wrappers to store images outside the persistent store.

 - works entirely on the main thread
 This one is already opt-in for both opening and saving, so fragility 
 shouldn't be an issue to upgrading the class.
 
 [Aside: As far as I know you *can* actually open an NSPersistentDocument 
 asynchronously. At least I haven't seen anything that says you can't, and it 
 seems to work on every system I've tried it on.]
 
 Well you would appear to be breaking Core Data's threading contract by doing 
 so. In theory, MOCs know the thread they were created on. So by creating the 
 document on a background thread, you are also creating the MOC on that thread 
 and giving it the wrong idea about the thread it will be used on.

NSPersistentDocument always creates a MOC of type NSMainQueueConcurrencyType, 
even if it is created on a background thread. So as long as things don't go 
wrong during document opening, everything will be the same as a document opened 
on the main thread forever after.

I believe, the window controller and view objects are always created on the 
main thread after the MOC has been initialized, so there won't be any 
contention with trying to access the MOC from different threads at the same 
time.

This is all identical on 10.6 and 10.7+.

 
 On 10.7+ you can of course tell the context at creation time it's for the 
 main thread, but I'd be a little surprised if NSPersistentDocument is doing 
 that.
 
 I also covered the topic fairly recently: 
 http://www.mikeabdullah.net/concurrently-open-core-data-docs.html
 


___

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: FileWrapper iCloud

2012-12-01 Thread Dave Fernandes
 NSPersistentDocument always creates a MOC of type NSMainQueueConcurrencyType, 
 even if it is created on a background thread. So as long as things don't go 
 wrong during document opening, everything will be the same as a document 
 opened on the main thread forever after.

Whoops! I meant to say NSPersistentDocument always creates a MOC of type 
**NSConfinementConcurrencyType** -- the legacy type that assumes you know what 
you are doing and will manage access accordingly.
___

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: FileWrapper iCloud

2012-12-01 Thread Dave Fernandes

On 2012-12-01, at 5:12 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 - is comprised of a single Core Data store
 - has a single managed object context
 
 This definitely limits your options. But, is it necessary to support file 
 wrappers and iCloud? (Just trying to educate myself about how documents 
 work.)
 
 I don't understand your question here. Are you asking if my list of 
 assumptions are necessary conditions for iCloud and file wrapper support?
 
 Yes, that was basically the question. For example, what if you were just 
 using file wrappers to store images outside the persistent store.
 
 My understanding is that if you want anything to be persisted outside of Core 
 Data, you get treated just like a regular NSDocument subclass. i.e. no 
 attempt to sync by SQLite changes.
 
 On OS X the docs state that NSPersistentDocument is flat-out not supported 
 for iCloud.
 
 On iOS, the docs state that UIManagedDocument does not support additional 
 content when used for iCloud. I assume the reason is that the moment you add 
 into the mix some data outside of Core Data’s control/knowledge, iCloud has 
 no smart way to sync it, so you’re giving up that major benefit of Core Data. 
 Of course Core Data supports externally stored data attributes these days, so 
 that does improve the situation.
 
 At that point I figure it’s best and easiest to subclass NSDocument afresh to 
 add Core Data support, rather than try to bend NSPersistentDocument to your 
 bidding. This is what I have done with BSManagedDocument.

Looks like an extremely useful class. Thank you for sharing it!

Dave
___

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: FileWrapper iCloud

2012-12-01 Thread Dave Fernandes

On 2012-12-01, at 5:05 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 On 1 Dec 2012, at 20:21, Dave Fernandes wrote:
 
 NSPersistentDocument always creates a MOC of type 
 NSMainQueueConcurrencyType, even if it is created on a background thread. 
 So as long as things don't go wrong during document opening, everything 
 will be the same as a document opened on the main thread forever after.
 
 Whoops! I meant to say NSPersistentDocument always creates a MOC of type 
 **NSConfinementConcurrencyType** -- the legacy type that assumes you know 
 what you are doing and will manage access accordingly.
 
 But the Core Data team have said for years that MOCs created on the main 
 thread get some special treatment.

I guess I missed that somewhere. Was it on this list?

 Of course they’ve never given us any specifics. The docs state very clearly 
 that MOCs (using the non-private queue types) should be created on the same 
 thread/queue that they’ll be used on.

They do say that clearly, and if you follow that you are less likely to get 
into trouble; but they go on to explain that you *can* access a MOC from 
different threads as long as you take responsibility for serializing access. 
(If You Don’t Use Thread Containment section from the Core Data Programming 
Guide)

With concurrent opening, there is no way to use NSLocking in the background 
thread if the frameworks are not doing it for you, but since you only get hold 
of the MOC after the background thread has completed its work, you should not 
need to lock from that point on.

-d
___

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: FileWrapper iCloud

2012-11-30 Thread Dave Fernandes

On 2012-11-30, at 6:42 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 
 On 30 Nov 2012, at 01:16, Sean McBride s...@rogue-research.com wrote:
 
 On Fri, 30 Nov 2012 00:43:36 +, Mike Abdullah said:
 
 With all the different features of the document system these days, it
 can be pretty hard to slot them all in nicely with Core Data. People may
 find https://github.com/karelia/BSManagedDocument pretty handy for this
 (the real meat is in the header file at present)
 
 Wow, that looks pretty awesome if it does all that is advertised.  It's only 
 700 LOC, which really does make me wonder why NSPersistentDocument can't do 
 all these things.  Core Data didn't get any love in 10.8 at all.  The 
 conspiracy theorist in me wonders...
 
 One way to look at it is that NSPersistentDocument pretty much painted itself 
 into a corner from day 1, and it's too messy for Apple to untangle that.

Can you elaborate?


___

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: FileWrapper iCloud

2012-11-30 Thread Dave Fernandes

On 2012-11-30, at 4:46 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 
 On 30 Nov 2012, at 18:59, Dave Fernandes dave.fernan...@utoronto.ca wrote:
 
 
 On 2012-11-30, at 6:42 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote:
 
 One way to look at it is that NSPersistentDocument pretty much painted 
 itself into a corner from day 1, and it's too messy for Apple to untangle 
 that.
 
 Can you elaborate?
 
 Well it makes the assumptions that your document:
 
 - is comprised of a single Core Data store
 - has a single managed object context

This definitely limits your options. But, is it necessary to support file 
wrappers and iCloud? (Just trying to educate myself about how documents work.)

 - works entirely on the main thread
This one is already opt-in for both opening and saving, so fragility shouldn't 
be an issue to upgrading the class.

[Aside: As far as I know you *can* actually open an NSPersistentDocument 
asynchronously. At least I haven't seen anything that says you can't, and it 
seems to work on every system I've tried it on.]

 - only ever saves on top of itself, or to a new location using Save As

I guess this is an implementation detail to me. I want to manage the data model 
and let the framework classes handle the document stuff. If they could add 
all the Lion document behaviors to NSPersistentDocument, I don't see how they 
couldn't add file wrapper support. But then, I've never tried. (I have filed 
plenty of bug reports though. :)

 
 I wonder if there's simply too much fragility in the existing subclasses that 
 people have shipped, which make it a royal pain to try and modernise.
 


___

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: nssound question

2012-11-21 Thread Dave Fernandes
In System Preferences  Sound, there is a setting to Play sound effects 
through… I believe this changes where alert sounds are played. I expect 
NSSound by default uses the selected sound output device (selected in the 
Output tab of the preference panel). But it seems to have a 
setPlaybackDeviceIdentifier: method that I've never tried using.

Dave

On 2012-11-21, at 9:04 PM, Keary Suska cocoa-...@esoteritech.com wrote:

 On Nov 21, 2012, at 3:54 PM, Rick C. wrote:
 
 In my project there are times I call NSBeep and times when I use NSSound and 
 play one of Finder's system sounds that have to do with file-movement (for 
 example the undo sound).  Problem is NSBeep gets played through the user's 
 internal Mac speakers where as using NSSound is played through a user's 
 external speakers assuming they are using them.  This can make a big 
 difference in sound volume.  Is there any solution/workaround for this?  Or 
 just to make a preference to disable the calls to NSSound?  Thanks for the 
 input,
 
 Are you sure this is the case? All sounds (including system beeps) on my Macs 
 always play through external speakers when connected, and I don't seem to 
 have any way to tell it otherwise…
 
 HTH,
 
 Keary Suska
 Esoteritech, Inc.
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Creating CoreData Configurations in xcode

2012-11-03 Thread Dave Fernandes
[followup to question on xcode-users list]

Just curious why you are using configurations. I've never found them to be 
useful for anything. My hope was that I wouldn't have to migrate some types of 
documents as often if the only entities that changed were not part of that 
document type's configuration. But that wasn't the case. All document types had 
to be migrated if an entity in any configuration in the model changed. So what 
are configurations useful for?

Dave

On 2012-11-03, at 3:16 PM, Gordon Apple g...@ed4u.com wrote:

 Could somebody explain to me how to create CoreData configurations in xcode 
 or point me to the appropriate docs?  I currently have a data model with 21 
 entities.  I use the same model for two different document types and would 
 like to add a third.  These each use subsets of the (default) configuration 
 entities.  I thought “addConfiguration” would give me a new screen with a 
 copy of the original defaults, so I could delete what is not needed for each 
 configuration and add other entities as needed.  Apparently, it doesn’t work 
 that way and I haven’t figured out how to do it.
 ___
 Do not post admin requests to the list. They will be ignored.
 Xcode-users mailing list  (xcode-us...@lists.apple.com)
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/xcode-users/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Programmatically providing default value for new core data attribute?

2012-10-31 Thread Dave Fernandes
[resent to list-serve]

You can create a subclass of NSEntityMigrationPolicy, then specify this class 
in the Custom Policy for that entity in your mapping model. During migration, 
the createDestinationInstancesForSourceInstance method of your migration 
policy class will be called, and can fill in the value for the new attribute.

Note that the object you will get to work with will be a generic 
NSManagedObject, and not any subclass you have defined for that entity. So if 
you need your subclass methods, or if you need to access other entities, and 
not just the one you are handed, you will need to do that AFTER migration has 
completed.

Dave

On 2012-10-31, at 5:44 AM, Rick Mann rm...@latencyzero.com wrote:

 Hi. I've added a simple attribute to my model that should be a concatenation 
 of a handful of other attributes, run through some code. I don't suppose 
 there's any way to do the lightweight migration but tell it, here's a method 
 to call to get the default value of this property?
 
 I looked at doing a mapping model, but even that just has me build the value 
 in there; no apparent way to run it through my code.
 
 Given that, I can let lightweight migration do its thing, then post-process 
 it, but I don't see a way to determine that lightweight migration ran when I 
 opened the store.
 
 Any suggestions? Will -isConfiguration:compatibleWithStoreMetadata: tell me a 
 lightweight migration-capable change is incompatible?

It tells you whether or not a migration is needed (lightweight or otherwise).

 
 Thanks,
 
 -- 
 Rick
 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Plan for persisting preferences on iOS applications

2012-10-24 Thread Dave Fernandes
This doesn't answer your question, but it might not be against company policies 
to encrypt the data and store the ciphertext in iCloud.

On 2012-10-24, at 11:24 AM, Alex Zavatone z...@mac.com wrote:

 We're currently looking at expanding one of our applications from 1 office to 
 up to 40.  
 
 It's an app that needs an internal preference to be set and remembered 
 through updates or reinstalls.
 
 Since (thanks to the joys of sandboxing), preferences can't be saved outside 
 the app in the preferences folder, I'm expecting to either get a UUID, or MAC 
 address of the device, registering it and the device's name off in a mySQL 
 database and fetching this information on load every time and saving as a 
 pList if the pList doesn't exist, or if the pList contents are different from 
 what is fetched.
 
 It sure sounds like a valid approach, but is this the best approach?
 
 Since standard policy with many companies is that no corporate data can exist 
 outside the corporate network, using iCloud is out of the question.
 
 Thanks in advance.
 - Alex Zavatone
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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


Re: binding an array controller to columns in an NSTableView

2012-09-10 Thread Dave Fernandes
Select the table column in Xcode, and bind its Value binding to the array 
controller with Controller Key = arrangedObjects, and Model Key Path = 
attributeName for the entity.

On 2012-09-10, at 9:40 PM, Chuck Soper chu...@veladg.com wrote:

 An have an Color entity in my data model (I'm just using the word
 'color' for demonstrative purposes). Typically, I only expect to have 6 or
 8 colors for each instance. I'd like to create an NSArrayController for
 the Color entity, then bind it to columns in an NSTableView. I'll need to
 add and remove columns in a table as colors are added or removed.
 
 I understand how to bind an array controller (for an entity) to rows in a
 table, and how to bind a Text Field in the Table Cell View to an entity
 property. I'm not sure how to go about this for columns in a table. I
 assume that I may need to take a programmatic approach. Has anyone done
 this? Or, can someone point me in the right direction?
 
 Thanks,
 Chuck
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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


Re: binding an array controller to columns in an NSTableView

2012-09-10 Thread Dave Fernandes
Wait, did you mean you want consecutive items in the array to be consecutive 
table columns? I can't think of any way to do that.

On 2012-09-10, at 10:02 PM, Dave Fernandes dave.fernan...@utoronto.ca wrote:

 Select the table column in Xcode, and bind its Value binding to the array 
 controller with Controller Key = arrangedObjects, and Model Key Path = 
 attributeName for the entity.
 
 On 2012-09-10, at 9:40 PM, Chuck Soper chu...@veladg.com wrote:
 
 An have an Color entity in my data model (I'm just using the word
 'color' for demonstrative purposes). Typically, I only expect to have 6 or
 8 colors for each instance. I'd like to create an NSArrayController for
 the Color entity, then bind it to columns in an NSTableView. I'll need to
 add and remove columns in a table as colors are added or removed.
 
 I understand how to bind an array controller (for an entity) to rows in a
 table, and how to bind a Text Field in the Table Cell View to an entity
 property. I'm not sure how to go about this for columns in a table. I
 assume that I may need to take a programmatic approach. Has anyone done
 this? Or, can someone point me in the right direction?
 
 Thanks,
 Chuck
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: makeFirstResponder: and tab views

2012-08-07 Thread Dave Fernandes
How long a delay did you give performSelector?

This is working for me now on 10.8 (and a new MBP) without needing 
performSelector, but on 10.7 with an old MBP, I had to use a delay of 
animationResizeTime + 0.5 seconds. I haven't yet tested other combinations of 
MBP age and OS version.

On 2012-08-06, at 1:25 AM, Graham Cox graham@bigpond.com wrote:

 Run into a bug where if I have a number of NSTextFields in a window, and 
 programatically switch the first responder of the window among these fields, 
 it works fine, but if there is a NSTabView interposed between the fields and 
 the window, they just cannot be set to be first responder programatically at 
 all - it goes through the motions but it fails silently.
 
 The text field has a blue focus ring, but there is no blinking cursor and 
 typing results in a beep. The exact same code, without the tab view, works 
 fine.
 
 The field editor delegate causes the text field focus to shift every 4 
 characters:
 
 - (void)  controlTextDidChange:(NSNotification *)obj
 {
   NSTextField* control = [obj object];
   
   NSString* text = [control stringValue];
   
   if([text length] = 4 )
   {
   NSString* shortStr = [[text substringToIndex:4] 
 uppercaseString];
   [control setStringValue:shortStr];
   
   NSResponder* nextField = [control nextKeyView];
   
   NSLog(@got 4 characters: '%@', moving to field: %@, shortStr, 
 nextField );
   
   if([nextField acceptsFirstResponder])
   [[self window] makeFirstResponder:nextField];
   
   }
   
   [self conditionallyEnableOK];
 }
 
 The 'self' here is the window controller and field editor's delegate.
 
 I also tested to see whether the window returned YES or NO from 
 makeFirstResponder: and it always returns YES, indicating success.
 
 Has anyone else run into this? I've seen a few postings in the archives on 
 apparently similar topics, and one suggestion is to delay the 
 makeFirstResponder using -performSelector:... I have tried that but it 
 doesn't work either. Some of these postings go back to 2004 - it's hard to 
 believe such a painfully obvious bug would still be unfixed in 10.8
 
 --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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: setting preselected file for nsopenpanel

2012-06-11 Thread Dave Fernandes
Well, NSOpenPanel inherits from NSSavePanel, so setNameFieldStringValue: might 
work. I haven't tried this, and I don't know whether there would be sandboxing 
issues.

On 2012-06-11, at 7:08 AM, Rick C. wrote:

 Hi,
 
 Been through numerous posts on stack overflow without a solution so here goes:
 
 runModalForDirectory:file:types: was deprecated but in the docs it doesn't 
 give the replacement for the file argument.  How can we have a file 
 preselected when running an open panel?
 
 Thanks,
 
 rc
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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, automatic migration and sandbox problems.

2012-06-05 Thread Dave Fernandes

On 2012-06-05, at 6:10 AM, Samuel Williams wrote:

 Thanks for the info,
 
 I've spent quite a bit of time looking into how this would work. I found that 
 I can override makeDocumentWithContentsOfURL: and friends, but I'm at a loss 
 as to how to check whether the document needs to be migrated. I can get the 
 store metadata using [NSPersistentStoreCoordinator 
 metadataForPersistentStoreOfType:nil URL:contentsURL error:error] but I'm not 
 sure how to check whether that needs migration or not. How do I get the 
 latest model that would be used for the given file type? Seems like I'd need 
 to ask NSPersistentDocument but it doesn't provide any obvious methods for 
 doing that…

If you have a typical Core Data app with a single managed object model, then 
you can get the model using:
model = [NSManagedObjectModel mergedModelFromBundles:nil];

If you have a different model for each file type, then I believe you must be 
overriding -[NSPersistentDocument managedObjectModel]. If so, then whatever 
model you are providing in that method is the one you would compare against.

Hopefully someone else can answer the sandboxing-specific questions. I have no 
experience there.

 
 I was trying to figure out what is the best use-case for migration - 
 currently the file is modified without the user being aware of any change. 
 This is quite good but it fails in the sandbox since the user's explicit 
 permission is required to save the updated data (?). So, pending this, what 
 is the appropriate behaviour in the sandbox? Should we pop up a save box 
 asking the user to select a new location for the migration?
 
 There is (as far as I can see) no documentation in Apple's official docs 
 about how to handle this situation...
 
 What would the canonical approach be in this case?
 
 Kind regards,
 Samuel
 
 On 29 May 2012 04:01, Dave Fernandes dave.fernan...@utoronto.ca wrote:
 If you want to check whether a store needs to be migrated and ask the user, 
 you can use [NSPersistentStoreCoordinator 
 metadataForPersistentStoreOfType:::] to get the metadata for the document in 
 question and [NSManagedObjectModel 
 isConfiguration:compatibleWithStoreMetadata:] to check whether that is 
 compatible with the current MOM.
 
 A good place to do these checks is in NSDocumentController before attempting 
 to open the doc.
 
 On 2012-05-28, at 9:59 AM, Samuel Williams wrote:
 
  Hi,
 
  I'm having trouble with automatic migrations and sandbox.
 
  When the user opens an old file, the automatic migration fails due to no
  write permission to the file.
 
  -
  (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL*)url
  ofType:(NSString*)fileType modelConfiguration:(NSString*)configuration
  storeOptions:(NSDictionary*)storeOptions error:(NSError**)error
 
  {
 
  NSMutableDictionary *options = nil;
 
  if (storeOptions != nil) {
 
  options = [storeOptions mutableCopy];
 
  } else {
 
  options = [[NSMutableDictionary alloc] init];
 
  }
 
 
  [options setObject:[NSNumber numberWithBool:YES]
  forKey:NSMigratePersistentStoresAutomaticallyOption];
 
  [options setObject:[NSNumber numberWithBool:YES]
  forKey:NSInferMappingModelAutomaticallyOption];
 
  *//[options setObject:[NSNumber numberWithBool:YES]
  forKey:NSReadOnlyPersistentStoreOption];*
 
  BOOL result =
  [super configurePersistentStoreCoordinatorForURL:url ofType:fileType
  modelConfiguration:configuration storeOptions:options
 
  error:error];
 
  *//if (*error) {*
 
  * //  *** Fails here 
 
  *// [[NSAlert alertWithError:*error] runModal];*
 
  *//}*
 
  [options release];
 
  return result;
 
  }
 
 
  Just wondering if anyone has a suggestion about how I can avoid writing to
  the file, e.g. forcing the user to re-save or duplicate the document before
  attempting the migration. It works fine for non-sandbox builds.
 
  Kind regards,
  Samuel
  ___
 
  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/dave.fernandes%40utoronto.ca
 
  This email sent to dave.fernan...@utoronto.ca
 
 


___

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, automatic migration and sandbox problems.

2012-05-28 Thread Dave Fernandes
If you want to check whether a store needs to be migrated and ask the user, you 
can use [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:::] to 
get the metadata for the document in question and [NSManagedObjectModel 
isConfiguration:compatibleWithStoreMetadata:] to check whether that is 
compatible with the current MOM.

A good place to do these checks is in NSDocumentController before attempting to 
open the doc.

On 2012-05-28, at 9:59 AM, Samuel Williams wrote:

 Hi,
 
 I'm having trouble with automatic migrations and sandbox.
 
 When the user opens an old file, the automatic migration fails due to no
 write permission to the file.
 
 -
 (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL*)url
 ofType:(NSString*)fileType modelConfiguration:(NSString*)configuration
 storeOptions:(NSDictionary*)storeOptions error:(NSError**)error
 
 {
 
 NSMutableDictionary *options = nil;
 
 if (storeOptions != nil) {
 
 options = [storeOptions mutableCopy];
 
 } else {
 
 options = [[NSMutableDictionary alloc] init];
 
 }
 
 
 [options setObject:[NSNumber numberWithBool:YES]
 forKey:NSMigratePersistentStoresAutomaticallyOption];
 
 [options setObject:[NSNumber numberWithBool:YES]
 forKey:NSInferMappingModelAutomaticallyOption];
 
 *//[options setObject:[NSNumber numberWithBool:YES]
 forKey:NSReadOnlyPersistentStoreOption];*
 
 BOOL result =
 [super configurePersistentStoreCoordinatorForURL:url ofType:fileType
 modelConfiguration:configuration storeOptions:options
 
 error:error];
 
 *//if (*error) {*
 
 * //  *** Fails here 
 
 *// [[NSAlert alertWithError:*error] runModal];*
 
 *//}*
 
 [options release];
 
 return result;
 
 }
 
 
 Just wondering if anyone has a suggestion about how I can avoid writing to
 the file, e.g. forcing the user to re-save or duplicate the document before
 attempting the migration. It works fine for non-sandbox builds.
 
 Kind regards,
 Samuel
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: mutableBytes Creates Autoreleased Objects

2012-05-12 Thread Dave Fernandes

On 2012-05-12, at 12:37 PM, Quincey Morris wrote:

 P.S. I think there's also another, better solution, but it involves adding a 
 method to NSData/NSMutableData via a category:
 
   - (void*) interiorBytes __attribute__ ((objc_returns_inner_pointer)) {
   return self.bytes;
   }
 
   - (void*) mutableInteriorBytes __attribute__ 
 ((objc_returns_inner_pointer)) {
   return self.mutableBytes;
   }
 
 and never using bytes/mutableBytes directly ever again. Perhaps one day 
 bytes/mutableBytes will themselves be marked this way.

So when a method is declared __attribute__ ((objc_returns_inner_pointer)), then 
LLVM tracks regular pointers like it would NSObject pointers to see when the 
owning object can be dealloced? Just want to make sure I understand.

Dave
___

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: mutableBytes Creates Autoreleased Objects

2012-05-12 Thread Dave Fernandes
Cool! That would eliminate some of the gymnastics I have been going through to 
make sure I reference the NSData object some time after I use the internal 
bytes.

On 2012-05-12, at 5:05 PM, Quincey Morris wrote:

 On May 12, 2012, at 13:55 , Dave Fernandes wrote:
 
 So when a method is declared __attribute__ ((objc_returns_inner_pointer)), 
 then LLVM tracks regular pointers like it would NSObject pointers to see 
 when the owning object can be dealloced? Just want to make sure I understand.
 
 … to see when the owning object's variable's compile time scope ends. Other 
 retain/release optimizations aside, that would be the point where its retain 
 count is decremented, and that might in turn trigger deallocation.
 
 But, yes, basically that's how I understand the documentation. It seems *way* 
 too convenient to be true. ;)
 
 


___

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: Google maps-like zooming of NSScrollView's content view

2012-04-01 Thread Dave Fernandes
Just a comment about the UI… I find this behavior horribly counter-intuitive. I 
always end up zooming when I mean to pan.

On 2012-04-01, at 11:28 AM, Nick wrote:

 Hello
 
 I am trying to implement a zooming of a content view (actually it is a
 PDFView page) using a mouse scrolling wheel.
 What I want to have in the end - is to have the final content view
 zoomed in or out in a way that the point, where the mouse was located,
 does not move during this zooming operation (this point would be some
 kind of an anchor around which the rest of the content view should be
 zoomed). Here is an example of this: http://maps.google.com
 
 I've managed to make the view zoom in and out using a view's center
 point as such an anchor  (this is an example i found on the internet):
 
 float zoomFactor = 1.3;
 
 -(void)zoomIn
 {
NSRect visible = [scrollView documentVisibleRect];
NSRect newrect = NSInsetRect(visible, NSWidth(visible)*(1 -
 1/zoomFactor)/2.0, NSHeight(visible)*(1 - 1/zoomFactor)/2.0);
NSRect frame = [scrollView.documentView frame];
 
[scrollView.documentView
 scaleUnitSquareToSize:NSMakeSize(zoomFactor, zoomFactor)];
[scrollView.documentView setFrame:NSMakeRect(0, 0,
 frame.size.width * zoomFactor, frame.size.height * zoomFactor)];
 
[[scrollView documentView] scrollPoint:newrect.origin];
 }
 
 -(void)zoomOut
 {
NSRect visible = [scrollView documentVisibleRect];
NSRect newrect = NSOffsetRect(visible,
 -NSWidth(visible)*(zoomFactor - 1)/2.0, -NSHeight(visible)*(zoomFactor
 - 1)/2.0);
 
NSRect frame = [scrollView.documentView frame];
 
[scrollView.documentView
 scaleUnitSquareToSize:NSMakeSize(1/zoomFactor, 1/zoomFactor)];
[scrollView.documentView setFrame:NSMakeRect(0, 0,
 frame.size.width / zoomFactor, frame.size.height / zoomFactor)];
 
[[scrollView documentView] scrollPoint:newrect.origin];
 }
 
 However, I can't figure out how to make zooming like google maps does,
 preserving that mouse anchor point's location. Could you give me a
 hint?
 
 Thank you
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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

Re: Binding and multithreading

2012-03-24 Thread Dave Fernandes
Hi Jonathan,
Yes, that would work as long as the thing that changed is KVO compliant. To 
update the shadow object, you can do as Jens suggested, or use dispatch_async 
to the main thread, or use the main operation queue as described in the 
receptionist pattern.

Cheers,
Dave

On 2012-03-24, at 5:46 AM, Jonathan Taylor wrote:

 It sounds, though, as if it should be ok to use 
 observeValueForKeyPath:ofObject:change:context (which will run on the 
 secondary thread, by the sound of it) as a way of monitoring the fact that 
 something has changed in the state of my object. I can then use that as a 
 single place in which I schedule a GUI update via a shadow object on the main 
 thread. Does that sound as if it would be ok?
 
 On 23 Mar 2012, at 23:14, Dave Fernandes wrote:
 
 See the Cocoa Design Patterns doc:
 The Receptionist Design Pattern in Practice
 A KVO notification invokes the 
 observeValueForKeyPath:ofObject:change:context: method implemented by an 
 observer. If the change to the property occurs on a secondary thread, 
 theobserveValueForKeyPath:ofObject:change:context: code executes on that 
 same thread.
 
 So you shouldn't use observeValueForKeyPath:ofObject:change:context to 
 update the GUI in this context. I don't know of any better method than what 
 the OP suggested.
 
 Cheers,
 Dave
 
 On 2012-03-23, at 6:32 PM, Jan E. Schotsman wrote:
 
 Jonathan Taylor wrote:
 I have been struggling with a problem which I think I have eventually 
 realised is down to me not handling multithreading issues properly. The 
 situation is I have some computationally-demanding code that is running in 
 a separate thread. This has input parameters and state variables 
 associated with it. For diagnostic reasons I would like to be able to 
 display the values of the state variables in the GUI. I had intended to do 
 this just by binding to them. However I am getting occasional message 
 sent to deallocated instance errors which I suspect are a symptom of the 
 fact that I am Doing It Wrong. Further reading suggests that because of 
 the way bindings work, modifying those state variables is leading to 
 binding/gui type stuff happening away from the main thread, which appears 
 not to be permitted.
 I use KVO for this. Have your main thread observe the state variables 
 (declared as properties) and update the GUI in your 
 observeValueForKeyPath:ofObject:change:context: method.
 I hope this is elegant enough for you  ;-)
 Jan E.
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca
 
 


___

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

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

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

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


Re: Binding and multithreading

2012-03-23 Thread Dave Fernandes
See the Cocoa Design Patterns doc:
The Receptionist Design Pattern in Practice
A KVO notification invokes the observeValueForKeyPath:ofObject:change:context: 
method implemented by an observer. If the change to the property occurs on a 
secondary thread, theobserveValueForKeyPath:ofObject:change:context: code 
executes on that same thread.

So you shouldn't use observeValueForKeyPath:ofObject:change:context to update 
the GUI in this context. I don't know of any better method than what the OP 
suggested.

Cheers,
Dave

On 2012-03-23, at 6:32 PM, Jan E. Schotsman wrote:

 Jonathan Taylor wrote:
 I have been struggling with a problem which I think I have eventually 
 realised is down to me not handling multithreading issues properly. The 
 situation is I have some computationally-demanding code that is running in a 
 separate thread. This has input parameters and state variables associated 
 with it. For diagnostic reasons I would like to be able to display the 
 values of the state variables in the GUI. I had intended to do this just by 
 binding to them. However I am getting occasional message sent to 
 deallocated instance errors which I suspect are a symptom of the fact that 
 I am Doing It Wrong. Further reading suggests that because of the way 
 bindings work, modifying those state variables is leading to binding/gui 
 type stuff happening away from the main thread, which appears not to be 
 permitted.
 I use KVO for this. Have your main thread observe the state variables 
 (declared as properties) and update the GUI in your 
 observeValueForKeyPath:ofObject:change:context: method.
 I hope this is elegant enough for you  ;-)
 Jan E.
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: There's obviously something I don't understand about NSDate.

2012-03-17 Thread Dave Fernandes
Yes, [NSDate date] returns an autoreleased object. So you need to retain it if 
you want to use it later. Once you are done with it, you should release it. See:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994-SW6

If a Cocoa method name doesn't begin with “alloc”, “new”, “copy”, or 
“mutableCopy”, then the returned object is autoreleased.

Dave

On 2012-03-17, at 6:38 PM, G S wrote:

 I have a member variable to hold an NSDate:
 
NSDate* _firstBadAccuracyTime;
 
 At some point, something happens and I set this value to now:
 
_firstBadAccuracyTime = [NSDate date];
 
 On my next trip through this function, I calculate how long it has been
 since I set this date:
 
NSDate* now = [NSDate date];
if([now timeIntervalSinceDate:_firstBadAccuracyTime] 
 BAD_ACCURACY_TIME)
 
 then CRASH: BAD ACCESS
 
 _firstBadAccuracyTime still contains a valid address, but the object
 must've been released.  Why?  If I add a retain where I assign it, the
 crash doesn't happen.  I added autorelease, but then got a crash on
 releasing an object I hadn't allocated (which makes me think it's already
 autoreleased).
 
 Thanks for any insight!
 
 Gavin
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: There's obviously something I don't understand about NSDate.

2012-03-17 Thread Dave Fernandes

On 2012-03-17, at 6:57 PM, Dave Fernandes wrote:

 Yes, [NSDate date] returns an autoreleased object. So you need to retain it 
 if you want to use it later. Once you are done with it, you should release 
 it. See:
 https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994-SW6
 
 If a Cocoa method name doesn't begin with “alloc”, “new”, “copy”, or 
 “mutableCopy”, then the returned object is autoreleased.

Oops - init should be included in this list, of course.

 
 Dave
 
 On 2012-03-17, at 6:38 PM, G S wrote:
 
 I have a member variable to hold an NSDate:
 
  NSDate* _firstBadAccuracyTime;
 
 At some point, something happens and I set this value to now:
 
  _firstBadAccuracyTime = [NSDate date];
 
 On my next trip through this function, I calculate how long it has been
 since I set this date:
 
  NSDate* now = [NSDate date];
  if([now timeIntervalSinceDate:_firstBadAccuracyTime] 
 BAD_ACCURACY_TIME)
 
 then CRASH: BAD ACCESS
 
 _firstBadAccuracyTime still contains a valid address, but the object
 must've been released.  Why?  If I add a retain where I assign it, the
 crash doesn't happen.  I added autorelease, but then got a crash on
 releasing an object I hadn't allocated (which makes me think it's already
 autoreleased).
 
 Thanks for any insight!
 
 Gavin
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca
 


___

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: There's obviously something I don't understand about NSDate.

2012-03-17 Thread Dave Fernandes

On 2012-03-17, at 7:10 PM, G S wrote:

 If a Cocoa method name doesn't begin with “alloc”, “new”, “copy”, or 
 “mutableCopy”, then the returned object is autoreleased.
 
 
 Thanks, Dave.  That's what I thought.  But I don't understand why I need to 
 retain it then; it's assigned to a member pointer.  Why does it get released, 
 and when?  If I call retain on it, do I have to call release on it later?

If you are using manual retain-release semantics (not ARC or GC), then instance 
(member) variables are not retained. This means the object will be released 
whenever the autorelease pool is drained - probably at the end of the event 
cycle. So you should retain it (increasing its retain count), and then release 
it when you no longer need it (decreasing its release count and causing it to 
be deallocated).

 
 I create another NSDate, on the stack, to hold now for use within that 
 function.  Do I need to retain that too?  If not, why not?

As long as it is used only within the function, it is safe to use the 
autoreleased object. You only need to retain it if you want to keep it around 
after the method returns.
___

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: xCode crash on validation for App Store

2012-02-26 Thread Dave Fernandes
Where does one get this Application Loader? I have a similar crash just trying 
to export the application.

On 2012-02-26, at 6:44 AM, Evadne Wu wrote:

 If you are running 10.7.3 then get the new Application Loader.  It
 works.  The OS X update broke (!) app validation.
 
 On Feb 26, 2012, at 19:14, Georg Seifert georg.seif...@gmx.de wrote:
 
 Hi,
 
 I’m using xCode 4.3. If I try to validate my app prior to uploading it to 
 the Mac App Store, it constantly crashes.
 
 I get a crash report that says:
 UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[DVTFilePath compare:]: 
 unrecognized selector sent to instance 0x409ab29c0
 
 The same happens if i try to generate a installer package.
 
 Is there anything I can do to circumvent this? Does anyone else has this 
 problem?
 
 Best
 Georg
 ___
 
 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/ev%40monoceroi.com
 
 This email sent to e...@monoceroi.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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Difficulty Calling NSTableView's validateDrop: Method for Unit Testing

2012-02-07 Thread Dave Fernandes
tableView:validateDrop:proposedRow:proposedDropOperation: is an 
NSTableViewDataSource method (not an NSTableView method). So whatever class is 
implementing the data source methods is probably the class you want to test 
with your unit test code.

Dave

On 2012-02-06, at 9:22 PM, Mark Szymczyk wrote:

 I'm trying to unit test drag and drop rearranging of items in a table view. 
 In my unit testing code I have an object of a NSDocument subclass.
 
 MyDocument* testDoc;
 
 The NSDocument subclass has a table view outlet.
 
 IBOutlet NSTableView* myTableView;
 
 I start my unit test by creating a mock object that implements the 
 NSDraggingInfo protocol.
 
 id mock = [OCMockObject mockForProtocol:@protocol(NSDraggingInfo)];
 
 I use the mock object as an argument to NSTableView's validateDrop: method, 
 like the following code:
 
 NSDragOperation theDrag = [xyz
   tableView:myTableView
   validateDrop:mock
   proposedRow:1
   proposedDropOperation:NSTableViewDropAbove];
 
 What do I replace xyz with in my call to validateDrop:? I tried supplying 
 testDoc, myTableView, NSDocument, and NSTableView, but they generate syntax 
 errors. I searched Google for examples, but all I found were examples on how 
 to write a validateDrop: method to handle drag and drop in my code. I didn't 
 find any examples of calling validateDrop:.
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Selected text in NSTextField

2012-02-02 Thread Dave Fernandes
I'm still a little unclear on when to use an NSWindow and when to use an 
NSPanel. I thought you used an NSPanel if you did *not* want it to become key. 
But for input, you do want it to become key, don't you? I'm sure I've missed 
some basic Cocoa 101 here, but I found the docs clear as mud on this.

Dave

On 2012-02-02, at 6:02 PM, Graham Cox wrote:

 
 On 03/02/2012, at 9:37 AM, Quincey Morris wrote:
 
 You're the second person who's scorned the idea of adding things to an 
 alert. In fact, NSAlert is explicitly designed to allow adding controls via 
 an accessory subview:
 
  
 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Dialog/Articles/CustomAlertDialogs.html
 
 One of the benefits of using a customized alert is that you don't have to 
 worry about resizing the window based on the size of the message and 
 informative text.
 
 OTOH, looking at the OP's links to screenshots, two things are obvious:
 
 1. This particular task isn't one that NSAlert is suitable for. It's not 
 actually an alert.
 
 We used to call these 'dialogs'. Panels seems to be the preferred Cocoa 
 terminology.
 
 Notwithstanding the (minor) benefits of NSAlert, (and internally it's 
 implemented in terms of NSPanel, I would assume), the design of NSAlert makes 
 it harder to set up interactivity, because it doesn't have an explicit 
 controller - it inherits NSObject, not NSWindowController or even NSPanel. In 
 other words, it's designed for a different job to the OP's.
 
 My view is, if you need any input fields in a dialog, the go-to class is 
 NSPanel, not NSAlert.
 
 
 2. There are no new frontiers in Cyrillic pornography. ;)
 
 LOL, indeed.
 
 --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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Selected text in NSTextField

2012-02-02 Thread Dave Fernandes
I see. I've been having trouble forcing an NSTextField to get focus in 
document-modal sheets, and I wondered whether NSPanel/NSWindow should make a 
difference. (Experimentally it does not.)

I found on Snow Leopard that the following always worked:
[sheetController window]; // load the NIB
[sheet performSelector:@selector(makeFirstResponder:) withObject:myTextField 
afterDelay:0.];
[NSApp beginSheet:sheet modalForWindow:docWindow ...

On Lion, it works for some sheets, but not others (very reproducible for any 
given sheet). Sometimes if the performSelector delay is  0.8 sec, it works, 
but not always.

The problem cases are always with NSTextField or its subclasses inside of 
NSTabViews.

I also tried setting the sheet's initial first responder to be the text field 
and then calling:
[sheet makeFirstResponder:sheet];
[sheet performSelector:@selector(selectNextKeyView:) withObject:nil 
afterDelay:0.];

That also works in some cases and not others on Lion. Am I trying the right 
things here?

On 2012-02-02, at 7:10 PM, Graham Cox wrote:

 NSPanel inherits NSWindow. If you look at the methods that NSPanel adds to 
 NSWindow, it's really a very small set.
 
 It allows:
 
 a) the window to be a floating window
 
 b) it allows the window to not become key unless necessary, which is very 
 useful to prevent a floater from stealing focus away from whatever it floats 
 over, unless the user explicitly clicks in a text field, for example.
 
 c) it allows the window to be receive events when run modally.
 
 I think there are also some minor appearance differences.
 
 That's all, so if your needs are not addressed by any of these features, you 
 may as well use NSWindow.
 
 
 --Graham
 
 
 
 
 On 03/02/2012, at 10:51 AM, Dave Fernandes wrote:
 
 I'm still a little unclear on when to use an NSWindow and when to use an 
 NSPanel. I thought you used an NSPanel if you did *not* want it to become 
 key. But for input, you do want it to become key, don't you? I'm sure I've 
 missed some basic Cocoa 101 here, but I found the docs clear as mud on 
 this.
 
 Dave
 


___

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: Selected text in NSTextField

2012-02-02 Thread Dave Fernandes

On 2012-02-02, at 8:11 PM, Graham Cox wrote:

 
 On 03/02/2012, at 11:39 AM, Dave Fernandes wrote:
 
 Am I trying the right things here?
 
 
 It should just work if you set the 'initialFirstResponder' outlet to be your 
 text field. No other code needed, except possibly NOT calling 
 -setBecomesKeyOnlyIfNeeded:YES.
 
 The docs suggest this is only called the first time the window is shown - for 
 sheets and other dialogs, often they are only hidden rather than discarded 
 when closed, so it might not work for subsequent showing of the dialog, but 
 simply making the view returned by -initialFirstResponder the first responder 
 should work, i.e.
 
 [myPanel makeFirstResponder:[myPanel initialFirstResponder]];

This was the first thing I tried, but it didn't even work in Snow Leopard when 
the text field was inside an NSTabView. So then I tried performSelector after 
reading an old post on this topic. And that works on Snow Leopard, but not 
always on Lion.

I also tried setting the initialFirstResponder of the NSTabViewItem to be my 
text field and the initialFirstResponder of the window to be the NSTabView. It 
still doesn't get focus without the aforementioned kludges.

 when you display the sheet. I'm not sure if the -performSelector stuff is 
 needed - I guess you're trying to ensure that the window is really there and 
 the event loop is running but AFAIK, that's not necessary at least after the 
 first time it is displayed. I usually end up calling my 'dialog set up' 
 method from two places - one in -windowDidLoad, and the other just after 
 -beginSheet…. The two calls are mutually exclusive in the sense that on the 
 first run, the call after beginSheet finds all the outlets nil, so does 
 nothing, and -windowDidLoad is only called the first time. While not super 
 elegant I've never encountered any unreliability with it.
 
 --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: How to get the dispatch queue for the current thread's runloop?

2012-01-27 Thread Dave Fernandes
This works:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), 
^{});

On 2012-01-27, at 3:14 PM, 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);
 
 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? I'm unsure of what this does 
 when called on a background thread. The API docs say If the call is made 
 from any other thread, this function returns the default concurrent queue … 
 is that a queue associated with the thread's runloop, that's guaranteed to 
 execute tasks on that thread?
 
 —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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Versions, -windowWillClose:

2012-01-22 Thread Dave Fernandes
You can set a breakpoint in the normal document opening methods such as 
-[NSDocument initWithContentsOfURL:ofType:error:] to see what URL the versioned 
documents are being loaded from.

On 2012-01-22, at 10:06 AM, Martin Hewitson wrote:

 
 On 21, Jan, 2012, at 07:31 PM, Mike Abdullah wrote:
 
 
 On 3 Jan 2012, at 15:25, Martin Hewitson wrote:
 
 Dear list,
 
 I'm investigating getting the new 10.7 Versions stuff working on my 
 NSPersistentDocument app. In doing that, I've seen a couple of strange 
 things which I wanted to check on. 
 
 Firstly, all I've done to make it work is to return YES from 
 +autosavesInPlace.
 
 Now, what I notice is the following sequence of events:
 
 
 1) App starts: 
  windowControllerDidLoadNib NSWindow: 0x10055d970
 2) Enter Versions browser
 NSDocumentRevisionsDebugMode=YES
 Error: kCGErrorFailure: CGSDisplayID: App trying to enumerate [0 to 
 CGSGetNumberOfDisplays()] instead of using CGSGetDisplayList().  
 Compensating...
 Error: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to 
 catch errors as they are logged.
 windowControllerDidLoadNib NSWindow: 0x1091939c0
 Entered Versions: NSConcreteNotification 0x108658620 {name = 
 NSWindowDidEnterVersionBrowserNotification; object = NSWindow: 
 0x10055d970}
 3) Exit Versions (by clicking Done button in Versions browser)
 Window will close NSWindow: 0x1091939c0 / NSWindow: 0x1091939c0
 Open windows 1 (logged in windowWillClose:)
 Exited Versions: NSConcreteNotification 0x1091a22c0 {name = 
 NSWindowDidExitVersionBrowserNotification; object = NSWindow: 0x10055d970}
 4) Exit App
 Window will close NSWindow: 0x10055d970 / NSWindow: 0x10055d970
 Open windows 1 (logged in windowWillClose:)
 
 Some questions:
 
 a) Why is it that I don't have 2 open windows in step 3)?
 b) What is the first window doing while the Versions browser is open? It 
 seems the same document is opened again, judging by the NSWindow objects.
 c) What are the Errors reported just after entering Versions?
 
 The CG errors happen in all apps; seems to be a side-effect of however Apple 
 have implemented Versions.
 
 OK, good to know.
 
 
 Perhaps I'm not understanding how this stuff works yet, so any 
 enlightenment would be gratefully received.
 
 As a side question, where are the different versions of the document kept? 
 I've read that they are kept in the document, but inspection of the 
 (XML-based) Core Data document shows that's not the case. The app is 
 actually a manager of other (text) files on disk, and I'm amazed to see 
 that the versions actually reflect the state of the managed text files, 
 even though the save core data document does not store the file contents. 
 The file contents are stored temporarily in a core data entity as a 
 transient property. Can I then conclude that these transient properties are 
 stored in the different versions? I've tried reading through the 
 documentation on this, and I've watched the WWDC11 session on this, but 
 perhaps I need to do that again.
 
 It's entirely private to the OS where and how it chooses to store the 
 historical versions of your documents.
 
 
 
 True, but it would be very useful in the debugging/understanding process to 
 be able to inspect the contents of the previous versions. Of course, if we 
 had decent documentation on this, that might not be necessary. Alas
 
 Martin
 
 
 Martin Hewitson
 Albert-Einstein-Institut
 Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
 Callinstr. 38, 30167 Hannover, Germany
 Tel: +49-511-762-17121, Fax: +49-511-762-5861
 E-Mail: martin.hewit...@aei.mpg.de
 WWW: http://www.aei.mpg.de/~hewitson
 
 
 
 
 
 
 
 ___
 
 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/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca


___

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: Difference between @synchronized and [managedObjectContext lock]?

2011-11-29 Thread Dave Fernandes
See (bottom of page):
http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/coredata/Articles/cdConcurrency.html#//apple_ref/doc/uid/TP40003385-SW1

If you share a managed object context or a persistent store coordinator 
between threads, you must ensure that any method invocations are made from a 
thread-safe scope. For locking, you should use the NSLocking methods on managed 
object context and persistent store coordinator instead of implementing your 
own mutexes. These methods help provide contextual information to the framework 
about the application's intent—that is, in addition to providing a mutex, they 
help scope clusters of operations.


On 2011-11-29, at 3:08 PM, Laurent Daudelin wrote:

 I'm working on some code that I didn't write and have some core data areas 
 that use [managedObjectContext lock] and [managedObjectContext unlock] while 
 other areas in the code uses @synchronized. I know that @synchronized is a 
 convenience to create a mutex lock so that not 2 threads can acquire the same 
 lock at the same time but are there other differences? Is one better than the 
 other?
 
 Thanks for any insight on this!
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin   
 http://www.nemesys-soft.com/
 Logiciels Nemesys Software
 laur...@nemesys-soft.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Determining when a Lion Versioned document is locked/unlocked

2011-11-16 Thread Dave Fernandes
SUMMARY
I'd like to know when a document is in the locked state. Cocoa provides 
-[NSDocument checkAutosavingSafetyAndReturnError:]; but this only seems to tell 
me when the heuristics think the document should be locked, not when the user 
has deliberately locked the document. Is there any way to determine the actual 
locked state, or receive a notification when it changes?

PROBLEM
I have a document-bases app where documents conceptually contain widgets and 
other data. The widget properties are managed from an application (singleton) 
library. Normally, the user would expect the widgets to always be in sync with 
this library. However, when the document is locked or emailed to someone else 
(who may have a quite different widget library), the document should retain the 
widget properties as they existed in the library when the document was locked.

This means the document must contain a copy of any widgets it uses. It also 
means that either the app must automatically sync the document's widgets with 
the library at appropriate times, or the user must do this her/himself. Since, 
the user almost always wants the two to be in sync, I would much rather the 
application do this automatically. Thus, the app needs to know when this is 
appropriate, and so, needs to know the locked state.

But if you can think of a better application design, I'd be happy to hear it.

Dave___

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

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

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

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


Re: [PARTIALLY SOLVED] Determining when a Lion Versioned document is locked/unlocked

2011-11-16 Thread Dave Fernandes
To answer the first part of my question…
This (deliberately set) locked state is the same as the Finder's locked state. 
You can get it using -[NSURL getResourceValue:forKey:error:] with the key, 
NSURLIsUserImmutableKey.

So you need to check both the NSURLIsUserImmutableKey file-attribute and the 
checkAutosavingSafetyAndReturnError document heuristic in order to know whether 
Locked is displayed in the document's title bar.

As for notifications -
It seems autosaveWithImplicitCancellability is called when the user locks the 
file from title bar menu, but not when the user unlocks the file. Makes sense; 
however, *unlocking a locked file* is the transition I am interested in. I 
suppose I can poll for it, but ick!

Is there a better way to be notified when a file's attributes change?

Thanks,
Dave

On 2011-11-16, at 1:31 PM, Dave Fernandes wrote:

 SUMMARY
 I'd like to know when a document is in the locked state. Cocoa provides 
 -[NSDocument checkAutosavingSafetyAndReturnError:]; but this only seems to 
 tell me when the heuristics think the document should be locked, not when the 
 user has deliberately locked the document. Is there any way to determine the 
 actual locked state, or receive a notification when it changes?
 
 PROBLEM
 I have a document-bases app where documents conceptually contain widgets and 
 other data. The widget properties are managed from an application (singleton) 
 library. Normally, the user would expect the widgets to always be in sync 
 with this library. However, when the document is locked or emailed to someone 
 else (who may have a quite different widget library), the document should 
 retain the widget properties as they existed in the library when the document 
 was locked.
 
 This means the document must contain a copy of any widgets it uses. It also 
 means that either the app must automatically sync the document's widgets 
 with the library at appropriate times, or the user must do this her/himself. 
 Since, the user almost always wants the two to be in sync, I would much 
 rather the application do this automatically. Thus, the app needs to know 
 when this is appropriate, and so, needs to know the locked state.
 
 But if you can think of a better application design, I'd be happy to hear it.
 
 Dave___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Re: Locking an NSDocument

2011-11-16 Thread Dave Fernandes

On 2011-09-09, at 6:05 PM, Kyle Sluder wrote:

 Unfortunately, it doesn't look like there's any public API to force a
 document to be locked. The closest I've come is -[NSDocument
 checkAutosavingSafetyAndReturnError:], but it doesn't seem to be
 called at all the times I'd expect it to be called (for example, a new
 document), and returning NO doesn't put the Locked text in the
 titlebar; it just prohibits the user from making any changes without
 duplicating. Likewise, returning YES from -isInViewingMode just makes
 it impossible to make any changes to the document.

When I try returning NO from checkAutosavingSafetyAndReturnError:, it does put 
Locked in the title bar for a newly opened existing document (on 10.7.2). Not 
sure why you would want to do this for a newly created document, though. But 
the frameworks seem to maintain their own state after checking this. The user 
may then unlock the document, and it will stay unlocked until it is closed. It 
will be locked again when reopened (if you are still returning NO).

Not sure if this helps with your problem. I'm just trying to understand the 
behavior myself, and thinking out loud.

Dave

___

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

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

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

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


Re: About iVars declaration and property

2011-11-13 Thread Dave Fernandes
The synthesized ivars are private to the class that declares them. So you can 
use them as an ivar in that class's implementation, but not in a subclass 
implementation. Usually this is not a problem, but if you already have code 
that passes the ivar's address in a function call, for example, that won't work 
with a property.

On 2011-11-13, at 2:16 AM, ico wrote:

 I am surprise that I just know we do not need to declare instance variables
 explicitly when we declare the property and use @synthesize.
 
 That is we do not need a instance variable to be declared that is
 corresponds to the property declaration.
 
 
 
 look at this blog:
 http://cocoawithlove.com/2010/03/dynamic-ivars-solving-fragile-base.html
 
 
 
 However, I just wonder, is it really true that there is no ANY different
 between explicitly declaring iVars and not delaring it?
 
 If so, is it a better approach that just declare the property and let
 @synthesize to generate the iVars itself.
 
 
 
 Any more explaination and clarify will be appreciated.
 
 -- 
 ==
 Life isn't about finding yourself.
 Life is about creating yourself.
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Re: About iVars declaration and property

2011-11-13 Thread Dave Fernandes
For some reason, sometimes my synthesized ivars show up in the debugger as 
ivars, and sometimes they don't. Can anyone explain this? I can't remember 
whether this is with GDB or LLDB.

On 2011-11-13, at 5:24 AM, Don Quixote de la Mancha wrote:

 Explicitly declaring your ivars makes them easier to see in the
 debugger.  Otherwise you have to call the property accessor from gdb's
 command line to look at it.
 
 I feel that it's helpful to declare them in any case, so I can
 more-easily tell how much memory each of my objects is taking up by
 looking at its list of ivars.
 
 Not every property is backed by the ivar it acts as asscessors for.
 It's perfectly legal to implement custom accessors that do other
 things than set or get instance variables.  They could instead run
 some sort of calculation, or set some other combination of ivars.
 
 -- 
 Don Quixote de la Mancha
 Dulcinea Technologies Corporation
 Software of Elegance and Beauty
 http://www.dulcineatech.com
 quix...@dulcineatech.com
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Re: Core Data: Determine if managed object is deleted

2011-10-21 Thread Dave Fernandes

On 2011-10-21, at 11:57 AM, David Riggle wrote:

 I'm currently experimenting with the following to see if it's as safe and 
 perhaps faster:
 
 - (void)prepareForDeletion
 {
   // track object deletion for faster testing below
   NSString *objIDStr = [[[self objectID] URIRepresentation] 
 resourceSpecifier];
   [_deletedObjectIDs addObject:objIDStr];
 }
 
 - (BOOL)retainedObjectHasBeenDeleted
 {
   NSString *objIDStr = [[[self objectID] URIRepresentation] 
 resourceSpecifier];
   return [_deletedObjectIDs containsObject:objIDStr];
 }
 
 Unfortunately _deletedObjectIDs grows without bound. So you wouldn't want to 
 use this approach if you are expecting a lot of deletions.

This also wouldn't work if you can undo 
deletions.___

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

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

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

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


Re: Core Data : Undo Delete : Cannot fulfill a fault

2011-09-28 Thread Dave Fernandes
I tried to reproduce this problem in my app and couldn't. I got these types of 
exceptions in the past when I was using KVO with my managed objects, but I no 
longer do that. If you aren't either, then I don't have any other suggestions.

In my app, I have parent objects with many child objects that have component 
objects. The component objects are large and don't get faulted in when opening 
a document. There is a cascade delete rule from child to component.

I deleted a child object and saved the document. Then I performed an undo 
operation, and the child and its component were both correctly brought back to 
life (I could edit both of them), even though the component had never been 
faulted in before the delete. So Core Data is saving their attributes somewhere 
other than the persistent store.

On 2011-09-27, at 12:56 PM, Jerry Krinock wrote:

 
 On 2011 Sep 26, at 11:57, Dave Fernandes wrote:
 
 Does the deleted object have relationships?
 
 Yes.  The object is of entity Foo which are classic tree nodes.  There is a 
 root Foo; Foo objects have to-one parents and to-many children, etc.
 
 What is the state of those objects?
 
 It's always the same exceptional object which whose deletion is unable to 
 be undone because Core Data could not fulfill a fault.  Its parent is an 
 object that was not deleted and therefore does not need to be restored.  It 
 has one child which has already been successfully restored at the time the 
 exception occurs.
 
 I now have an AppleScript which reproduces the problem.  The Core Data 
 exception does not happen on every run, but on more than half.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Re: Core Data : Undo Delete : Cannot fulfill a fault

2011-09-26 Thread Dave Fernandes
Jerry,
Does the deleted object have relationships? And if so, what is the state of 
those objects?

Dave

On 2011-09-26, at 2:27 PM, Jerry Krinock wrote:

 
 On 2011 Sep 26, at 03:48, Richard Somers wrote:
 
 My rough testing of a managed object (no undo grouping) produced the 
 following results…
 
 Thank you, Richard.  I agree with those results.
 
 Regarding the contents of the undo and redo stack you could inspect it's 
 contents using something like this…
 
 Oh, I have a better way to do peek the undo stack.  I don't use 
 NSUndoManager.  Instead, I use the open-sourced GCUndoManager.  
 GCUndoManager's stacks are public, and I have code which extracts the target, 
 selector and arguments from the invocations which are on the stacks.  
 Unfortunately, they're quite opaque with Core Data.
 
 Hope this helps.
 
 Well, it looks like it's going to be a long week.  
 
 By overriding -dealloc, I've confirmed that the managed object for which 
 Core Data cannot fulfill a fault is not being deallocced.  And just to make 
 sure that GCUndoManager wasn't causing a problem, I #if-ed NSUndoManager back 
 into the project and retested.  But I still get the same cannot fulfill a 
 fault exception in my corner case.  (Also, I get additional exceptions which 
 are due to NSUndoManager not being as smart as GCUndoManager.)
 
 * * *
 
 So I go back to my assertion that, when undoing object deletion, Core Data 
 somehow un-faults the faulted object by re-populating it with properties it 
 has stored in an argument of an invocation which it had earlier pushed onto 
 the undo stack.  I'm still looking for confirmation of that, and any ideas on 
 how I might possibly by hosing that machinery.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Asynchronous document migration use cases

2011-09-23 Thread Dave Fernandes
I have a document-based app (Core Data, but that isn't important here) that can 
have fairly large documents. Migrating these documents from an old format to 
the new one can take several seconds (to decode, transform and re-encode data), 
so I need to do it off the main thread. It seems to work if I create an 
NSOperation to do the migration in the 
openDocumentWithContentsOfURL:display:error: method of my NSDocumentController 
subclass.

So if a document needs migration, this method returns nil with an 
NSCocoaErrorDomain NSUserCancelledError, queues the NSOperation, and then after 
the asynchronous migration completes, [super 
openDocumentWithContentsOfURL:display:error:] is called (on the main thread) to 
open the document.

While the migration is in progress, a modeless dialog is shown with a progress 
indicator and cancel button, and further calls to open the same document are 
ignored (returns NSCocoaErrorDomain NSUserCancelledError).

My question is: Will this strategy miss (or miss-handle) any use cases on Snow 
Leopard or Lion?  Can openDocumentWithContentsOfURL:display:error: ever be 
called off the main thread in response to user actions (assuming my code 
doesn't do this)?

NOTE: My override of 
reopenDocumentForURL:withContentsOfURL:display:completionHandler: does not 
migrate documents since it would be confusing to launch the app and have a 
migration start immediately. So if it is called with a document that needs 
migration, it does nothing.

Thanks for any feedback.

Dave___

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

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

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

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


Re: KVO on objects in NSArrayController

2011-09-03 Thread Dave Fernandes
I'm coming late to this conversation, but couldn't you just add a -[MyObject  
setMarked:] method that would then be called to change the 'marked' 
attribute/property? It can do anything else it wants after making the change. 
Why use notifications at all? Is it some other object that needs to be notified 
when MyObject changes?

On 2011-09-03, at 1:22 AM, Trygve Inda wrote:

 On Sep 2, 2011, at 19:01 , Trygve Inda wrote:
 
 I have an array of objects (of class MyObject) managed by an
 NSArrayController and displayed in an NSTable (via bindings).
 
 One property of MyObject is a BOOL marked.
 
 I need to be notified whenever the user toggles a marked checkbox in my
 NSTable.
 
 What is the best way to do this? Do I need to add an observer to every
 object in the array (there are about 8,000 of them).
 
 How can I best achieve this so that I get passed the changed MyObject
 (immediately after it changes).
 
 Briefly, you can configure the checkbox cell (either in IB or
 programmatically) to have an action, and possibly an explicit target. In the
 action method, you can use NSTableView's 'clickedRow' method to find the row
 and hence the object whose marked property changed, and send a message
 representing to the change directly to whatever object has to be notified.
 
 
 
 I think this sounds like a much better option than trying to use KVO.
 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:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


Re: KVO on objects in NSArrayController

2011-09-03 Thread Dave Fernandes
I agree, it is certainly a valid and useful design pattern that I use as well. 
But I just wasn't sure that it is needed in the OP's case. From the part that I 
read (and I missed the first part of the thread), there was no mention of which 
objects needed to be notified.

On 2011-09-03, at 10:52 AM, Jerry Krinock wrote:

 
 On 2011 Sep 03, at 07:34, Dave Fernandes wrote:
 
 I'm coming late to this conversation, but couldn't you just add a -[MyObject 
  setMarked:] method that would then be called to change the 'marked' 
 attribute/property? It can do anything else it wants after making the 
 change. Why use notifications at all? Is it some other object that needs to 
 be notified when MyObject changes?
 
 Yes.  The reason I use the notification is, of course, the same reason you 
 always using a notification, because the observer is not known to the 
 observee, and/or it makes for nicer encapsulation.  But if you didn't have 
 these reasons, indeed a simple message would 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:
 http://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
 
 This email sent to dave.fernan...@utoronto.ca

___

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

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

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

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


  1   2   >