Re: Intermittent invisible NSWindow

2021-11-19 Thread davelist--- via Cocoa-dev
FWIW, I think I've noticed that similar issues with Aquamacs. Sometimes I can 
see it in Expose but when I try to select it, it disappears. It may be an issue 
with multiple desktops or an external display. If you think it will help, I'll 
see if I can reproduce what the exact situation is.

Dave


> On Nov 18, 2021, at 7:07 PM, Tom Doan via Cocoa-dev 
>  wrote:
> 
> Unfortunately, it appears that it's 100% predictable---it fails on a M1 
> chipped computer and works on an Intel chipped computer (or an 
> M1 running the software through Rosetta).
> 
>> I can say it has been true in the past, even if it is no longer the
>> case. It is not something I test with each OS release. I certainly can
>> move a window almost entirely offscreen-enough to not notice it at
>> least. Also, your suggestion that the window may have an invalid size
>> could also be the case, additionally revealed by logging the window
>> frame. I have seen some auto layout wonkiness that forces  too-small
>> frame, though not enough to  make it disappear. 
>> 
>> Keary Suska
>> Esoteritech, Inc.
>> "Demystifying technology for your home or business"
>> 
>> 
>> 
>>> On Nov 15, 2021, at 7:13 AM, Tom Doan via Cocoa-dev
>>>  wrote:
>>> 
>>> Thanks, but is that true? I've tried forcing the window off screen
>>> with setFrame: and it still shows up (generally pinned to the top of
>>> the visible frame) even though the [NSWindow frame] returns the
>>> "off-screen" location that I programmed in. The only way I have
>>> found to make the window "invisible" is to give it a non-positive
>>> size, and then pulling it off the window menu still won't show it.
>>> 
>>>> Have you logged the window coordinates? It might be placed fully
>>>> offscreen, and that would produce the behavior you are seeing.
>>>> 
>>>> Keary Suska
>>>> Esoteritech, Inc.
>>>> "Demystifying technology for your home or business"
>>>> 
>>>> 
>>>> 
>>>>> On Nov 13, 2021, at 9:52 AM, Tom Doan via Cocoa-dev
>>>>>  wrote:
>>>>> 
>>>>> I'm having a problem with an application where a small percentage
>>>>> of users have one particular NSWindow type which doesn't show even
>>>>> though it goes through a makeKeyAndOrderFront. It's on the window
>>>>> list and will open if they do a tile, cascade or window switch
>>>>> operation, but doesn't come up initially. I can't reproduce this
>>>>> on any of my computers running three different flavors of MacOS
>>>>> (including Big Sur and Monterey). What should I be looking for
>>>>> that might cause this behavior.
>>>>> 
>>>>> Best regards,
>>>>> 
>>>>> Tom Doan
>>>>> ---
>>>>> 2717 Harrison St
>>>>> Evanston, IL 60201
>>>>> USA
>>>>> 
>>>>> 
>>>>> ___
>>>>> 
>>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>>> 
>>>>> Please do not post admin requests or moderator comments to the
>>>>> list. Contact the moderators at
>>>>> cocoa-dev-admins(at)lists.apple.com
>>>>> 
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esot
>>>>> er itech.com
>>>>> 
>>>>> This email sent to cocoa-...@esoteritech.com
>>>> 
>>> 
>>> 
>>> ---
>>> 2717 Harrison St
>>> Evanston, IL 60201
>>> USA
>>> 
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40esoter
>>> itech.com
>>> 
>>> This email sent to cocoa-...@esoteritech.com
>> 
> 
> 
> ---
> 2717 Harrison St
> Evanston, IL 60201
> USA
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/davelist%40mac.com
> 
> This email sent to davel...@mac.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: Alerts in Xcode 11

2019-10-09 Thread davelist--- via Cocoa-dev
I'm by no means an expert but if I understand what you're trying to do, I think 
the approach I would take is to make an extension on UIViewController:

extension UIViewController {
func notificationAlert(_ msg1: String, _ msg2: String) {

// create the UIAlertAlertController
// and then do as David Duncan said and do:
self.present(, animated:  completion: …)
}
}

Now all your UIViewController subclasses can call that method (and because it's 
a method, they have access to self which is a subclass of UIViewController).

HTH,
Dave


> On Sep 30, 2019, at 11:27 PM, Doug Hardie via Cocoa-dev 
>  wrote:
> 
> I tried that and swift complains that self is not defined.  This is not in a 
> view controller but a stand alone function used in many view controllers.  
> Generally it is used during a segue, but I added one in a view controller to 
> a button action, not part of a segue and it dismissed the alert also.  
> 
> -- Doug
> 
>> On 30 September 2019, at 19:48, David Duncan  wrote:
>> 
>> Instead of creating a new window and a root view controller in order to 
>> present your alert, just use (assuming self is a UIViewController) 
>> self.present(, animated:  completion: …)
>> 
>>> On Sep 30, 2019, at 5:48 PM, Doug Hardie  wrote:
>>> 
>>> Not sure how to do that.  It's not in any view controller as it is used in 
>>> virtually all of the various view controllers.  That's why I wanted it as a 
>>> function.
>>> 
>>> -- Doug
>>> 
>>>> On 30 September 2019, at 14:44, David Duncan  
>>>> wrote:
>>>> 
>>>> What happens if you present it over your normal view controller hierarchy 
>>>> instead of using another window?
>>>> 
>>>> Has your application adopted UIWindowScene?
>>>> 
>>>>> On Sep 30, 2019, at 5:36 PM, Doug Hardie via Cocoa-dev 
>>>>>  wrote:
>>>>> 
>>>>> I have some code that presents an alert to the user with information they 
>>>>> need, and an OK button to clear it.  It works fine in the previous Xcode 
>>>>> versions.  However, after upgrading to 11, it now displays the alert and 
>>>>> then immediately clears it.  This happens both in the simulator and on a 
>>>>> real device.  I have played around with the code and can't figure out how 
>>>>> to make it leave the alert on the screen.  This is in Swift.  It is a 
>>>>> function that is called from numerous places in the app.
>>>>> 
>>>>> func NotificationAlert (_ msg1: String, _ msg2: String) {
>>>>> let ErrorAlert = UIAlertController(title: msg1, message: msg2, 
>>>>> preferredStyle: .alert)
>>>>> let dismiss = UIAlertAction(title: "Ok", style: .default, handler: nil)
>>>>> ErrorAlert.addAction(dismiss)
>>>>> ErrorAlert.presentInOwnWindow(animated: true, completion: nil)
>>>>> }
>>>>> 
>>>>> extension UIAlertController {
>>>>> func presentInOwnWindow(animated: Bool, completion: (() -> Void)?) {
>>>>>let alertWindow = UIWindow(frame: UIScreen.main.bounds)
>>>>>alertWindow.rootViewController = UIViewController()
>>>>>alertWindow.windowLevel = UIWindow.Level.alert + 1;
>>>>>alertWindow.makeKeyAndVisible()
>>>>>alertWindow.rootViewController?.present(self, animated: animated, 
>>>>> completion: completion)
>>>>> }
>>>>> }
>>>>> 
>>>>> 
>>>>> -- Doug
>>>>> 
>>>>> ___
>>>>> 
>>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>>> 
>>>>> Please do not post 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/david.duncan%40apple.com
>>>>> 
>>>>> This email sent to david.dun...@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/davelist%40mac.com
> 
> This email sent to davel...@mac.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: UIDocumentBrowserViewController and file package documents

2017-06-24 Thread davelist

FYI, I tested this on an iPad with iOS 11 beta 2 and opening an existing 
UIDocument works on the actual device - just not on the simulator. I updated my 
bug report with this information.

Dave Reed


> On Jun 21, 2017, at 5:08 PM, Jonathan Hull  wrote:
> 
> That part is really confusing me as well (I am also using a package 
> document).  I started by using the documents directory, but I keep getting an 
> error that the browser doesn’t have access.  Then I switched to the temp 
> directory, and now it works part of the time, and the other times I still get 
> the same error.
> 
> Where are we supposed to create our package?  Does the browser copy it to a 
> specific place? or do we need to copy it?
> 
> Here is the error:
> [ERROR] Could not get attribute values for item file:. Error: 
> Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not 
> permitted to access the URL."
> 
> Thanks,
> Jon
> 
> 
>> On Jun 21, 2017, at 5:41 AM, davel...@mac.com wrote:
>> 
>>> 
>>> On Jun 20, 2017, at 5:29 PM, Kyle Sluder  wrote:
>>> 
>>> On Tue, Jun 20, 2017, at 03:40 PM, davel...@mac.com wrote:
 I'm trying out the new UIDocumentBrowserViewController in iOS 11 (using
 the iPad simulator). I can get it to create a new document (which is a
 file package) for my app, but tapping on the document in the
 UIDocumentBrowserViewController does not cause the delegate method
 documentBrowser(_ controller: UIDocumentBrowserViewController,
 didPickDocumentURLs documentURLs: [URL]) to get called.
 
 It does get called for another document type that is a flat file (not a
 file package), but it doesn't work with the file package document created
 by NSFileWrapper.
 
 Am I doing something wrong or is this a bug with file packages?
>>> 
>>> Please file a bug report and send me the number so I can ensure the
>>> correct team sees it.
>>> 
>>> Thanks,
>>> --Kyle
>>> 
 
 Thanks,
 Dave
>> 
>> I have one more idea to try and then if that doesn't work, I'll try to make 
>> a small sample project today and submit the bug report (and I'll email you 
>> the #).
>> 
>> The one thing I'm not certain about is the WWDC video shows making an empty 
>> file and adding it to the project as a resource and then copying it when the 
>> new document button is pressed. Do I just need to make an empty directory 
>> for that? My idea was to create an empty document with my app (in the 
>> simulator) and then copy that empty document directory to the Xcode project. 
>> Are there any special flags/attributes that need to be set on that directory 
>> to make it a correct package?
>> 
>> Thanks,
>> Dave Reed
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/jhull%40gbis.com
>> 
>> This email sent to jh...@gbis.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: UIDocumentBrowserViewController and file package documents

2017-06-21 Thread davelist
I submitted a bug report: rdar://32912183

Based on the WWDC video, it appears Apple is recommending you put an empty 
document as a resource in your app and then choose the option to copy it. 

The other option would be to make a new document in a temporary directory your 
app can write to and then in the completion handler of closing it, call the 
importHandler and tell it to copy it.

My understanding is the UIDocumentBrowserViewController is running in a 
different process and your app may not have access to the chosen directory 
normally (as it may not be in your app's sandbox) so you can't just create a 
file there. Instead, you need have a document your app can access and tell the 
importHandler to copy or move it to the location the user picked.

HTH,
Dave Reed



> On Jun 21, 2017, at 5:08 PM, Jonathan Hull  wrote:
> 
> That part is really confusing me as well (I am also using a package 
> document).  I started by using the documents directory, but I keep getting an 
> error that the browser doesn’t have access.  Then I switched to the temp 
> directory, and now it works part of the time, and the other times I still get 
> the same error.
> 
> Where are we supposed to create our package?  Does the browser copy it to a 
> specific place? or do we need to copy it?
> 
> Here is the error:
> [ERROR] Could not get attribute values for item file:. Error: 
> Error Domain=NSFileProviderInternalErrorDomain Code=1 "The reader is not 
> permitted to access the URL."
> 
> Thanks,
> Jon
> 
> 
>> On Jun 21, 2017, at 5:41 AM, davel...@mac.com wrote:
>> 
>>> 
>>> On Jun 20, 2017, at 5:29 PM, Kyle Sluder  wrote:
>>> 
>>> On Tue, Jun 20, 2017, at 03:40 PM, davel...@mac.com wrote:
 I'm trying out the new UIDocumentBrowserViewController in iOS 11 (using
 the iPad simulator). I can get it to create a new document (which is a
 file package) for my app, but tapping on the document in the
 UIDocumentBrowserViewController does not cause the delegate method
 documentBrowser(_ controller: UIDocumentBrowserViewController,
 didPickDocumentURLs documentURLs: [URL]) to get called.
 
 It does get called for another document type that is a flat file (not a
 file package), but it doesn't work with the file package document created
 by NSFileWrapper.
 
 Am I doing something wrong or is this a bug with file packages?
>>> 
>>> Please file a bug report and send me the number so I can ensure the
>>> correct team sees it.
>>> 
>>> Thanks,
>>> --Kyle
>>> 
 
 Thanks,
 Dave
>> 
>> I have one more idea to try and then if that doesn't work, I'll try to make 
>> a small sample project today and submit the bug report (and I'll email you 
>> the #).
>> 
>> The one thing I'm not certain about is the WWDC video shows making an empty 
>> file and adding it to the project as a resource and then copying it when the 
>> new document button is pressed. Do I just need to make an empty directory 
>> for that? My idea was to create an empty document with my app (in the 
>> simulator) and then copy that empty document directory to the Xcode project. 
>> Are there any special flags/attributes that need to be set on that directory 
>> to make it a correct package?
>> 
>> Thanks,
>> Dave Reed
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/jhull%40gbis.com
>> 
>> This email sent to jh...@gbis.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: UIDocumentBrowserViewController and file package documents

2017-06-21 Thread davelist

> On Jun 20, 2017, at 5:29 PM, Kyle Sluder  wrote:
> 
> On Tue, Jun 20, 2017, at 03:40 PM, davel...@mac.com wrote:
>> I'm trying out the new UIDocumentBrowserViewController in iOS 11 (using
>> the iPad simulator). I can get it to create a new document (which is a
>> file package) for my app, but tapping on the document in the
>> UIDocumentBrowserViewController does not cause the delegate method
>> documentBrowser(_ controller: UIDocumentBrowserViewController,
>> didPickDocumentURLs documentURLs: [URL]) to get called.
>> 
>> It does get called for another document type that is a flat file (not a
>> file package), but it doesn't work with the file package document created
>> by NSFileWrapper.
>> 
>> Am I doing something wrong or is this a bug with file packages?
> 
> Please file a bug report and send me the number so I can ensure the
> correct team sees it.
> 
> Thanks,
> --Kyle
> 
>> 
>> Thanks,
>> Dave

I have one more idea to try and then if that doesn't work, I'll try to make a 
small sample project today and submit the bug report (and I'll email you the #).

The one thing I'm not certain about is the WWDC video shows making an empty 
file and adding it to the project as a resource and then copying it when the 
new document button is pressed. Do I just need to make an empty directory for 
that? My idea was to create an empty document with my app (in the simulator) 
and then copy that empty document directory to the Xcode project. Are there any 
special flags/attributes that need to be set on that directory to make it a 
correct package?

Thanks,
Dave Reed



___

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

Please do not post 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


UIDocumentBrowserViewController and file package documents

2017-06-20 Thread davelist
I'm trying out the new UIDocumentBrowserViewController in iOS 11 (using the 
iPad simulator). I can get it to create a new document (which is a file 
package) for my app, but tapping on the document in the 
UIDocumentBrowserViewController does not cause the delegate method 
documentBrowser(_ controller: UIDocumentBrowserViewController, 
didPickDocumentURLs documentURLs: [URL]) to get called.

It does get called for another document type that is a flat file (not a file 
package), but it doesn't work with the file package document created by 
NSFileWrapper.

Am I doing something wrong or is this a bug with file packages?

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: Help with Storyboard Problem

2017-06-19 Thread davelist

> On Jun 19, 2017, at 2:24 PM, Dave  wrote:
> 
> XCode 8.3.3.
> 
> Hi All,
> 
> I’m using storyboards on an iOS project and can’t seem to get it to work.
> 
> I have two view controllers in the “Main.storyboard” file. The fist view 
> controller has one button on it, that when clicked, I want it to go to the 
> other view controller.
> 
> I’ve tried using Segues but can’t get that to work so decided to to it 
> manually.
> 
> I have a method in the first view controller that is hooked to the button as 
> so:
> 
> -(IBAction) startGameAction:(id) theSender
> {
> LTWChaosBoardViewController*  myGameViewController;
> UIView*   
> myView;
> 
> myGameViewController = [self.storyboard 
> instantiateViewControllerWithIdentifier:@"LTWChaosBoardViewController1”];
> myView = myGameViewController.view;
> }
> 
> This returns the correct View Controller but does not actually present it. 
> How do I do this? 
> 
> The documentation is sooo poor that I just can’t find anything that is of 
> help.
> 
> All the Best
> Dave

UIViewController has a method: - (void)presentViewController:(UIViewController 
*)viewControllerToPresent animated:(BOOL)flag completion:(void 
(^)(void))completion;

so instead of setting myView =
call:
[self presentViewController:myGameViewController animated:YES completion: nil]; 
// (typed in Mail and I've been doing mostly Swift development so check my 
syntax)

HTH,
Dave Reed

___

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

Please do not post 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: [OT] Question about writing documentation

2017-04-21 Thread davelist

> On Apr 21, 2017, at 5:33 AM, Dave  wrote:
> 
> Hi,
> 
> I’m looking for a decent Application that runs on the Mac that will allow me 
> to create detailed diagrams of Objective-C Classes. Basically I have a 
> Network of inter-related Objects, the Network is represented by Array’s and 
> Dictionary’s and I like to do some diagrams showing how each object in the 
> Network is linked.
> 
> I’ve tried a few Apps from the App Store and although they are “OK” they 
> either buggy for hard to use and don’t have any in-built objects that are 
> suitable for representing Classes/Objecrs. The type of diagrams I’d like are 
> similar to the ones in the Apple Documentation. 
> 
> Thanks in Advance for any suggestions…..
> 
> All the Best
> Dave

You did't say what you tried, but IMO the best app for professional looking 
figures on the Mac is OmniGraffle from omnigroup.com. There are extensive 
stencil libraries for many things and I expect one could work (at least as a 
starting point) for you or you could create a stencil group you could reuse. 
They have a free trial.

I'm not affiliated with OmniGroup - just a satisfied customer.

HTH,
Dave Reed



___

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

Please do not post 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

ReplayKit Bug

2017-04-18 Thread davelist
Are there any Apple iOS ReplayKit engineers on the list? I submitted a bug 
report (with sample project that demonstrates the bug) where ReplayKit does not 
start recording sometimes (generally the first call to 
RPScreenRecorder.shared().startRecording(handler:) does not start the recording 
in the demo app (and my main app) when you call it and the user taps the 
permission option. After calling stopRecording and then startRecording again, 
it does start immediately. The first call to startRecording seems to require a 
subsequent tap of a button on the screen or (showing an alert view also starts 
it). I'm doing this on an iPad Pro (but have also observed it on the original 
iPad Air).

rdar://31543732

For anyone else curious, sample project is here:

https://github.com/dave256/ReplayKitBugReport

Thanks,
Dave Reed

___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-30 Thread davelist



> On Mar 23, 2017, at 8:01 PM, davel...@mac.com wrote:
> 
> 
>> On Mar 23, 2017, at 12:24 PM, David Duncan  wrote:
>> 
>> I just want to remind everyone I’m *not* a file system’s engineer – I’m just 
>> trying to help Dave (and anyone else caught in this) make sure their app can 
>> find their files.
>> 
>>> On Mar 23, 2017, at 1:53 AM, Alastair Houghton 
>>>  wrote:
>>> 
>>> On 22 Mar 2017, at 18:00, David Duncan  wrote:
 
 So there was another explanation posted on the bug that I’m not certain 
 you got, but which I think may explain.
 
 Basically the concept is that since APFS doesn’t normalize file names, if 
 you store file names in some other storage (say in your preferences) then 
 what could happen is this:
 
 10.2: File is saved with a file name handed to the file system in NFC 
 form. File system converts the file name to NFD. You store it as NFC.
 10.3: File system is converted to APFS, and the file name is NFD. You try 
 to look up the file as NFC, and it fails.
>>> 
>>> This is going to cause problems, though, when things migrate from HFS+ to 
>>> APFS, because the HFS normalisation *isn’t* a standard one.  In particular, 
>>> it certainly *isn’t* NFD for the current version of Unicode.
>> 
>> Yes, that is the crux of Dave’s issue – HFS+ => APFS only translated the 
>> file names (from UTF-16 to UTF-8), it did not re-normalize them.
>> 
>>> The only obvious solution for that would be to have the HFS+ to APFS 
>>> migration tool *re-normalise* the filenames (maybe it does?), but that’s 
>>> bound to break things in the (presumably quite common) case where the 
>>> filename stored in e.g. a plist was originally obtained from the filesystem.
>> 
>> Arguably there is no way for the file system converter to know how it should 
>> renormalize file names. This is akin to case sensitive vs case insensitive 
>> file systems. If you ran a converter from a case insensitive file system to 
>> a case sensitive one, you could preserve the capitalization during the 
>> conversion, but file lookups that used the wrong case would fail after the 
>> conversion. But the converter can’t know you want to look up “foo” via “FOO” 
>> or “Foo” to do any kind of normalization. The difference here is that for 
>> the most part unicode normalization is invisible to the developer.
>> 
>>> 
>>> Kind regards,
>>> 
>>> Alastair.
>>> 
>>> --
>>> http://alastairs-place.net
>>> 
>> 
>> --
>> David Duncan
> 
> 
> I appreciate the help you (and everyone else) has given. I should be able to 
> add an option to rescan what files are there. And I'll make time this weekend 
> to submit a DTS incident and see what answer I can get and share it here. I 
> do suspect I won't be the only one bit by this.
> 
> Thanks,
> Dave Reed


I received a reply from DTS with lots of information and references. The 
suggestion for me was to store both the name the user enters and a filename 
that won't have the issue in my plist file with the list of "courses" (I assume 
they mean use a ASCII name such as GUID). The other suggestion was to iterate 
over the files and apply the same decomposition to the filename and the user 
entered string to find the match - that's what I did over the weekend and the 
update is now available in the App Store.

Dave Reed


___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-23 Thread davelist

> On Mar 23, 2017, at 12:24 PM, David Duncan  wrote:
> 
> I just want to remind everyone I’m *not* a file system’s engineer – I’m just 
> trying to help Dave (and anyone else caught in this) make sure their app can 
> find their files.
> 
>> On Mar 23, 2017, at 1:53 AM, Alastair Houghton 
>>  wrote:
>> 
>> On 22 Mar 2017, at 18:00, David Duncan  wrote:
>>> 
>>> So there was another explanation posted on the bug that I’m not certain you 
>>> got, but which I think may explain.
>>> 
>>> Basically the concept is that since APFS doesn’t normalize file names, if 
>>> you store file names in some other storage (say in your preferences) then 
>>> what could happen is this:
>>> 
>>> 10.2: File is saved with a file name handed to the file system in NFC form. 
>>> File system converts the file name to NFD. You store it as NFC.
>>> 10.3: File system is converted to APFS, and the file name is NFD. You try 
>>> to look up the file as NFC, and it fails.
>> 
>> This is going to cause problems, though, when things migrate from HFS+ to 
>> APFS, because the HFS normalisation *isn’t* a standard one.  In particular, 
>> it certainly *isn’t* NFD for the current version of Unicode.
> 
> Yes, that is the crux of Dave’s issue – HFS+ => APFS only translated the file 
> names (from UTF-16 to UTF-8), it did not re-normalize them.
> 
>> The only obvious solution for that would be to have the HFS+ to APFS 
>> migration tool *re-normalise* the filenames (maybe it does?), but that’s 
>> bound to break things in the (presumably quite common) case where the 
>> filename stored in e.g. a plist was originally obtained from the filesystem.
> 
> Arguably there is no way for the file system converter to know how it should 
> renormalize file names. This is akin to case sensitive vs case insensitive 
> file systems. If you ran a converter from a case insensitive file system to a 
> case sensitive one, you could preserve the capitalization during the 
> conversion, but file lookups that used the wrong case would fail after the 
> conversion. But the converter can’t know you want to look up “foo” via “FOO” 
> or “Foo” to do any kind of normalization. The difference here is that for the 
> most part unicode normalization is invisible to the developer.
> 
>> 
>> Kind regards,
>> 
>> Alastair.
>> 
>> --
>> http://alastairs-place.net
>> 
> 
> --
> David Duncan


I appreciate the help you (and everyone else) has given. I should be able to 
add an option to rescan what files are there. And I'll make time this weekend 
to submit a DTS incident and see what answer I can get and share it here. I do 
suspect I won't be the only one bit by this.

Thanks,
Dave Reed





___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-22 Thread davelist

> On Mar 22, 2017, at 2:00 PM, David Duncan  wrote:
> 
>> 
>> On Mar 22, 2017, at 4:15 AM, davel...@mac.com wrote:
>> 
>>> 
>>> On Mar 22, 2017, at 5:05 AM, Alastair Houghton 
>>>  wrote:
>>> 
>>> On 21 Mar 2017, at 20:49, Quincey Morris 
>>>  wrote:
 
 On Mar 20, 2017, at 14:23 , davel...@mac.com wrote:
> 
> "iOS HFS Normalized UNICODE names , APFS now treats all file[ name]s as a 
> bag of bytes on iOS . We are requesting that Applications developers call 
> the correct Normalization routines to make sure the file name contains 
> the correct representation."
 
 I’ve been letting this simmer for a couple of days now, and I’ve come to 
 the conclusion that it’s — sincere apologies to the unnamed Apple engineer 
 who wrote it — as dumb as dirt.
 
 — It’s not a "bag of bytes”, because bags of stuff are generally 
 understood as unordered sets, and I doubt that’s what’s intended. It has 
 to be a sequence of bytes.
>>> 
>>> In the context of filesystems (and specifically filenames), the phrases 
>>> “bag of bytes” and “bunch of bytes” have a fairly specific meaning.  The 
>>> point is that the filesystem doesn’t inspect the bytes it’s given, and 
>>> doesn’t care what they represent (about the only exception is that it 
>>> probably doesn’t support embedded NULs).  It isn’t suggesting that the 
>>> names are treated as an unordered set of bytes (that’d just be silly).  
>>> It’s just expressing the fact that the filesystem doesn’t care what they 
>>> are - it may compare them, and if it does so, it will use binary ordering 
>>> (not some other collation sequence) and won’t worry about things like case 
>>> or encoding at all.
>>> 
 — It’s not just a string, it has to be a string in a known encoding. 
 Otherwise, how could you ever mount an external drive on a different 
 computer? The encoding has to be pre-specified for APFS, or it has to be 
 stored in metadata on each volume.
>>> 
>>> Agreed, that’s where the “bunch of bytes” approach falls down.
>>> 
 — It’s not just going to be a string of known encoding, it’s going to be 
 Unicode. That’s going to be true even if the fact is specified in volume 
 metadata and it’s theoretically possible to create APFS volumes with 
 non-Unicode file names. Anything other than Unicode would, at this point, 
 be a crime against humanity.
>>> 
>>> If I’d designed APFS, it probably would use Unicode names (and it’d store 
>>> the version of Unicode it used in the filesystem header, to avoid having to 
>>> hard-code it).
>>> 
>>> But I didn’t design it - Dominic Giampaolo and his team did - and we still 
>>> don’t have that much information about how APFS works.  I’m sure they had 
>>> their reasons for whatever decision they’ve made here.
>>> 
 Is *that* the bottom line? I doubt it. I don’t believe the above quoted 
 statement can be correct. I could believe that normalization is being 
 moved out of the file system code, but it would have to be moved to (e.g.) 
 the Cocoa frameworks, still “downstream” of the file-handling APIs. It 
 can’t go upstream of the public APIs without breaking an API contract that 
 has existed for the 16+ years since OS X 10.0.
>>> 
>>> This is a tricky area.  The problem with what we have at the moment 
>>> (-fileSystemRepresentation) is that it *assumes* HFS+ semantics.  That 
>>> isn’t always going to be correct for existing non-HFS+ filesystems, let 
>>> alone in the future.  Of course, if you’re using the NSURL or NSString 
>>> methods, rather than calling the BSD or C library APIs yourself, this is 
>>> all hidden from you anyway (you certainly shouldn’t, IMO, be required to do 
>>> anything unusual at Cocoa level - the Foundation framework should just make 
>>> this all work, rather in the same way it presently does for numerous other 
>>> things).
>>> 
>>> It’s also complicated by the fact that, unlike on DOS or Windows, UNIX-like 
>>> systems use a unified filesystem - that is, other filesystems are joined on 
>>> at mount points.  Thus you could have a name like
>>> 
>>> /Volumes/Foo/Bar/Baz/Blam
>>> 
>>> where (say) both Foo and Baz are mount points, and the rules about 
>>> filenames could differ markedly, at least in principle; that is, 
>>> /Volumes/Foo would have to conform to HFS+ (or APFS) rules, Bar/Baz to 
>>> whatever rules govern the filesystem mounted at Foo, and Blam to whatever 
>>> rules govern the filesystem mounted at Baz.  And remember, not every 
>>> filesystem will be using a well known encoding - macOS already has code to 
>>> add and remove percent escapes (I kid you not) for this very reason.
>>> 
>>> I’d like to hear what Dominic has to say (at least what he *can* say) about 
>>> this, since he’s likely in a position to shed some light on it - or at 
>>> least to take on board that we’re worrying about 

Re: Unicode filenames with Apple File System and UIManagedDocument

2017-03-22 Thread davelist

> On Mar 22, 2017, at 5:05 AM, Alastair Houghton  
> wrote:
> 
> On 21 Mar 2017, at 20:49, Quincey Morris 
>  wrote:
>> 
>> On Mar 20, 2017, at 14:23 , davel...@mac.com wrote:
>>> 
>>> "iOS HFS Normalized UNICODE names , APFS now treats all file[ name]s as a 
>>> bag of bytes on iOS . We are requesting that Applications developers call 
>>> the correct Normalization routines to make sure the file name contains the 
>>> correct representation."
>> 
>> I’ve been letting this simmer for a couple of days now, and I’ve come to the 
>> conclusion that it’s — sincere apologies to the unnamed Apple engineer who 
>> wrote it — as dumb as dirt.
>> 
>> — It’s not a "bag of bytes”, because bags of stuff are generally understood 
>> as unordered sets, and I doubt that’s what’s intended. It has to be a 
>> sequence of bytes.
> 
> In the context of filesystems (and specifically filenames), the phrases “bag 
> of bytes” and “bunch of bytes” have a fairly specific meaning.  The point is 
> that the filesystem doesn’t inspect the bytes it’s given, and doesn’t care 
> what they represent (about the only exception is that it probably doesn’t 
> support embedded NULs).  It isn’t suggesting that the names are treated as an 
> unordered set of bytes (that’d just be silly).  It’s just expressing the fact 
> that the filesystem doesn’t care what they are - it may compare them, and if 
> it does so, it will use binary ordering (not some other collation sequence) 
> and won’t worry about things like case or encoding at all.
> 
>> — It’s not just a string, it has to be a string in a known encoding. 
>> Otherwise, how could you ever mount an external drive on a different 
>> computer? The encoding has to be pre-specified for APFS, or it has to be 
>> stored in metadata on each volume.
> 
> Agreed, that’s where the “bunch of bytes” approach falls down.
> 
>> — It’s not just going to be a string of known encoding, it’s going to be 
>> Unicode. That’s going to be true even if the fact is specified in volume 
>> metadata and it’s theoretically possible to create APFS volumes with 
>> non-Unicode file names. Anything other than Unicode would, at this point, be 
>> a crime against humanity.
> 
> If I’d designed APFS, it probably would use Unicode names (and it’d store the 
> version of Unicode it used in the filesystem header, to avoid having to 
> hard-code it).
> 
> But I didn’t design it - Dominic Giampaolo and his team did - and we still 
> don’t have that much information about how APFS works.  I’m sure they had 
> their reasons for whatever decision they’ve made here.
> 
>> Is *that* the bottom line? I doubt it. I don’t believe the above quoted 
>> statement can be correct. I could believe that normalization is being moved 
>> out of the file system code, but it would have to be moved to (e.g.) the 
>> Cocoa frameworks, still “downstream” of the file-handling APIs. It can’t go 
>> upstream of the public APIs without breaking an API contract that has 
>> existed for the 16+ years since OS X 10.0.
> 
> This is a tricky area.  The problem with what we have at the moment 
> (-fileSystemRepresentation) is that it *assumes* HFS+ semantics.  That isn’t 
> always going to be correct for existing non-HFS+ filesystems, let alone in 
> the future.  Of course, if you’re using the NSURL or NSString methods, rather 
> than calling the BSD or C library APIs yourself, this is all hidden from you 
> anyway (you certainly shouldn’t, IMO, be required to do anything unusual at 
> Cocoa level - the Foundation framework should just make this all work, rather 
> in the same way it presently does for numerous other things).
> 
> It’s also complicated by the fact that, unlike on DOS or Windows, UNIX-like 
> systems use a unified filesystem - that is, other filesystems are joined on 
> at mount points.  Thus you could have a name like
> 
>  /Volumes/Foo/Bar/Baz/Blam
> 
> where (say) both Foo and Baz are mount points, and the rules about filenames 
> could differ markedly, at least in principle; that is, /Volumes/Foo would 
> have to conform to HFS+ (or APFS) rules, Bar/Baz to whatever rules govern the 
> filesystem mounted at Foo, and Blam to whatever rules govern the filesystem 
> mounted at Baz.  And remember, not every filesystem will be using a well 
> known encoding - macOS already has code to add and remove percent escapes (I 
> kid you not) for this very reason.
> 
> I’d like to hear what Dominic has to say (at least what he *can* say) about 
> this, since he’s likely in a position to shed some light on it - or at least 
> to take on board that we’re worrying about it.  At the very least it’d be 
> nice to see some more detail about APFS published somewhere *soon*...
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net


I think it should be taken care of by NSURL so developers don’t need to worry 
about it but that doesn’t appear to be the case, but, at this point I 

Re: Unicode filenames with Apple File System and UIManagedDocument

2017-03-21 Thread davelist

> On Mar 21, 2017, at 8:33 AM, Jean-Daniel  wrote:
> 
> 
>> Le 21 mars 2017 à 12:03, davel...@mac.com a écrit :
>> 
>>> 
>>> On Mar 21, 2017, at 1:06 AM, Jens Alfke  wrote:
>>> 
>>> 
 On Mar 20, 2017, at 2:23 PM, davel...@mac.com wrote:
 
 NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name];
>>> 
>>> There’s nothing wrong with that call; it’s the canonical way to add a path 
>>> component to a URL, filesystem or not.
>>> 
 NSURL *url = [NSURL fileURLWithFileSystemRepresentation:[name 
 fileSystemRepresentation] isDirectory:YES relativeToURL:[self 
 courseDirectory]];
>>> 
>>> This call doesn’t make sense. You’re converting to filesystem 
>>> representation and then back again, for no reason.
>>> 
>>> What Apple suggested is to Unicode-normalize the filename before adding it 
>>> to the URL. Did you try doing that?
>>> 
>>> —Jens
>> 
>> Jens,
>> 
>> I’m trying to find out what that means. Someone suggested off-list to me 
>> that I should be calling this:
>> 
>> https://developer.apple.com/reference/foundation/nsstring/1409474-decomposedstringwithcanonicalmap?language=objc
>> 
>> Is that correct?
>> 
>> So based on that, I think it means I should do:
>> 
>> NSURL *url = [[self courseDirectory] 
>> URLByAppendingPathComponent:name.decomposedStringWithCanonicalMapping];
>> 
>> Thanks,
>> Dave Reed
>> 
> 
> This is what the reply suggest but that make no sens for me. If you are 
> accessing the file using URL, that the work of the framework to convert the 
> URL into the right file system representation.
> 
> That said, if using name.decomposedStringWithCanonicalMapping fix your 
> problem, so go with it.

Unfortunately, I can't tell. One user told me he couldn't open his files (with 
Arabic names) after upgrading to iOS 10.3 public beta. He then changed the 
names to English names and was able to open the files. He sent me some sample 
files that I can open (but they were zipped by my app and then unzipped by me) 
so I honestly can't tell if any of these changes have different effects. With 
all the options I've tried, I can open the files on my 10.2 and my 10.3 
developer device.

If he creates files with Arabic names on 10.3 he can open them so something 
happened in the 10.2 to 10.3 (which is why I suspect APFS) upgrade that 
prevents files created with 10.2 from being opened with 10.3.

My plan to test it is to take a file created with 10.2 using an Arabic name and 
see what happens when I upgrade my regular phone to 10.3 but obviously that's 
time consuming and I only plan to do that upgrade once since it's a pain to 
downgrade (and not certain it would be possible with the APFS change).

That's why I keep emailing about this - I can't test it and can't find specific 
documentation from Apple that says exactly how to create a NSURL from a 
NSString that may contain Unicode characters.

Thanks,
Dave Reed







___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-21 Thread davelist

> On Mar 21, 2017, at 1:06 AM, Jens Alfke  wrote:
> 
> 
>> On Mar 20, 2017, at 2:23 PM, davel...@mac.com wrote:
>> 
>> NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name];
> 
> There’s nothing wrong with that call; it’s the canonical way to add a path 
> component to a URL, filesystem or not.
> 
>> NSURL *url = [NSURL fileURLWithFileSystemRepresentation:[name 
>> fileSystemRepresentation] isDirectory:YES relativeToURL:[self 
>> courseDirectory]];
> 
> This call doesn’t make sense. You’re converting to filesystem representation 
> and then back again, for no reason.
> 
> What Apple suggested is to Unicode-normalize the filename before adding it to 
> the URL. Did you try doing that?
> 
> —Jens

Jens,

I’m trying to find out what that means. Someone suggested off-list to me that I 
should be calling this:

https://developer.apple.com/reference/foundation/nsstring/1409474-decomposedstringwithcanonicalmap?language=objc

Is that correct?

So based on that, I think it means I should do:

NSURL *url = [[self courseDirectory] 
URLByAppendingPathComponent:name.decomposedStringWithCanonicalMapping];

Thanks,
Dave Reed


___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-20 Thread davelist
;>> (http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt 
>>> <http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt>):
>>> 0625;ARABIC LETTER ALEF WITH HAMZA BELOW;Lo;0;AL;0627 0655;...
>>> 
>>> That is, in some cases this character 0625 (UTF8: D8 A5)  will be converted 
>>> to the sequence 0627 0655 (UTF8: D8 A7 D9 95).
>>> 
>>> This decomposition was introduced in Unicode 3.0. If there are processes 
>>> that use decomposition according to Unicode 9 versus Unicode 2.x, or 
>>> processes that don't decompose versus ones that do, then the filename bytes 
>>> will be different.
>>> 
>>> - Peter 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/witness.of.teachtext%40gmx.net
>>> 
>>> This email sent to witness.of.teacht...@gmx.net
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/davelist%40mac.com
>> 
>> This email sent to davel...@mac.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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-12 Thread davelist
(resent from address that is subscribed to the list)

Hi Uli, 

The code to create the URL was using:

   NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name];

where [self courseDirectory] is a URL of a directory (with an English name 
created by the app) in the Documents folder. The variable "name" is a NSString 
that is from the user (with just basic sanitizing to replace "/" with "-"). 
Note: this is iOS.

So I wasn't using UTF8String or fileSystemRepresentation.

Someone claimed I should be using fileSystemRepresentation and someone else 
said it shouldn't matter. If anyone has the definitive answer as to what I 
should change that to, I'm happy to use it (although it may be too late now).

Thanks,
Dave Reed

> On Mar 12, 2017, at 8:25 AM, Uli Kusterer <witness.of.teacht...@gmx.net> 
> wrote:
> 
> I can't find the start of this thread, but this sounds a lot like you were 
> using -UTF8String instead of -fileSystemRepresentation to save out your file 
> names. That's the main difference between those two calls: 
> -fileSystemRepresentation decomposes UTF8 the way HFS+ does, so should never 
> adopt newer decompositions, and will instead guarantee the same string will 
> decompose the same way — as long as you don't forget to use it somewhere.
> 
> Of course, if you are using command line tools, they might not be properly 
> normalizing the file names.
> 
> Apologies if this was already covered in the lost beginning of this thread.
> 
> Cheers,
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
> http://www.zathras.de
> 
>> On 8 Mar 2017, at 22:35, Peter Edberg <pedb...@apple.com> wrote:
>> 
>> 
>>> On Mar 8, 2017, at 12:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
>>> 
>>> Message: 1
>>> Date: Tue, 07 Mar 2017 15:03:41 -0500
>>> From: davel...@mac.com
>>> To: Alastair Houghton <alast...@alastairs-place.net>,   David Duncan
>>> <david.dun...@apple.com>
>>> Cc: cocoa-dev list <cocoa-dev@lists.apple.com>
>>> Subject: Re: Unicode filenames with Apple File System and
>>> UIManagedDocument
>>> 
>>> 
>>> 
>>> My app has the option to zip up the directories UIManagedDocument creates 
>>> and email it (so users can back up their data or share it with others). The 
>>> person sent it to me. Below is what I did in the Terminal so you can see 
>>> what happens when I try to unzip it. If this doesn’t come through on the 
>>> email list with the characters looking correct, I can screenshot it.
>>> 
>>> This is one of the data files that was created on iOS 10.2 and then won’t 
>>> open now on an iOS 10.3 device. It appears the directory name and zip file 
>>> name do not match and it won’t unzip correctly. It does create a directory 
>>> but the directory is empty instead of containing the StoreContent and 
>>> persistentStore files. The zip file is 34KB so it may or may not actually 
>>> have the data in it.
>>> 
>>> $ ls
>>> إعلام.zip
>> 
>> 
>> It is probably worth noting that the first Arabic character in the above 
>> filename (i.e. the one that appears on the right, adjacent to the period) 
>> has a canonical decomposition, as per this line from UnicodeData.txt 
>> (http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt 
>> <http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt>):
>> 0625;ARABIC LETTER ALEF WITH HAMZA BELOW;Lo;0;AL;0627 0655;...
>> 
>> That is, in some cases this character 0625 (UTF8: D8 A5)  will be converted 
>> to the sequence 0627 0655 (UTF8: D8 A7 D9 95).
>> 
>> This decomposition was introduced in Unicode 3.0. If there are processes 
>> that use decomposition according to Unicode 9 versus Unicode 2.x, or 
>> processes that don't decompose versus ones that do, then the filename bytes 
>> will be different.
>> 
>> - Peter 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/witness.of.teachtext%40gmx.net
>> 
>> This email sent to witness.of.teacht...@gmx.net
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderato

Re: Unicode filenames with Apple File System and UIManagedDocument

2017-03-11 Thread davelist

> On Mar 9, 2017, at 7:31 AM, Chris Ridd  wrote:
> 
> 
>> On 8 Mar 2017, at 22:56, Peter Edberg  wrote:
>> 
>>> 
>>> On Mar 8, 2017, at 1:44 PM, David Reed  wrote:
>>> 
>>> Thanks Peter.
>>> 
>>> I am going to try to find time in the next few days to file a bug report. 
>>> I'll obviously include this information. Is there anything else you think I 
>>> should include?
>> 
>> Nothing else leaps out at me other than the usuals (system version, exact 
>> steps to repro, etc.).
>> - Peter E
> 
> The only other thing I’d do (if possible) is to use NSFileManager and 
> enumerate all the filenames in the directory containing the “bad” document. 
> Possibly the process of zipping stuff up will mangle the bytes of the 
> filename, so the more “raw” info you can get from the OS the better.
> 
> Chris

Thanks, I reported the bug: rdar://30993389

I did do a directory enumeration and the "persistentStore" files that 
UIMangagedDocument creates were missing. The directory name was there as was 
the StoreContent directory inside it, but the StoreContent directory was empty.

Thanks,
Dave Reed


___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-08 Thread davelist

> On Mar 8, 2017, at 4:35 PM, Peter Edberg  wrote:
> 
> 
>> On Mar 8, 2017, at 12:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
>> 
>> 
>> My app has the option to zip up the directories UIManagedDocument creates 
>> and email it (so users can back up their data or share it with others). The 
>> person sent it to me. Below is what I did in the Terminal so you can see 
>> what happens when I try to unzip it. If this doesn’t come through on the 
>> email list with the characters looking correct, I can screenshot it.
>> 
>> This is one of the data files that was created on iOS 10.2 and then won’t 
>> open now on an iOS 10.3 device. It appears the directory name and zip file 
>> name do not match and it won’t unzip correctly. It does create a directory 
>> but the directory is empty instead of containing the StoreContent and 
>> persistentStore files. The zip file is 34KB so it may or may not actually 
>> have the data in it.
>> 
>> $ ls
>> إعلام.zip
> 
> 
> It is probably worth noting that the first Arabic character in the above 
> filename (i.e. the one that appears on the right, adjacent to the period) has 
> a canonical decomposition, as per this line from UnicodeData.txt 
> (http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt 
> ):
> 0625;ARABIC LETTER ALEF WITH HAMZA BELOW;Lo;0;AL;0627 0655;...
> 
> That is, in some cases this character 0625 (UTF8: D8 A5)  will be converted 
> to the sequence 0627 0655 (UTF8: D8 A7 D9 95).
> 
> This decomposition was introduced in Unicode 3.0. If there are processes that 
> use decomposition according to Unicode 9 versus Unicode 2.x, or processes 
> that don't decompose versus ones that do, then the filename bytes will be 
> different.
> 
> - Peter E

Thanks Peter.

I am going to try to find time in the next few days to file a bug report. I'll 
obviously include this information. Is there anything else you think I should 
include?

Thanks,
Dave Reed
___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-07 Thread davelist

> On Mar 7, 2017, at 1:19 PM, Alastair Houghton  
> wrote:
> 
> On 7 Mar 2017, at 12:47, Jean-Daniel  wrote:
>> 
>> Did you try to use NSString -fileSystemRepresentation instead of UTF-8, or 
>> even better, use URL. While using UTF-8 for path worked well on HFS+, It was 
>> never guaranteed to work on all FS.
> 
> FWIW, the macOS kernel does use UTF-8 at the VFS interface (and therefore the 
> BSD syscalls that take path arguments expect UTF-8).  This is different to 
> most other UNIXen (which tend to treat paths as a bunch of bytes, at least at 
> syscall level and often at filesystem level too).  It’s definitely the case 
> that for the built-in FAT, NTFS and HFS+ implementations, UTF-8 will work.  
> Other filesystem implementations really *should* be treating what they get as 
> UTF-8 too, but obviously that’s not guaranteed.
> 
> AFAIK all -fileSystemRepresentation does is it processes the Unicode string 
> according to the rules in TN1150 and then convert to UTF-8; but you don’t 
> actually *need* to do the HFS+ mapping (TN1150) before calling the BSD API 
> (and it doesn’t even make any sense to do so unless the filesystem is HFS+, 
> which -fileSystemRepresentation has no way of knowing).  The main benefit is 
> that the result will compare bytewise equal with a filename read from the 
> filesystem (assuming HFS+).  On other filesystems, well, things are 
> different.  VFAT and later variants store UTF-16, as does NTFS, but the rules 
> in both cases differ.  ExtFS, UFS et al. tend to regard filenames as a bunch 
> of bytes and don’t even try to record what encoding was used.  I don’t know 
> what ZFS, XFS or JFS do; using Unicode at filesystem level on a UNIX-like 
> system is not unproblematic (because it may very well *not* be the same 
> encoding being used at the user’s terminal), but equally the bunch of bytes 
> approach creates all kinds of fun (you may *see* a file with a particular 
> name, but you can’t necessarily name it yourself from the keyboard...)
> 
> Not that I’d recommend *not* using -fileSystemRepresentation; Apple says we 
> should, so we should.  I’m just observing that it isn’t a particularly good 
> API and in future it’ll either be deprecated or do the exact same thing as 
> -UTF8String because there’s really no other good option I can see.
> 
> Kind regards,
> 
> Alastair.

I saw the other posts about fileSystemRepresentation and tried the code I 
posted earlier in the thread didn’t have any effect.

My app has the option to zip up the directories UIManagedDocument creates and 
email it (so users can back up their data or share it with others). The person 
sent it to me. Below is what I did in the Terminal so you can see what happens 
when I try to unzip it. If this doesn’t come through on the email list with the 
characters looking correct, I can screenshot it.

This is one of the data files that was created on iOS 10.2 and then won’t open 
now on an iOS 10.3 device. It appears the directory name and zip file name do 
not match and it won’t unzip correctly. It does create a directory but the 
directory is empty instead of containing the StoreContent and persistentStore 
files. The zip file is 34KB so it may or may not actually have the data in it.

$ ls
إعلام.zip

$ unzip *.zip
Archive:  إعلام.zip
checkdir error:  cannot create Ϻ+?Ϧ+?Ϻ+?/StoreContent
 No such file or directory
 unable to process Ϻ+?Ϧ+?Ϻ+?/StoreContent/persistentStore.
checkdir error:  cannot create Ϻ+?Ϧ+?Ϻ+?/StoreContent
 No such file or directory
 unable to process Ϻ+?Ϧ+?Ϻ+?/StoreContent/persistentStore-shm.
checkdir error:  cannot create Ϻ+?Ϧ+?Ϻ+?/StoreContent
 No such file or directory
 unable to process Ϻ+?Ϧ+?Ϻ+?/StoreContent/persistentStore-wal.

 $ ls
?+%F2Ϧ+%E4?+%E0/إعلام.zip

When you unzip it, it should create a directory with the exact same name as the 
.zip file (just without the .zip extension). 

This may be enough information that it’s worth filing a bug report now. Does 
anyone have any other suggestions? Again, creating an Arabic file on iOS 10.3 
works fine, but these ones that were created on 10.2 do not open on 10.3.

Thanks,
Dave Reed





___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-07 Thread davelist

> On Mar 7, 2017, at 9:55 AM, davel...@mac.com wrote:
> 
> 
>> On Mar 7, 2017, at 7:47 AM, Jean-Daniel  wrote:
>> 
>> 
>>> Le 6 mars 2017 à 14:28, davel...@mac.com a écrit :
>>> 
>>> I have an iOS app (Attendance2) written in Objective-C. One of my users 
>>> upgraded to the public 10.3 iOS beta and reported he could no longer open 
>>> his documents (I have a subclass of UIManagedDocument so they are Core Data 
>>> files stored in the package/directory format that UIManagedDocument uses). 
>>> I didn’t notice any issues with my test device using the developer beta of 
>>> 10.3. He changed the file names from Arabic to Roman and then he said he 
>>> could open them.
>>> 
>>> Everything I do with NSString is via UTF8 (and it worked fine with Arabic 
>>> letters for this person before updating to the 10.3 beta) so I don’t think 
>>> I’m doing anything wrong.
>>> 
>> 
>> Did you try to use NSString -fileSystemRepresentation instead of UTF-8, or 
>> even better, use URL. While using UTF-8 for path worked well on HFS+, It was 
>> never guaranteed to work on all FS.
>> 
> 
> I’ll take a look at this today. I suspect I’m not using 
> fileSystemRepresentation. I’ll have to see when that is appropriate to use as 
> I believe I’m creating a URL from the string the user types in and then using 
> that as part of the URL for the UIManagedDocument.
> 
> The person did create a new Arabic file under 10.3 and it opens fine, but the 
> ones that we created under 10.2 won’t open under 10.3 unless the person 
> changes the name so it uses Roman/English characters.
> 
> If using fileSystemRepresentation doesn’t fix it, I’ll file a bug.
> 
> Thanks,
> Dave Reed

Is this the correct way to do it (assuming the variable name is the NSString 
with the name of the file (and [self courseDirectory] is the directory the file 
is in?

NSFileManager *fm = [[NSFileManager alloc] init];
const char *data = [name fileSystemRepresentation];
NSString *filename = [fm stringWithFileSystemRepresentation:data 
length:strlen(data)];
NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:filename];

Before what I was doing is:
NSURL *url = [[self courseDirectory] URLByAppendingPathComponent:name];

With the above changes, I can still open my files so it doesn't appear to break 
anything. I'll have to wait until I get home to see if that now lets me open 
the pre-created Arabic files (the person sent me a sample file that won't open 
in 10.3 and I can confirm it opens in 10.2 but not with my 10.3 test device) as 
I don't have Xcode 8.3 beta on my laptop and that seems to be required to load 
the data onto the 10.3 beta device.

Thanks,
Dave Reed



___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-07 Thread davelist

> On Mar 7, 2017, at 7:47 AM, Jean-Daniel  wrote:
> 
> 
>> Le 6 mars 2017 à 14:28, davel...@mac.com a écrit :
>> 
>> I have an iOS app (Attendance2) written in Objective-C. One of my users 
>> upgraded to the public 10.3 iOS beta and reported he could no longer open 
>> his documents (I have a subclass of UIManagedDocument so they are Core Data 
>> files stored in the package/directory format that UIManagedDocument uses). I 
>> didn’t notice any issues with my test device using the developer beta of 
>> 10.3. He changed the file names from Arabic to Roman and then he said he 
>> could open them.
>> 
>> Everything I do with NSString is via UTF8 (and it worked fine with Arabic 
>> letters for this person before updating to the 10.3 beta) so I don’t think 
>> I’m doing anything wrong.
>> 
> 
> Did you try to use NSString -fileSystemRepresentation instead of UTF-8, or 
> even better, use URL. While using UTF-8 for path worked well on HFS+, It was 
> never guaranteed to work on all FS.
> 

I’ll take a look at this today. I suspect I’m not using 
fileSystemRepresentation. I’ll have to see when that is appropriate to use as I 
believe I’m creating a URL from the string the user types in and then using 
that as part of the URL for the UIManagedDocument.

The person did create a new Arabic file under 10.3 and it opens fine, but the 
ones that we created under 10.2 won’t open under 10.3 unless the person changes 
the name so it uses Roman/English characters.

If using fileSystemRepresentation doesn’t fix it, I’ll file a bug.

Thanks,
Dave Reed




___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-06 Thread davelist

> On Mar 6, 2017, at 5:10 PM, David Duncan  wrote:
> 
>> 
>> On Mar 6, 2017, at 2:05 PM, davel...@mac.com wrote:
>> 
>>> 
>>> On Mar 6, 2017, at 12:37 PM, Chris Ridd  wrote:
>>> 
>>> 
 On 6 Mar 2017, at 13:28, davel...@mac.com wrote:
 
 I have an iOS app (Attendance2) written in Objective-C. One of my users 
 upgraded to the public 10.3 iOS beta and reported he could no longer open 
 his documents (I have a subclass of UIManagedDocument so they are Core 
 Data files stored in the package/directory format that UIManagedDocument 
 uses). I didn’t notice any issues with my test device using the developer 
 beta of 10.3. He changed the file names from Arabic to Roman and then he 
 said he could open them.
 
 Everything I do with NSString is via UTF8 (and it worked fine with Arabic 
 letters for this person before updating to the 10.3 beta) so I don’t think 
 I’m doing anything wrong.
 
 Any suggestions?
>>> 
>>> If that iOS beta has upgraded the user’s filesystem to APFS, then it may be 
>>> an iOS bug that you need to report.
>>> 
>>> Chris
>> 
>> I'm assuming the public beta upgraded to APFS (as I believe I read the 
>> developer betas upgraded to APFS). I'm trying to figure out if this an Apple 
>> bug (i.e., either APFS isn't handling his Arabic filenames correctly or 
>> perhaps something went wrong in the upgrade from HFS+ to APFS) or if perhaps 
>> it is a bug in my app (I doubt since all I'm doing is taking the NSString 
>> they enter and using it as the filename).
>> 
>> Is there anything else we could try to see which one of those it likely is? 
>> I'm going to ask him to create a new file and use an Arabic name and see if 
>> that works (i.e., was it just an issue with existing files in Arabic).
> 
> I would highly recommend you file a bug that includes enough of your code to 
> reproduce the issue now. You can update it later if you determine it is your 
> issue.
> 
> --
> David Duncan

If I had the time and could easily do that, I would but pairing my app down to 
just the minimal parts would be time consuming. It would probably be quicker to 
create a brand new app that creates a subclass of UIDocument and see if it 
happens with that. And then I need to figure out how to get my phone in to an 
Arabic locale (which should be easy), but more challenging is to get back out 
since I can't read Arabic and navigating the UI settings might be challenging.

In the meantime, I've asked the person who ran into the problem to create a new 
document that uses Arabic as the filename and see if it happens with the new 
file. 

Thanks,
Dave Reed
___

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

Please do not post 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: Unicode filenames with Apple File System and UIManagedDocument

2017-03-06 Thread davelist

> On Mar 6, 2017, at 12:37 PM, Chris Ridd  wrote:
> 
> 
>> On 6 Mar 2017, at 13:28, davel...@mac.com wrote:
>> 
>> I have an iOS app (Attendance2) written in Objective-C. One of my users 
>> upgraded to the public 10.3 iOS beta and reported he could no longer open 
>> his documents (I have a subclass of UIManagedDocument so they are Core Data 
>> files stored in the package/directory format that UIManagedDocument uses). I 
>> didn’t notice any issues with my test device using the developer beta of 
>> 10.3. He changed the file names from Arabic to Roman and then he said he 
>> could open them.
>> 
>> Everything I do with NSString is via UTF8 (and it worked fine with Arabic 
>> letters for this person before updating to the 10.3 beta) so I don’t think 
>> I’m doing anything wrong.
>> 
>> Any suggestions?
> 
> If that iOS beta has upgraded the user’s filesystem to APFS, then it may be 
> an iOS bug that you need to report.
> 
> Chris

I'm assuming the public beta upgraded to APFS (as I believe I read the 
developer betas upgraded to APFS). I'm trying to figure out if this an Apple 
bug (i.e., either APFS isn't handling his Arabic filenames correctly or perhaps 
something went wrong in the upgrade from HFS+ to APFS) or if perhaps it is a 
bug in my app (I doubt since all I'm doing is taking the NSString they enter 
and using it as the filename).

Is there anything else we could try to see which one of those it likely is? I'm 
going to ask him to create a new file and use an Arabic name and see if that 
works (i.e., was it just an issue with existing files in Arabic).

Thanks,
Dave Reed


___

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

Please do not post 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

Unicode filenames with Apple File System and UIManagedDocument

2017-03-06 Thread davelist
I have an iOS app (Attendance2) written in Objective-C. One of my users 
upgraded to the public 10.3 iOS beta and reported he could no longer open his 
documents (I have a subclass of UIManagedDocument so they are Core Data files 
stored in the package/directory format that UIManagedDocument uses). I didn’t 
notice any issues with my test device using the developer beta of 10.3. He 
changed the file names from Arabic to Roman and then he said he could open them.

Everything I do with NSString is via UTF8 (and it worked fine with Arabic 
letters for this person before updating to the 10.3 beta) so I don’t think I’m 
doing anything wrong.

Any suggestions?

Thanks,
Dave Reed


___

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

Please do not post 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: making a video from still frames that don't change that often plus audio

2017-01-15 Thread davelist

> On Jan 15, 2017, at 3:12 PM, Quincey Morris 
>  wrote:
> 
> On Jan 15, 2017, at 09:22 , davel...@mac.com wrote:
>> 
>> I have an iOS presentation app 
>> (https://itunes.apple.com/app/redraw/id1114820588?mt=8) that I currently 
>> make videos from by AirPlaying it to my Mac and using Screenflow on the Mac 
>> to show the iPad screen and record my audio from a microphone (and then 
>> edit). I'd like to build this functionality into my app directly
> 
> AVFoundation doesn’t seem to have the ability of capturing screen video on 
> iOS — AVCaptureScreenInput is documented as Mac only. That would rule out 
> AVFoundation for the basic video capture within your app. You might be able 
> to capture a series of screen shots, but it has to be done in real time, and 
> that’s going to be tricky to get right on iOS where you’ll need to buffer the 
> captured images to storage that might not be fast enough.
> 
> If you mean you want to write a companion Mac app, then I guess you can use 
> AVCaptureScreenInput to capture the raw video, and then you could use 
> AVAssetWriter to export your final, composed video. However, AVAssetWriter is 
> *not* a real-time function, so you couldn’t rely on it keeping up if you 
> tried to export as the user interleaves the still images with the raw video. 
> What you’d need to do is add a playback/edit phase, where you played the raw 
> video, captured the timing of the user edits (letting the playback skip 
> frames if the edits held up the playback), then export the “composition” when 
> the user is done. (Or, you could export in the background *during* editing, 
> which would mean it would be done soon after the user finishes, but this may 
> have adverse effects on playback on a lower-end Mac.)
> 
> AVCaptureScreenInput does let you choose the screen, though.
> 
> FWIW, since I’m not sure I properly understood exactly what solution you’re 
> looking for.

I'm talking about doing this on the iPad (not with a separate Mac app). I know 
the only option for recording the screen itself is using ReplayKit. I don't 
really need to record the screen. I want to write a video in real-time that 
consists of the audio from the microphone and an image that changes 
periodically (and that image happens to be shown on a UIImageView of the second 
screen of my app). So given that AVAssetWriter is not real time, I think my 
best option (if I want to do it all the work on the iPad without a separate Mac 
app) is to use ReplayKit.

The other option would be to let the user navigate to a specific image on the 
screen, record audio for that image, navigate to the next image, record audio 
for that image, and so on and then I could probably use AVAssetWriter to write 
that audio and the fixe image and then the next audio segment and the next 
fixed image, etc.

Thanks,
Dave Reed


___

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

Please do not post 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: making a video from still frames that don't change that often plus audio

2017-01-15 Thread davelist
I misunderstood the 8 minute limitation - I thought it would interrupt you 
after 8 minutes of continuous recording, but trying it, I was able to record 
over 8 minutes without the dialog appearing. The problem I still see is that it 
only records the main screen. I want it to record what I'm showing on a second 
screen. I don't see anything in the ReplayKit API that would support that.

The relatively easy option would be to have a record mode where I only show 
what I want recorded. There are also some restrictions on what you can do with 
the ReplayKit video when you're done - you can share it but your app itself 
doesn't have access to the video. That may not be a problem for me, but I was 
thinking about including some editing functionality too.

I'll have to give it some more thought as I would prefer the ability to make 
the video directly with the second screen images but the ease of ReplayKit may 
win out.

Thanks,
Dave Reed



> On Jan 15, 2017, at 12:29 PM, Saagar Jha  wrote:
> 
> The 8 minute limitation is for the time the user’s choice is remembered for 
> the authorization prompt, is it not? Is there a limit for the actual 
> recording as well?
> 
> Saagar Jha
> 
>> On Jan 15, 2017, at 9:22 AM, davel...@mac.com wrote:
>> 
>> I have an iOS presentation app 
>> (https://itunes.apple.com/app/redraw/id1114820588?mt=8) that I currently 
>> make videos from by AirPlaying it to my Mac and using Screenflow on the Mac 
>> to show the iPad screen and record my audio from a microphone (and then 
>> edit). I'd like to build this functionality into my app directly. I see 
>> ReplayKit which would probably work (haven't checked if it can record the 
>> external screen my app makes) but the 8 minute limitation is probably a deal 
>> breaker. If that were 20 minutes, I would probably use it.
>> 
>> Basically what I want to do is to have the app record some audio (while the 
>> user is interacting with the app) and make a video that includes this audio 
>> and a series of sporadically updated images. For example, I have an image 
>> that is being shown on the screen of the app and want that image to be in 
>> the video until the user presses a button to change the image and then I 
>> want that image to be the image that is shown in the video (as the audio 
>> continues). Most of the time the same image might be shown for 10 or so 
>> seconds at a time, but occasionally the image might be updated at 30 fps.
>> 
>> So basically I want to make a video from this audio and periodically I will 
>> update the image that should be displayed and that frame should continue to 
>> be shown in the movie until I tell it to use a new image for the subsequent 
>> frames.
>> 
>> It looks like AVFoundation and specifically AVAssetWriter may be what I 
>> need? Is that the correct approach? 
>> 
>> I found this that sort of looks like what I want:
>> 
>> http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie
>> 
>> Although in my case I don't have all the images saved ahead of time (and 
>> don't want to save the images in memory while recording the audio because I 
>> would likely run out of memory). I just want to write the move to the flash 
>> storage as the audio is recorded.
>> 
>> My app is written in Swift although I wrote Objective-C code for 6 or so 
>> years so pointers to example code written in Objective-C are fine also.
>> 
>> Thanks,
>> Dave Reed


___

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

Please do not post 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

making a video from still frames that don't change that often plus audio

2017-01-15 Thread davelist
I have an iOS presentation app 
(https://itunes.apple.com/app/redraw/id1114820588?mt=8) that I currently make 
videos from by AirPlaying it to my Mac and using Screenflow on the Mac to show 
the iPad screen and record my audio from a microphone (and then edit). I'd like 
to build this functionality into my app directly. I see ReplayKit which would 
probably work (haven't checked if it can record the external screen my app 
makes) but the 8 minute limitation is probably a deal breaker. If that were 20 
minutes, I would probably use it.

Basically what I want to do is to have the app record some audio (while the 
user is interacting with the app) and make a video that includes this audio and 
a series of sporadically updated images. For example, I have an image that is 
being shown on the screen of the app and want that image to be in the video 
until the user presses a button to change the image and then I want that image 
to be the image that is shown in the video (as the audio continues). Most of 
the time the same image might be shown for 10 or so seconds at a time, but 
occasionally the image might be updated at 30 fps.

So basically I want to make a video from this audio and periodically I will 
update the image that should be displayed and that frame should continue to be 
shown in the movie until I tell it to use a new image for the subsequent frames.

It looks like AVFoundation and specifically AVAssetWriter may be what I need? 
Is that the correct approach? 

I found this that sort of looks like what I want:

http://stackoverflow.com/questions/3741323/how-do-i-export-uiimage-array-as-a-movie

Although in my case I don't have all the images saved ahead of time (and don't 
want to save the images in memory while recording the audio because I would 
likely run out of memory). I just want to write the move to the flash storage 
as the audio is recorded.

My app is written in Swift although I wrote Objective-C code for 6 or so years 
so pointers to example code written in Objective-C are fine also.

Thanks,
Dave Reed


___

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

Please do not post 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: UIDocument with NSFileWrapper

2016-03-22 Thread davelist

I don't claim this is the one right way, but I think it makes sense based on 
the little bit of documentation there is for NSFIleWrapper and it seems to 
work. My situation is complicated because my document consists of multiple 
files. UIDocument is pretty simple if you only need a single data file to store 
all your data.

I'll post an update if I find anything else out, but I may start prototyping 
some other parts of that app before coming back to this again in a month or so.

Dave Reed

> On Mar 21, 2016, at 9:02 PM, Luther Baker  wrote:
> 
> Thanks for posting this. Exploring UIDocument and caching/parsing JSON 
> instead of CoreData for a service based mobile app that must support offline 
> mode ... and looking forward to considering where you landed.
> On Mon, Mar 21, 2016 at 5:11 PM  wrote:
> 
> > On Mar 21, 2016, at 2:08 AM, Quincey Morris 
> >  wrote:
> >
> > On Mar 19, 2016, at 18:54 , davel...@mac.com wrote:
> >>
> >> What I’m having trouble understanding is how I store the images (whose 
> >> filenames will vary from document to document) with NSFileWrapper. In my 
> >> top level directory do I have my main model file as a JSON file along with 
> >> a file (JSON or plist) that lists all the images and then have an Image 
> >> directory that another NSFileWrapper is used to read/write the images 
> >> (that are stored in the Image subdirectory)?
> >>
> >> Or can I simply store all the files without a subdirectory? I still 
> >> suspect I need to have a file with a fixed name (such as image.plist) that 
> >> tells me what all the other filenames are to put in the NSFileWrapper (vs. 
> >> using NSFileManager to ask for the name of all the files).
> >
> > There’s no correct answer to these questions. It’s a design problem whose 
> > answer is whatever works best in your use case. I’d recommend you start by 
> > choosing what looks to you like the most straightforward approach, then be 
> > prepared to revise your strategy later if it doesn’t work out well. (The 
> > amount of code relating to file wrappers is likely to be small relative to 
> > the code that generally maintains your data model, so rewriting it 
> > shouldn’t be onerous. However, that suggests it would be prudent not to let 
> > the wrappers propagate too deeply into the model. Keep them as an artifact 
> > of the save mechanism in particular, rather than the data model in general.)
> >
> 
> Ok, thanks again for all your feedback. I took a stab at implementing it 
> yesterday. Everything is in my subclass of UIDocument. The rest of the model 
> is a layer below the UIDocument subclass (i.e., the subclass has a couple 
> instance variables which are the main model) although I did put a few methods 
> in the UIDocument class to add the images since that needs to change the 
> NSFileWrapper.
> 
> I think I've got it working. Here is how I did it (in case this helps anyone 
> else and in case anyone else sees a problem with this).
> 
> UIDocument subclass has a NSFIleWrapper instances for each of these:
> 
> 1. Top level NSFileWrapper directory wrapper.
> 2. It contains a directory wrapper for a subdirectory named Images where all 
> the image files (that won't be updated often go). I put the method to add an 
> image here so that it could update the NSFileWrapper
> 3. a NSFileWrapper that contains a single file that is a list of all the 
> image filenames that is added to the top level NSFileWrapper
> 4. a NSFileWrapper for the rest of the model that will change often and is 
> added to the top level NSFileWrapper
> 
> Whenever an image is added, I remove the NSFileWrapper in #3 from the top 
> level file wrapper, created a new NSFileWrapper with the new list of images, 
> and then add that to the top level NSFileWrapper. And add the image file to 
> the NSFileWrapper in #2. It appears you must call removeFileWrapper on the 
> top level NSFileWrapper and then add the new NSFileWrapper with 
> addFileWrapper rather than just calling addFileWrapper with the same 
> preferred filename and replacement NSFileWrapper. Similarly with my #4 main 
> data model file, I call removeFileWrapper and addFileWrapper each time a save 
> occurs since this data changes frequently.
> 
> Since images won't be added as often as the rest of the model is updated, I'm 
> hoping this won't cause these images to be re-written every time a save is 
> performed but I'm not certain how to verify this is the case.
> 
> Thanks,
> Dave Reed
> 


___

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

Please do not post 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: UIDocument with NSFileWrapper

2016-03-21 Thread davelist

> On Mar 21, 2016, at 2:08 AM, Quincey Morris 
>  wrote:
> 
> On Mar 19, 2016, at 18:54 , davel...@mac.com wrote:
>> 
>> What I’m having trouble understanding is how I store the images (whose 
>> filenames will vary from document to document) with NSFileWrapper. In my top 
>> level directory do I have my main model file as a JSON file along with a 
>> file (JSON or plist) that lists all the images and then have an Image 
>> directory that another NSFileWrapper is used to read/write the images (that 
>> are stored in the Image subdirectory)?
>> 
>> Or can I simply store all the files without a subdirectory? I still suspect 
>> I need to have a file with a fixed name (such as image.plist) that tells me 
>> what all the other filenames are to put in the NSFileWrapper (vs. using 
>> NSFileManager to ask for the name of all the files).
> 
> There’s no correct answer to these questions. It’s a design problem whose 
> answer is whatever works best in your use case. I’d recommend you start by 
> choosing what looks to you like the most straightforward approach, then be 
> prepared to revise your strategy later if it doesn’t work out well. (The 
> amount of code relating to file wrappers is likely to be small relative to 
> the code that generally maintains your data model, so rewriting it shouldn’t 
> be onerous. However, that suggests it would be prudent not to let the 
> wrappers propagate too deeply into the model. Keep them as an artifact of the 
> save mechanism in particular, rather than the data model in general.)
> 

Ok, thanks again for all your feedback. I took a stab at implementing it 
yesterday. Everything is in my subclass of UIDocument. The rest of the model is 
a layer below the UIDocument subclass (i.e., the subclass has a couple instance 
variables which are the main model) although I did put a few methods in the 
UIDocument class to add the images since that needs to change the NSFileWrapper.

I think I've got it working. Here is how I did it (in case this helps anyone 
else and in case anyone else sees a problem with this).

UIDocument subclass has a NSFIleWrapper instances for each of these:

1. Top level NSFileWrapper directory wrapper.
2. It contains a directory wrapper for a subdirectory named Images where all 
the image files (that won't be updated often go). I put the method to add an 
image here so that it could update the NSFileWrapper
3. a NSFileWrapper that contains a single file that is a list of all the image 
filenames that is added to the top level NSFileWrapper
4. a NSFileWrapper for the rest of the model that will change often and is 
added to the top level NSFileWrapper

Whenever an image is added, I remove the NSFileWrapper in #3 from the top level 
file wrapper, created a new NSFileWrapper with the new list of images, and then 
add that to the top level NSFileWrapper. And add the image file to the 
NSFileWrapper in #2. It appears you must call removeFileWrapper on the top 
level NSFileWrapper and then add the new NSFileWrapper with addFileWrapper 
rather than just calling addFileWrapper with the same preferred filename and 
replacement NSFileWrapper. Similarly with my #4 main data model file, I call 
removeFileWrapper and addFileWrapper each time a save occurs since this data 
changes frequently.

Since images won't be added as often as the rest of the model is updated, I'm 
hoping this won't cause these images to be re-written every time a save is 
performed but I'm not certain how to verify this is the case.

Thanks,
Dave Reed
___

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

Please do not post 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: UIDocument with NSFileWrapper

2016-03-19 Thread davelist

> On Mar 19, 2016, at 8:01 PM, Quincey Morris 
>  wrote:
> 
> On Mar 19, 2016, at 14:23 , davel...@mac.com wrote:
>> 
>> My thought is to have a dictionary mapping each image filename to a 
>> NSFileWrapper
> 
> You already have one, basically. The top level wrapper for a package is a 
> directory wrapper, which lists the wrappers of contained files, indexed by 
> file name.

Yes, right now I have that wrapper saving a JSON file that I read/write back 
into my model.

The documentation I found for NSFileWrapper handles the case where there are a 
fixed number of files with names known at compile time so I’m struggling to 
understand what to do when the number of files can vary and the names aren’t 
known at compile time. 

What I’m having trouble understanding is how I store the images (whose 
filenames will vary from document to document) with NSFileWrapper. In my top 
level directory do I have my main model file as a JSON file along with a file 
(JSON or plist) that lists all the images and then have an Image directory that 
another NSFileWrapper is used to read/write the images (that are stored in the 
Image subdirectory)?

Or can I simply store all the files without a subdirectory? I still suspect I 
need to have a file with a fixed name (such as image.plist) that tells me what 
all the other filenames are to put in the NSFileWrapper (vs. using 
NSFileManager to ask for the name of all the files).

Thanks for all your input.

Dave Reed





___

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

Please do not post 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: UIDocument with NSFileWrapper

2016-03-19 Thread davelist

> On Mar 19, 2016, at 1:48 PM, Quincey Morris 
>  wrote:
> 
> On Mar 19, 2016, at 10:18 , davel...@mac.com wrote:
>> 
>> The downside I see for my app is that UIDocument writes out the data to a 
>> temporary location and then moves it to the new location so I think my app 
>> will constantly be writing out these image/PDF files that never change. Is 
>> there a better way to do this so that the image/PDF files only get written 
>> out when they’re first added (or changed if they do get changed).
> 
> a. It’s not obvious that the unchanged files *are* written to a temporary 
> location and then moved. The trick is to keep the original directory wrapper 
> that you got when opening the file, and to preserve the individual file 
> wrappers for unchanged components. (You can, for example, just delete the 
> file wrappers for things that *are* changed, when they’re changed, then add 
> the missing wrappers at save time.) The save mechanism then knows what has 
> and has not been changed, and can optimize the save appropriately.
> 
> b. Even if the files are copied, it’s not obvious that you need “a better 
> way”. It may be fine to copy the files at every save.
> 
> I’d recommend you don’t try to solve this problem until it forces itself on 
> you as an actual problem.
> 

Ok, I'll give it a try and see if it slows down too much or seems to be 
constantly overwriting these files before worrying any more about it. I just 
wondered if there was a "better way" to do it so I figured I'd ask before I 
delved to far into it. I'm not certain I fully understand what to do with 
NSFileWrapper in this case but I'll give it a try. My thought is to have a 
dictionary mapping each image filename to a NSFileWrapper. I may also need a 
plist of all image filenames so I can read that first and then read each of 
those image and store them in the dictionary of NSFileWrapper objects. I need 
to re-read the documentation again although it seemed the documentation for 
NSFileWrapper was pretty limited and didn't apply to this case where there's 
not a fixed number of files each with specific names.

If anyone has links to better documentation for my other question about 
exporting the document type using Xcode 7, I'm still in need of help there. 

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

UIDocument with NSFileWrapper

2016-03-19 Thread davelist
I’m creating a document-based iPad app that I will want to persist the data 
(either using NSCoding or JSON or XML) along with auxiliary files that may be 
added, but won’t be modified much, if at all (i.e., image or PDF files the app 
displays but doesn’t modify). I have prior iOS experience writing apps using 
SQLite and Core Data in Objective-C although I’m using Swift for this app.

I’ve read through this:

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/CreateCustomDocument/CreateCustomDocument.html

and I think I see how NSFileWrapper works and how to use the
 - (id)contentsForType:(NSString *)typeName error:(NSError **)outError 
method. 

The downside I see for my app is that UIDocument writes out the data to a 
temporary location and then moves it to the new location so I think my app will 
constantly be writing out these image/PDF files that never change. Is there a 
better way to do this so that the image/PDF files only get written out when 
they’re first added (or changed if they do get changed). The other data that is 
written out using NSCoding or JSON or XML will obviously change much more 
frequently.


I’ve also had trouble finding up to date/accurate information about how to 
export the document type. I’ve found these two but neither match the UI in 
Xcode 7.2/7.3 for doing this and it appears some of the plist keys are now 
different.

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/DocumentBasedAppPGiOS/DocumentImplPreflight/DocumentImplPreflight.html

https://developer.apple.com/library/ios/qa/qa1587/_index.html

Is there something else I should be reading for how to do this in Xcode 7?

Thanks,
Dave Reed


___

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

Please do not post 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: What version of OpenGL bundled in El Capitan?

2015-08-14 Thread davelist

 On Aug 13, 2015, at 10:48 AM, Laurent Daudelin laur...@nemesys-soft.com 
 wrote:
 
 I've been googling all over the place. The only references I find are the
 ones that say Metal is going to replace OpenGL. But I know that OpenGL is
 still bundled. I haven't got around to install El Capitan on my system (I
 only have one and I use it for production, having been burnt in the past, I
 prefer to wait a bit).
 
 So, anybody running El Capitan can check to see which OpenGL version is
 bundled at this time?
 
 Thanks in advance!
 
 -Laurent.
 -- 
 Laurent Daudelin laur...@nemesys-soft.com
 AIM/iChat/Skype:*LaurentDaudelin*  http://www.nemesys-soft.com/
 Logiciels Nemesys Software

Running the OpenGL Extension Viewer (free in the Mac App Store) on a 2011 
MacBook Air on El Capitan, reports OpenGL version 3.3 Intel-10.0.37

My Late 2012 iMac run Yosemite reports OpenGL version 4.1 NVIDIA-10.4.2 
310.41.35f01 so I suspect it depends on the video card/driver for the specific 
machine.

If there's something else you want me to check (and I can do it easily), let me 
know.

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

2015-07-28 Thread davelist

 On Jul 28, 2015, at 10:01 AM, Roland King r...@rols.org wrote:
 
 
 On 28 Jul 2015, at 9:12 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I gather that when using NSPrivateQueueConcurrencyType, all operations (a
 fetch for example) have to be done within a performBlock call.
 
 
 ...
 
 Then later, this context is used outside a performBlock:
 
 
 NSArray *matchingQuakes = [taskContext
 executeFetchRequest:matchingQuakeRequest error:anyError];
 
 
 Why does this work?
 
 You are supposed to call performBlock so that all accesses to the MOC are 
 serialized on the queue and so you get thread safety that way. However it's 
 quite possible to call the methods directly on the MOC in any thread context 
 and they will work, all the performBlock() actually does is queue the same 
 block of code onto the dispatch queue and when it's its turn, it executes by 
 calling [ moc executeFetch.. blah blah]. 
 
 If you do that of course you have no thread safety any more and are likely to 
 blow up. In this case there's only one thread (I believe) and so the accesses 
 are serialized anyway and it works. It's a bad piece of code. 
 
 I filed an enhancement report requesting that the coredata stack assert if 
 you called a private queue MOC method from the wrong queue, I don't recall 
 seeing anything come of it, however I do remember there is quite a lot of 
 logging you can turn up on CoreData and it's possible one such log will tell 
 you you're doing this. 

As Roland states, it is a bug. You can edit the scheme and add this to the 
arguments passed on launch and it crashes.

-com.apple.CoreData.ConcurrencyDebug 1

http://oleb.net/blog/2014/06/core-data-concurrency-debugging/

Dave Reed


___

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

Please do not post 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 davelist

 On Jul 28, 2015, at 10:14 AM, Trygve Inda cocoa...@xericdesign.com wrote:
 
 
 On 28 Jul 2015, at 9:12 pm, Trygve Inda cocoa...@xericdesign.com wrote:
 
 I gather that when using NSPrivateQueueConcurrencyType, all operations (a
 fetch for example) have to be done within a performBlock call.
 
 
 ...
 
 Then later, this context is used outside a performBlock:
 
 
 NSArray *matchingQuakes = [taskContext
 executeFetchRequest:matchingQuakeRequest error:anyError];
 
 
 Why does this work?
 
 You are supposed to call performBlock so that all accesses to the MOC are
 serialized on the queue and so you get thread safety that way. However it's
 quite possible to call the methods directly on the MOC in any thread context
 and they will work, all the performBlock() actually does is queue the same
 block of code onto the dispatch queue and when it's its turn, it executes by
 calling [ moc executeFetch.. blah blah].
 
 If you do that of course you have no thread safety any more and are likely to
 blow up. In this case there's only one thread (I believe) and so the accesses
 are serialized anyway and it works. It's a bad piece of code.
 
 I filed an enhancement report requesting that the coredata stack assert if 
 you
 called a private queue MOC method from the wrong queue, I don't recall seeing
 anything come of it, however I do remember there is quite a lot of logging 
 you
 can turn up on CoreData and it's possible one such log will tell you you're
 doing this. 
 
 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.


Use performBlockAndWait instead of performBlock.

Or do something like (typed into Mail so not checked for syntax)

[myContext performBlock:^{
   //do whatever operation with myContext

   // assuming you want doSomethingElse done on main queue
   dispatch_async(dispatch_get_main_queue(), ^{
   [self doSomethingElse];
  });

}];

I believe NSConfementConcurrencyType is deprecated so you should not use it for 
new code.

I highly recommend you read through the documentation.

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

HTH,
Dave Reed



___

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

Please do not post 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 sync between iOS and Mac apps

2015-05-12 Thread davelist

CloudKit does seem to be Apple’s answer going forward (which makes me suspect 
Core Data sync will not improve) but CloudKit requires internet access for the 
app to work at all which I don’t want to require.

I’m not sure I understand your concerns about Dropbox. The app is single user 
so when the iOS enters the background, I can upload the data (if there’s a 
network connection at the moment) for modified files to Dropbox. When the app 
starts I can check Dropbox (or warn the user that there may be a newer version 
on Dropbox if there’s no internet connection) to see if the document files are 
newer on Dropbox. It’s not as clean as a pure sync but gives the user more 
control over their data (which is important for my app).

Dave



 On May 10, 2015, at 1:37 PM, Alex Kac a...@webis.net wrote:
 
 I would try CloudKit. Its super simple and far simpler than using Dropbox. 
 Plus using Dropbox you end up with lots of issues going forward that you 
 don't want to mess with. Different database versions, data that is not 
 written to disk when you make the copy due to disk caches, and a lot more. 
 
 CloudKit is Apple's solution for sync between Apple devices. CoreData sync 
 over iCloud was never going to work well. I loved the idea, but as everyone 
 knows its implementation wasn't really foolproof. Many of us realized that 
 the better solution is a cloud sync that we designed ourselves. Apple 
 providing CloudKit solves that for Apple-only users. 
 
 
 
 On Sun, May 10, 2015 at 7:16 AM, davel...@mac.com wrote:
 
 Thanks MIchael. That's what I was afraid of (i.e., that Apple doesn't make 
 this straightforward). I first looked at BSManagedDocument 2-3 years ago but 
 never got around to trying it for my original app as I kept hoping Apple 
 would have an official solution to this problem.
 
 Also thanks to Jens Alfke for his reply about Couchbase Lite 
 (http://www.couchbase.com/nosql-databases/couchbase-mobile). I may look into 
 it but after skimming the site, I couldn't tell exactly what I would need 
 (i.e., would I need to setup my own server or use a server that your company 
 provides, etc.). I doubt my app would generate enough income to even cover 
 the server costs. My apps are for teachers and I write them because I want to 
 use them myself but they don't generate much money given the fairly narrow 
 target audience and that many schools provide systems the teacher has to use 
 for the tasks (i.e., my existing iOS apps, Attendance and Attendance2 are for 
 taking attendance in class and generating reports, etc.). Jens, I may send 
 you an email off-list with a few more questions (that you can ignore if you 
 want).
 
 I may just end up using Dropbox without sync (i.e., have the user send the 
 data to Dropbox from the iOS app) when they want to use it on the Mac and 
 import the data from Dropbox into iOS after the data has been changed on the 
 Mac. It's not elegant but it's better than risking data corruption via an 
 automatic sync that isn't reliable. Perhaps with some warnings about which 
 data is newer by looking at modification dates from the file metadata, it 
 could be usable. The app is mainly intended to be used on iOS but I want to 
 use the Mac for one or two features that would not work well on iOS.
 
 Dave
 
 
  On May 7, 2015, at 10:57 AM, Michael Swan michaels...@mac.com wrote:
 
  Dave,
  Unfortunately on the OS X side with iCloud, Core Data, and documents it is 
  pretty much a pick any two situation. The iOS side can be done but there 
  are some gotchas not really covered in the documentation. I've actually 
  just started work on my own custom subclasses of UIManagedDocument and 
  NSDocument (NSPersistentDocument is less than useless if you want to share 
  with iOS). My current plan is to use Apple's code as much as possible 
  without adding extra stores like Ensembles does. If you're interested we 
  could talk about a collaboration to build an open sourced set of classes to 
  handle this area. (I plan to include a file browser for iOS as well since 
  nothing currently exists.)
 
  On iOS you set two keys in the options dictionary to tell the system where 
  to keep the change logs and what the name should be. The name is typically 
  a UUID and the location is generally some version of ChangeLogs at the root 
  level of the ubiquity container. The catch is that your can't set those 
  options in configurePersistentStoreCoordinator… and have it come out right. 
  You have to init the document then set the persistentStoreOptions property 
  to a dictionary with those keys in order for the file package to get the 
  right structure. You also need to create the document locally first and 
  then move it to the ubiquity container.
 
  On OS X NSPersistentDocument can only make flat files, not packages like 
  UIManagedDocument (I've filed a bug about there being no counterpart to 
  UIManagedDocument for OS X, been open for over a year now…). 
  BSManagedDocument will 

Re: Core Data sync between iOS and Mac apps

2015-05-10 Thread davelist

Thanks MIchael. That's what I was afraid of (i.e., that Apple doesn't make this 
straightforward). I first looked at BSManagedDocument 2-3 years ago but never 
got around to trying it for my original app as I kept hoping Apple would have 
an official solution to this problem.

Also thanks to Jens Alfke for his reply about Couchbase Lite 
(http://www.couchbase.com/nosql-databases/couchbase-mobile). I may look into it 
but after skimming the site, I couldn't tell exactly what I would need (i.e., 
would I need to setup my own server or use a server that your company provides, 
etc.). I doubt my app would generate enough income to even cover the server 
costs. My apps are for teachers and I write them because I want to use them 
myself but they don't generate much money given the fairly narrow target 
audience and that many schools provide systems the teacher has to use for the 
tasks (i.e., my existing iOS apps, Attendance and Attendance2 are for taking 
attendance in class and generating reports, etc.). Jens, I may send you an 
email off-list with a few more questions (that you can ignore if you want).

I may just end up using Dropbox without sync (i.e., have the user send the data 
to Dropbox from the iOS app) when they want to use it on the Mac and import the 
data from Dropbox into iOS after the data has been changed on the Mac. It's not 
elegant but it's better than risking data corruption via an automatic sync that 
isn't reliable. Perhaps with some warnings about which data is newer by looking 
at modification dates from the file metadata, it could be usable. The app is 
mainly intended to be used on iOS but I want to use the Mac for one or two 
features that would not work well on iOS.

Dave


 On May 7, 2015, at 10:57 AM, Michael Swan michaels...@mac.com wrote:
 
 Dave,
 Unfortunately on the OS X side with iCloud, Core Data, and documents it is 
 pretty much a pick any two situation. The iOS side can be done but there are 
 some gotchas not really covered in the documentation. I've actually just 
 started work on my own custom subclasses of UIManagedDocument and NSDocument 
 (NSPersistentDocument is less than useless if you want to share with iOS). My 
 current plan is to use Apple's code as much as possible without adding extra 
 stores like Ensembles does. If you're interested we could talk about a 
 collaboration to build an open sourced set of classes to handle this area. (I 
 plan to include a file browser for iOS as well since nothing currently 
 exists.)
 
 On iOS you set two keys in the options dictionary to tell the system where to 
 keep the change logs and what the name should be. The name is typically a 
 UUID and the location is generally some version of ChangeLogs at the root 
 level of the ubiquity container. The catch is that your can't set those 
 options in configurePersistentStoreCoordinator… and have it come out right. 
 You have to init the document then set the persistentStoreOptions property to 
 a dictionary with those keys in order for the file package to get the right 
 structure. You also need to create the document locally first and then move 
 it to the ubiquity container.
 
 On OS X NSPersistentDocument can only make flat files, not packages like 
 UIManagedDocument (I've filed a bug about there being no counterpart to 
 UIManagedDocument for OS X, been open for over a year now…). 
 BSManagedDocument will create a file package that looks like a locally stored 
 UIManagedDocument but it doesn't have the logic for dealing with files in 
 iCloud (my current plan is to build a subclass of BSManagedDocument with the 
 extra logic in place).
 
 Apple's answer to me when I have asked about this in he past is that it is 
 possible to sync Core Data documents through iCloud but you have to do all 
 the heavy lifting (I have no idea if that will change in June, but I doubt 
 it).
 
 As far as entitlements go you just need the document option enabled and to 
 ensure that both apps use the same container.
 
 On the Mac the documents should show up in the normal open sheet just like 
 they do for TextEdit and Preview documents that are in the cloud.
 
 These guides are a good starting point:
 Document Based App Programming Guide for Mac
 Document Based App Programming Guide for iOS 
 iCloud Design Guide
 iCloud Programming Guide For Core Data
 
 Thanks,
 Mike Swan
 ETCP Certified Entertainment Electrician
 347-451-5418
 theMikeSwan.com
 
 On May 5, 2015, at 8:54 PM, cocoa-dev-requ...@lists.apple.com wrote:
 
 Message: 3
 Date: Tue, 05 May 2015 17:31:23 -0400
 From: davel...@mac.com
 To: CocoaDev cocoa-dev@lists.apple.com
 Subject: Core Data sync between iOS and Mac apps
 
 I'm looking into options for building an iOS and Mac app that can sync/share 
 Core Data between them. I'm well aware of the issues with Core Data iCloud 
 syncing in iOS 5 and 6 and that it is supposedly better so I'm willing to 
 try it. The apps can have deployment targets of iOS 8 and greater and OS X 
 

Core Data sync between iOS and Mac apps

2015-05-05 Thread davelist

I'm looking into options for building an iOS and Mac app that can sync/share 
Core Data between them. I'm well aware of the issues with Core Data iCloud 
syncing in iOS 5 and 6 and that it is supposedly better so I'm willing to try 
it. The apps can have deployment targets of iOS 8 and greater and OS X 10.10. I 
don't expect they'll be ready to release before iOS 9 and 10.11 (or whatever 
it's called) are out. The apps will be document-based in that the user can 
open different data files each which should sync separately.

The most detail explanation I can find of iCloud Core Data syncing is WWDC 2013 
session 207 (which apparently also applies to iOS 8) and the objc.io issue: 
http://www.objc.io/issue-10/icloud-core-data.html

I looked into Ensembles (http://www.ensembles.io) a bit last year and bought a 
support package. I'm also aware of BSManagedDocument (but haven't tried using 
it). And I've seen this 
http://ossh.com.au/design-and-technology/software-development/ but I didn't see 
any accompanying code.

I'm comfortable with Objective-C, Swift, and Core Data locally, but not syncing 
Core Data.

Is there someone where that I should look for that describes the steps in 
detail including setting the proper entitlements, etc. in Xcode 6?

I assume now that the iOS synced data would show up in the iCloud Drive on the 
Mac - correct - or am I missing something that it is only for iCloud Documents, 
not Core Data sync? I don't quite understand how URLForUbiquityContainer comes 
into play on the Mac if the files now appear local on the Mac. After the user 
chooses File - Open would they navigate to the iCloud Drive and select the 
file? If so, how does the code then use URLForUbiquityContainer.

Pointers to any documentation or tutorials or recommendations would be 
appreciated.

Thanks,
Dave Reed


___

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

Please do not post 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 davelist

Are you 100% certain you set the Versioned Core Data Model current setting 
to the latest model in the inspector pane on the right side of Xcode.

Have you tried doing a clean and rebuilding? I think I once had an issue where 
it didn't seem to start using the new model until I did a clean build (or in my 
case for iOS, also deleted the app from the simulator and rebuilt it so it 
installed the app fresh in the simulator).

HTH,
Dave


On Jun 18, 2013, at 11:37 AM, Martin Hewitson martin.hewit...@aei.mpg.de 
wrote:

 
 On Jun 18, 2013, at 05:26 PM, Dave Fernandes dave.fernan...@utoronto.ca 
 wrote:
 
 Looks pretty standard, but I would try commenting out the call to 
 setMetadataForStoreAtURL:
 
 I'll try this and report back.
 
 Besides that, I don't know what to suggest.
 
 I know, it's a peculiar case. I've performed light migration many, many 
 times, and this is the first time it has taken me more than a couple of 
 minutes to resolve.
 
 Thanks,
 
 Martin 
 
 
 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, 

Re: -[NSManagedObjectContext performBlock:] concurrent or serial?

2013-06-13 Thread davelist

On May 31, 2013, at 7:40 PM, Rick Mann rm...@latencyzero.com wrote:

 Hi. If I issue a bunch of -performBlock: calls on a particular Managed Object 
 Context, will they execute serially or concurrently?
 
 Thanks,
 
 -- 
 Rick

I'm assuming serially and I would like to know too so I was hoping someone 
would provide a definitive answer. Did I miss it or did nobody respond to this?

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: QR code reader/generator SDK

2013-02-07 Thread davelist

On Feb 7, 2013, at 12:45 PM, Jens Alfke j...@mooseyard.com wrote:

 
 On Feb 7, 2013, at 4:02 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:
 
 Just a short reminder: That code is LGPL, so don't just compile it into your 
 application, only link against it as a dylib/framework, and be sure to 
 include the requisite license files.
 
 But you can’t do that (use dylibs) on iOS. Has anyone found a legal 
 workaround for using LGPL code in iOS apps, or is it verboten?
 
 —Jens

But ZBar uses LGPL 2.1

From: http://zbar.sourceforge.net/iphone/sdkdoc/licensing.html

we intentionally use version 2.1, which has specific static linking 
exceptions.

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: Getting notified of any change to a specific NSManagedObject?

2012-11-16 Thread davelist

On Nov 15, 2012, at 8:22 PM, Rick Mann wrote:

 
 On Nov 15, 2012, at 17:04 , Kyle Sluder k...@ksluder.com wrote:
 
 Override -didChangeValueForKey:?
 
 Apparently we are strongly discouraged from overriding those methods. :-)
 
 -- 
 Rick

Is this documented? What would be wrong with overriding it, calling [super 
didChangeValueForKey:] and then doing whatever else you need to do?

I'm not saying that's the right thing to do - just trying to understand why 
that wouldn't be a good idea?

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: Self contained command line tool

2012-10-12 Thread davelist
I'm not certain this is what you want, but could you use Automator to create an 
app that runs your executable as a shell script? I don't know if that will give 
you a file you drag onto it as a command line parameter or not.

Dave


On Oct 12, 2012, at 2:11 PM, Gene Crucean emailgeneonthel...@gmail.com wrote:

 There are lot's of reasons for this. You can drag and drop a file to
 perform some automated task on it, or just automate some task. You can also
 use cron jobs to launch the app. Just the other day I whipped up a tiny app
 that lets me drag and drop files/folders onto my app's icon to use 7zip for
 archiving. Those are simple examples but you can do quite a bit without an
 interface :)
 
 Cheers
 
 
 On Fri, Oct 12, 2012 at 9:09 AM, Kyle Sluder k...@ksluder.com wrote:
 
 On Oct 10, 2012, at 3:24 PM, Charlie Dickman 3tothe...@comcast.net
 wrote:
 
 I have created a command line tool that executes correctly in the
 debugger. How do I get the built binary to execute independently without
 starting the Terminal app.
 
 I'm sorry, your question doesn't make sense. You've written a command line
 tool; why are you trying to execute it any other way than from the command
 line?
 
 --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/emailgeneonthelist%40gmail.com
 
 This email sent to emailgeneonthel...@gmail.com
 
 
 
 
 -- 
 Gene Crucean - Emmy winning - Oscar nominated VFX Supervisor / iOS-OSX
 Developer / Filmmaker / Photographer
 ** *Freelance for hire* **
 www.genecrucean.com
 
 ~~ Please use my website's contact form on www.genecrucean.com for any
 personal emails. Thanks. I may not get them at this address. ~~
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/davelist%40mac.com
 
 This email sent to davel...@mac.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: NSOperationQueue and for-loop

2012-10-02 Thread davelist

On Oct 2, 2012, at 5:49 PM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 Hi,
 
 When looking how to implement an NSOperationQueue with a loop, I found 
 several examples that have the following structure:
 
   NSInteger  i;
 
for ( i = 0; i  1000; i++ ) {
[queue addOperationWithBlock:^{
i += 1;
}];
}
 
 But I get a compiler error:  Variable is not assignable (missing __block type 
 specifier)
 
 I solved by declaring the declaration for i:  
 
   NSInteger __block i;
 
 But why does it work in the examples I found?
 
 Thanks,
 
 - Koen.

I can't speak to the other examples since I haven't seen them, but the __block 
specifier is necessary if your block modifies the variable (your block does 
modify i). Your example also seems a bit strange since your for loop modifies i 
itself.

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: NSOperationQueue and for-loop

2012-10-02 Thread davelist

On Oct 2, 2012, at 8:43 PM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 
 On Oct 2, 2012, at 6:19 PM, Koen van der Drift koenvanderdr...@gmail.com 
 wrote:
 
 
 On Oct 2, 2012, at 6:07 PM, davel...@mac.com wrote:
 
 I can't speak to the other examples since I haven't seen them, but the 
 __block specifier is necessary if your block modifies the variable (your 
 block does modify i). Your example also seems a bit strange since your for 
 loop modifies i itself.
 
 Ha, yes you are right, that was a quick copy-paste error. I of course want 
 something like: sum += i ;-)
 
 I didn't know about the part when a block modifies a variable. That makes 
 sense, thanks.
 
 Alright, I got it to work.
 
 Now, of course I am not just doing a simple addition in the loop, I create 
 objects, set some of their properties, do some calculations with them, and 
 add them to an array.  Some of the objects are from my own project, but some 
 of them are from a 3rd party framework. Should I add the __block to all the 
 properties of these objects as well? I can do that for the objects from my 
 own project, but the objects from the other framework are not ARC (my project 
 is), and I get a crash at the dealloc method for these. 
 
 Is there a way to solve this?
 
 Thanks again,
 
 - Koen.

Only variables that are being modified by the block need to be declared with 
the __block specifier. You shouldn't be declaring the underlying instance 
variables as __block. You can mix and match ARC and non-ARC code. Google should 
help you figure out how to do that as I can't give specific instructions off 
the top of my head.

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: iOS:targeting iOS3 through iOS6

2012-09-22 Thread davelist

On Sep 21, 2012, at 11:31 PM, Rick Mann rm...@latencyzero.com wrote:

 
 On Sep 21, 2012, at 12:29 , Igor Elland igor.ell...@me.com wrote:
 
 1. Is this correct? If not, how do I target old and new devices?
 
 No. Set the deployment target to 3.0. You'll have to take care not to use any 
 new APIs, though. Apple doesn't provide an easy way to ensure you're not 
 doing that. I recommend testing on an old device.
 
 -- 
 Rick

I think the previous post about needing to use lipo is correct. Xcode 4.5 does 
not seem to support building for armv6.

Can anyone provide the exact set of steps for combining these using lipo, 
getting it properly signed, and submitting it to Apple? The new process with 
the Xcode Organizer is nice for submitting apps, but I don't know how to 
manually do all the steps that it is doing.

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: iOS 6 self-update from beta?

2012-09-19 Thread davelist

On Sep 19, 2012, at 4:25 PM, Rick Mann rm...@latencyzero.com wrote:

 My iPad says I have 10A5376e.
 
 On Sep 19, 2012, at 13:00 , davel...@mac.com wrote:
 
 
 On Sep 19, 2012, at 1:59 PM, Rick Mann rm...@latencyzero.com wrote:
 
 Am I supposed to be able to update my iOS 6 beta iPad over the air with the 
 release today? It doesn't present it as an option.
 
 Was there a change between the last pre-release and the final (I sure hope 
 so!)?
 
 -- 
 Rick
 
 If you go here and log in with your developer account, you'll see the build 
 is still 10A403 which I believe is what the GM seed released last week was 
 so the version released last week is the same as the one posted today. 
 
 https://developer.apple.com/devcenter/ios/index.action

What happens if you go to the above URL, log in, download the appropriate file 
for your iPad and install it manually from your computer?

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: Sandboxing die.die.die

2012-08-30 Thread davelist

But you're tilting at windmills here. This is not an official support channel. 
File Radars. And yes, we've had enough arguing about the effectiveness of doing 
that. You've spent far more time here and on the Xcode list complaining about 
losing fractions of a seconds waiting for animations to complete, etc. The time 
you lost there is minuscule in comparison to the time you've spent complaining 
about the issues on these mailing lists which does no good.

And many of us lose more than those fractions of a second hitting delete every 
time we see that one of your messages is just a rant.

Dave


On Aug 30, 2012, at 6:09 PM, z...@mac.com wrote:

 Easy. When the exact items that we have issues with are addressed.
 
 It's not that hard. Listen to the developers and fix what causes the most 
 problems for them. 
 
 You satisfy their needs and as a result have developers creating great apps 
 easier and faster.
 
 If you don't do this, then the focus from management is in the wrong place.
 
 
 Sent from my Verizon Wireless BlackBerry
 
 -Original Message-
 From: Jeffrey Oleander jgo...@yahoo.com
 Sender: cocoa-dev-bounces+zav=mac.com@lists.apple.comDate: Thu, 30 Aug 2012 
 13:57:44 
 To: cocoa-dev@lists.apple.com
 Subject: Re: Sandboxing die.die.die
 
 Sandboxing die.die.die
 Code-Signing die.die.die
 Javascript die.die.die
 Kludgey CPUs die.die.die
 Bodyshopping die.die.die
 (throwing hammer at hare-brained power-mad forces of evil)
 
 Now, when can we cut the chains and get back to developing great apps?

___

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

Please do not post 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 UIManagedDocument saving/closing questions

2012-08-30 Thread davelist

I asked the question in quote email two days ago with no response so let me try 
a related, but perhaps more concise/simpler question:

Is it even necessary to call -saveToURL:forSaveOperation:completionHandler in a 
UIManagedDocument subclass or will its autosaving mechanism take care of that 
at all times, including requesting extra time with a [[UIApplication 
sharedApplication] beginBackgroundTaskWithExpirationHandler: block when 
necessary. 

In other words, can I remove all calls to 
-saveToURL:forSaveOperation:completionHandler other than the one used to create 
a new file? I am not currently using iCloud.

The symptom I'm seeing is about 1% of the people who have purchased my app are 
losing the data files (they seem to have zero size). I can't reproduce it and 
I've been using the app for 8 months while developing it without ever seeing 
this. I don't know if it's a save issue or if perhaps something such as a 
required entity attribute not getting set that is leading to the zero length 
file.

I would be extremely grateful for any suggestions on how to track this down as 
I've temporarily pulled the app from the store until I can figure this out.

Thanks,
Dave



On Aug 28, 2012, at 10:17 PM, davel...@mac.com wrote:

 
 This is on iOS 5 and higher. 
 
 I have an iOS app that can open separate data files (one open at a time) 
 using a UIManagedDocument subclass. 
 
 When I do a -saveToURL:forSaveOperation:completionHandler
 
 do I need to that inside a: 
 
 [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:
 
 block in case the application enters the background and will be terminated 
 before the save operation completes? Or does UIManagedDocument take care of 
 that for me?
 
 Also, my app delegate's
 
 - (void)applicationDidEnterBackground:(UIApplication *)application
 
 do I need to call:
 
 - (void)closeWithCompletionHandler:(void (^)(BOOL success))completionHandler
 
 
 and then reopen it in:
 
 - (void)applicationWillEnterForeground:(UIApplication *)application
 
 
 Or can I just call:
 
 -saveToURL:forSaveOperation:completionHandler
 
 in 
 
 - (void)applicationDidEnterBackground:(UIApplication *)application
 
 without worrying about closing the file if the app is later terminated?
 
 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/davelist%40mac.com
 
 This email sent to davel...@mac.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


CoreData UIManagedDocument saving/closing questions

2012-08-28 Thread davelist

This is on iOS 5 and higher. 

I have an iOS app that can open separate data files (one open at a time) using 
a UIManagedDocument subclass. 

When I do a -saveToURL:forSaveOperation:completionHandler

do I need to that inside a: 

[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:

block in case the application enters the background and will be terminated 
before the save operation completes? Or does UIManagedDocument take care of 
that for me?

Also, my app delegate's

- (void)applicationDidEnterBackground:(UIApplication *)application

do I need to call:

- (void)closeWithCompletionHandler:(void (^)(BOOL success))completionHandler


and then reopen it in:

- (void)applicationWillEnterForeground:(UIApplication *)application


Or can I just call:

-saveToURL:forSaveOperation:completionHandler

in 

- (void)applicationDidEnterBackground:(UIApplication *)application

without worrying about closing the file if the app is later terminated?

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: Sharing a file between Mac and iOS

2012-07-19 Thread davelist

On Jul 19, 2012, at 12:52 PM, Jerry Krinock wrote:

 
 On 2012 Jul 19, at 08:22, Dennis wrote:
 
 Unfortunately iCloud is not an option for me
 
 Dropbox :))
 
 Seriously, Dropbox won't give you any crap.  Read this, though, and then 
 research further to learn if the App Store rejection issue has been resolved…
 
 http://www.macrumors.com/2012/05/02/ios-apps-with-dropbox-integration-running-afoul-of-apples-app-store-rules/
 

Dropbox released a new SDK that solved the App Store rejection so that is no 
longer an issue.

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: ARC not ready for primetime?

2012-03-26 Thread davelist

If you want to be certain Apple see this, please file a bug report at 
http://bugreport.apple.com

Dave


On Mar 25, 2012, at 1:05 PM, Scott Andrew wrote:

 I've uploaded a quick sample that shows what i have been seeing. I put some 
 NSLogs to show the deallocs for the NWColorViewController and NWColorLayer so 
 you can see dealloc being called. Load in instruments Allocations app and 
 switch back and forth a few times and end on the Hide tab. Basically this 
 is creating and destroying a color view controller (my real app does this as 
 a datasource for UIPageViewController). Go to the object list and filter by 
 NWLayerTest, you will small amounts of memory leaked where the view 
 controller was created and added to the subview.
 
 This is exactly what i am seeing in my code. Bits of runtime being left 
 behind. 
 
 i have uploaded a sample project to 
 https://bitbucket.org/ScottAndrew/arc-memory-issue
 
 Scott
 
 On Mar 24, 2012, at 5:11 AM, T.J. Usiyan wrote:
 
 Could you post the code for the sublayer and what is the residual memory?
 On Sat, Mar 24, 2012 at 4:17 AM, Scott Andrew 
 scottand...@roadrunner.comwrote:
 
 I seem to have hit a few limitations with ARC.
 
 1.) Subclasses of CALayer are not being fully released which causes my
 view controller to remain around. There is still some small bit of memory
 being left behind. Even if I do the following simple code:
 
 -(void) viewDidLoad {
 
  [super viewDidLoad];
 
  CNFooLayer* foo = [CNFooLayer layer];
 
  [self.view.layer addSublayer:cup];
 }
 
 Cup is:
 
 @interface CNFooLayer : CALayer
 @end
 
 
 If you change the above too:
 
  [super viewDidLoad];
 
  CALayer* foo = [CALayer layer];
 
  [self.view.layer addSublayer:cup];
 
 all is good.
 
 If I watch the object list the object allocations you can see that there
 is residual memory left behind and my view controller is still around (even
 though dealloc was called).
 
 2.) I have a simple class with lost of properties that if i alloc and init
 it will cause my hand created view controller to stick around. Remove the
 alloc in the view controller and all is fine.
 
 I seem to be at the point now where need to remove arc and go back to
 retain, release. The weird thing is leaks has no leaks, watching for my
 viewController in statistics shows that it has gone away. However heapshot
 shows residual and so does the object list.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/griotspeak%40gmail.com
 
 This email sent to griotsp...@gmail.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/scottandrew%40roadrunner.com
 
 This email sent to scottand...@roadrunner.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/davelist%40mac.com
 
 This email sent to davel...@mac.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


copying objects between two Core Data persistent stores?

2012-01-06 Thread davelist
I'd like to copy items between two different UIManagedDocument persistent 
stores. What is the proper way to do this?

Assuming I have a NSManagedObject subclass instance mo1 obtained from one 
UIManagedDocument, how do I properly copy the values from it to a newly 
inserted NSManagedObject subclass instance mo2 in the other UIManagedDocument?

Do I just run through all the properties I've defined for each attribute and do:
mo2.attribute = mo1.attribute
(which I could do by defining a method to do this)? I think this is ok, but I'm 
not 100% certain since these come from different NSManagedObjectContext 
instances so I want to be certain that won't cause a problem. Do all the 
properties need to be copy properties vs. strong/retain properties for this to 
work?

Or is there a better/simpler way to do this?

Also, I asked another Core Data question about four days ago, but never got a 
response. If you can answer this one too, that would be great.

===

If I create a child context of type NSMainQueueConcurrencyType such as:

   context = [[NSManagedObjectContext alloc] 
initWithConcurrencyType:NSMainQueueConcurrencyType];
   [context setParentContext:mainContext];

do I need to call [context performBlock:^{ // some code }];

or can I just use the context normally if I know the code is being executed on 
the main thread/queue?

Similarly, do I need to use performBlock on the UIManagedDocument's 
managedObjectContext property when I know the code is being executed on the 
main thread?

I think the answer to both questions is no, you do not need to use 
performBlock, but I'd like to be certain.

=

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

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


need to use NSManagedContext performBlock for contexts with NSMainQueueConcurrencyType?

2012-01-02 Thread davelist
If I create a child context of type NSMainQueueConcurrencyType such as:

context = [[NSManagedObjectContext alloc] 
initWithConcurrencyType:NSMainQueueConcurrencyType];
[context setParentContext:mainContext];

do I need to call [context performBlock:^{ // some code }];

or can I just use the context normally if I know the code is being executed on 
the main thread/queue?

Similarly, do I need to use performBlock on the UIManagedDocument's 
managedObjectContext property when I know the code is being executed on the 
main thread?

I think the answer to both questions is no, you do not need to use 
performBlock, but I'd like to be certain.

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

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


predicates and sort descriptors for NSFetchRequest - documentation is a bit vague

2011-12-14 Thread davelist

I have a fetch request with sort descriptors that was sorting on a many-one 
relationship (i.e., I'm fetching Entity A which has a relationship to one 
entity B and I was trying to get back the array of A entities sorted on an 
attribute of B). This doesn't work using sort descriptors; however, if I apply 
the sort descriptor to the resulting array, it does work.

I then read this link:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html

which states:

You cannot fetch using a predicate based on transient properties (although you 
can use transient properties to filter in memory yourself). Moreover, there are 
some interactions between fetching and the type of store—for details, see 
“Store Types and Behaviors.” To summarize, though, if you execute a fetch 
directly, you should typically not add Objective-C-based predicates or sort 
descriptors to the fetch request. Instead you should apply these to the results 
of the fetch. If you use an array controller, you may need to subclass 
NSArrayController so you can have it not pass the sort descriptors to the 
persistent store and instead do the sorting after your data has been fetched.

The if you execute a fetch directly, you should typically not add 
Objective-C-based predicates or sort descriptors to the fetch request. bothers 
me as I see lots of examples where they are used in books on Core Data.

I read the Store Types and Behaviors link also 
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdPersistentStores.html#//apple_ref/doc/uid/TP40002875-SW3

but that didn't seem to help me understand it much more. I understand the 
transient property issue, but don't know what predicates and sort descriptors 
you can use and which ones you cannot. Predicates are more important to me as 
I'd like to limit the amount of data (and thus limit the amount of memory used) 
I get back whereas sorting afterwards is not too big an issue.

Can someone please elaborate on what kinds of predicates and sort descriptors 
you can use when executing an NSFetchRequest using the NSManagedObjectContext 
method: executeFetchRequest:error: ?

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

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


Re: help trouble shooting...maybe with resume?

2011-08-23 Thread davelist

On Aug 23, 2011, at 11:00 AM, Jim Thomason wrote:

 Gang,
 
 Unfortunately, this is a very vague question but I'm at a bit of a
 loss and hoping someone could provide some general technique or
 avenues to explore.
 
 Apple recently rejected a new app of mine, with this explanation:
 
 When saving a file, and reopening it by double-clicking the saved file
 in the Finder, the app launches with 2-3 windows: One being the saved
 file, and additional windows with no saved data. Mac OS X 10.7
 
 
 I'm guessing it's due to Lion's resume window features somehow getting
 confused. The app is document based, and it looks at the document
 controller's recently opened documents upon launch. If it finds any,
 it automatically opens the last document used. If the list is empty,
 it automatically creates an untitled document. The snippet of code is
 essentially unchanged from when I originally wrote it for a different
 app way back on Tiger. This is called in the delegate from
 applicationDidFinishLaunching:. applicationShouldOpenUntitledFile:
 returns NO.
 
 Here are my problems - first of all, I can't reproduce the blasted
 bug. Everything seems to always behave fine to me, on 10.7.0 or
 10.7.1. I've requested more info about how to reproduce the bug but
 haven't heard back yet.
 
 Regardless of whether they get back to me, does what I've described
 sound like it could be the root of my issue? Is there some other
 method for re-opening the last document (or creating a new one) I
 should be using? Is there anything else I can look for or verify that
 might be causing this behavior?
 
 Naturally, it'd help if I could manifest the issue myself, but right
 now I just don't even know where to begin looking for this one. :-(
 
 -Jim…..


Your problem is likely related to how resume works in Lion. I've had some 
similar issues. In my application's applicationDidFinishLaunching method, I 
have the following to display a launch window with recently opened documents 
(similar to Xcode's launch window).


 if( [[[NSDocumentController sharedDocumentController] documents] count] == 0 ) 
{
launchController = [[LaunchController alloc] init];
[launchController showWindow:self];
}  

The problem is that the if statement evaluates to true even if the Lion resume 
feature is going to open some documents. So it appears the resume hasn't gotten 
far enough by the time applicationDidFinishLaunching is called for the 
sharedDocumentController to know about the documents it will open.

My hack solution was to execute the code after a delay of 0.75 seconds using 
dispatch_after and by that time the resume seems to have completed so if resume 
opened any documents, the if statement evaluates to false. I'd love to know if 
there's a more proper solution to this as the timing hack is fragile. In my 
case it just opens another window the user can close so it's not really a 
crisis.

Jim, my guess is your code is reopening documents when resume is also trying to 
open them and you end up with extra windows. I can't tell from your report of 
what the app review team said as to whether your code is opening up extra blank 
windows or extra windows with the same document (which I would think never 
happens given Apple's document controller).

HTH,
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: printDocument: hangs on Lion?

2011-08-22 Thread davelist

I'm not saying it's a bug in your code, but I have +autosavesInPlace set to 
return YES in my app and I can't reproduce your problem when printing. I know 
this doesn't solve your problem, but figured it might be worth knowing that not 
everyone is seeing this problem.

Dave


On Aug 22, 2011, at 9:26 AM, Graham Cox wrote:

 Further info, if I take out +autosavesInPlace (was overridden to return YES), 
 it works fine.
 
 This suggests there's more to supporting this new-fangled document model to 
 allow printing to work. Any documentation spells this out?
 
 Working in Xcode 4, the documentation viewer is so incredibly poor compared 
 to Xcode 3 I can't find anything, or rather I can't wait the ten minutes per 
 page it takes to download anything (aside: is there a way to d/l all the 
 documentation and view it locally? We don't all have gigabit fibre to the 
 node).
 
 --G.
 
 
 On 22/08/2011, at 10:59 PM, Graham Cox wrote:
 
 When my NSDocument subclass has its printDocument: method called, Lion hangs 
 indefinitely. Snow Leopard works fine.
 
 The top of my stack looks like this:
 
 #0   0x7fff905676b6 in semaphore_wait_trap ()
 #1   0x7fff85ddb08e in _dispatch_semaphore_wait_slow ()
 #2   0x7fff881b2616 in -[NSDocument 
 performActivityWithSynchronousWaiting:usingBlock:] ()
 #3   0x7fff881a2518 in -[NSDocument 
 runModalPrintOperation:delegate:didRunSelector:contextInfo:] ()
 #4   0x00010009e544 in -[GCOrteliusDocument 
 runModalPrintOperation:delegate:didRunSelector:contextInfo:] at 
 /Users/grahamcox/Projects/Artboard/Artboard/Source/Code/GCOrteliusDocument.m:1476
 #5   0x0001002f5b9f in -[DKDrawingDocument printShowingPrintPanel:] at 
 /Users/grahamcox/Projects/DrawKit/DrawKit/../Source/Code/DKDrawingDocument.m:923
 #6   0x7fff881a1a52 in __-[NSDocument 
 printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:]_block_invoke_2
  ()
 #7   0x7fff881a95e0 in -[NSDocument _commitEditingThenContinue:] ()
 #8   0x7fff881a52ab in -[NSDocument 
 _commitEditingWithDelegate:didSomethingSelector:contextInfo:thenContinue:] ()
 #9   0x7fff881a18bf in __-[NSDocument 
 printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:]_block_invoke_1
  ()
 #10  0x7fff881b2670 in -[NSDocument 
 performActivityWithSynchronousWaiting:usingBlock:] ()
 #11  0x7fff881a17d1 in -[NSDocument 
 printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:]
  ()
 #12  0x7fff881a1763 in -[NSDocument printDocument:] ()
 
 
 So it's waiting on some lock, but it never gets it. This is on the main 
 thread, therefore my app just grinds to a halt and has to be force quit.
 
 I'm at a loss as to what to do - it doesn't seem to be my bug.
 
 --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:
 http://lists.apple.com/mailman/options/cocoa-dev/graham.cox%40bigpond.com
 
 This email sent to graham@bigpond.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/davelist%40mac.com
 
 This email sent to davel...@mac.com

___

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

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

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

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


Re: Creating a TCP server?

2011-07-26 Thread davelist
Here's some sample code (I'm not the author)

https://bitbucket.org/snej/mynetwork/overview

Dave


On Jul 26, 2011, at 4:00 PM, Bing Li wrote:

 Hi, Rick,
 
 If you are familiar with BSD socket, you can program with it to create a TCP
 server. I have done that successfully.
 
 Thanks,
 Bing
 
 On Wed, Jul 27, 2011 at 3:17 AM, Rick Mann rm...@latencyzero.com wrote:
 
 Hi. I need to build a little serial port-to-TCP server (so that clients can
 connect to my Mac to interact with a serial port). Among other things, I
 want to advertise this using Bonjour.
 
 How do I create a TCP server in Cocoa? It seems like CF networking is my
 best bet, but I thought TCP should be easy via Cocoa. I briefly looked at
 NSSocket and NSStream, but they're not really what I want, I think.
 
 And to verify: is NSNetServices what I need to publish the Bonjour name?
 
 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Printing options

2011-07-21 Thread davelist

On Jul 19, 2011, at 3:25 PM, Amy Gibbs wrote:

 Hi,
 
 I've read everything that says printing is easy...but I'm struggling with it!
 
 I have googled, but nothing quite seems to fit my situation, I just want a 
 single page.
 
 In my app I have customer orders, and I just want to print out a copy. I 
 can't work out what the best option would be. I can probably create an html 
 file (and have css to format it) and save it to disk, but then I'd still have 
 to print it, either within my app, or with a browser, or I could create a PDF 
 and try and print that? or I could lay it all out on a view and print that? 
 Some orders have more than 1 item though, and tableviews don't seem to print 
 properly so how should I lay out a list of products? It should easily fit on 
 1 page, just a name address and a couple of lines of product details.
 
 It's all in a CoreData app,
 
 I'd appreciate any help, Thanks,
 
 Amy

If you want to print something different than what is on the screen, the best 
example of this I've seen is in the Hillegas book (Cocoa Programming for Mac OS 
X, 3rd Ed).

HTH,
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: Progress Indicators Spin vs Bar

2011-06-20 Thread davelist

On Jun 20, 2011, at 11:43 PM, James Merkel wrote:

 
 
 On Jun 20, 2011, at 7:23 PM, Conrad Shultz wrote:
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 6/20/11 3:54 PM, James Merkel wrote:
 I'm opening all  digital camera files in a folder (JPEG, TIF, etc),
 extracting a thumbnail and some Exif data, and putting the data in a
 TableView. The time consuming part is finding the thumbnails in the files.
 
 OK.
 
 I don't know anything about extracting thumbnails et al., but for the
 sake of argument suppose you have a class JMImageProcessor that has
 methods like:
 
 - - (id)initWithFileHandle:(NSFileHandle *)fileHandle;
 - - (NSDictionary *)exifData;
 - - (NSImage *)thumbnail; // Takes a long time to run
 
 So in your main thread you then have a loop over a bunch of
 NSFileHandles (of course you might be accessing the files completely
 differently; this is just for illustration).  So you might currently have:
 
 for (NSFileHandle *fileHandle in files) {
  JMImageProcessor *processor = [[JMImageProcessor alloc]
 initWithFileHandle:fileHandle];
  // Call some code to stash the results, presumably updating the
 tableView's data source in the process
  [self setExifData:[processor exifData] forFile:fileHandle];
  [self setThumbnail:[processor thumbnail] forFile:fileHandle];
  [processor release];
  // Call some code to redisplay the NSTableView
  [self updateTable];
 }
 
 
 
 
 You could make such code non-blocking with, for example, GCD:
 
 
 
 
 dispatch_queue_t workerQueue =
 dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, NULL);
 
 for (NSFileHandle *fileHandle in files) {
  dispatch_async(workerQueue,
  ^{
  JMImageProcessor *processor = [[JMImageProcessor alloc]
 initWithFileHandle:fileHandle];
  [self setExifData:[processor exifData] 
 forFile:fileHandle];
  [self setThumbnail:[processor thumbnail] 
 forFile:fileHandle];
  [processor release];
  dispatch_async(dispatch_get_main_queue(),
  ^{
  [self updateTable];
  // UI updates need to be on the main 
 thread, i.e., the GCD main
 queue, so we call back asynchronously
  }
  );
  }
  );
 }
 
 (Note 1: this was all written in a mail client and untested.)
 
 (Note 2: the above assumes that the setExifData/setThumbnail methods are
 implemented properly, atomically if required.  But if the methods are
 backed by, for example, mutable dictionaries, and anything accessing
 them handle absent entries reasonably, this should be pretty
 straightforward.)
 
 (Note 3: this could all alternatively be done with NSOperationQueue, or
 even plain old NSThread.  But GCD can probably do it in the smallest
 amount of code.)
 
 Good luck!
 
 - --
 Conrad Shultz
 
 Synthetiq Solutions
 www.synthetiqsolutions.com
 

 First of all (kind of basic) what is GCD ?
 
 I have actually implemented this a couple of different ways (not using 
 threads).
 At first I just had lazy loading of the TableView. Whenever the TableView 
 needed something a file was accessed and a thumbnail extracted. Then I 
 changed it to do preprocessing. That is, everything was extracted from the 
 files  and then the TableView was allowed to load. The first approach uses 
 less memory but is slower in updating the TableView (when it is scrolled for 
 example). The second approach uses more memory but is faster in updating 
 (provides a better user experience). I think trying to do this in a separate 
 thread would be much cleaner using the second approach.
 
 I forgot to mention the really slow case: if a thumbnail can't be found in 
 the file, then I make a thumbnail from the main image. If this has to be done 
 on a lot of files, then things really bog down.
 
 Jim Merkel


GCD is Grand Central Dispatch - Apple's very nice API for writing multithreaded 
code.

You should read the Concurrency Programming Guide at developer.apple.com

https://developer.apple.com/library/mac/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html

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


@selector signature with two colons instead of actual message name

2011-05-03 Thread davelist

I create a sheet using the following:

 [alert beginSheetModalForWindow:[self windowForSheet] modalDelegate:self 
didEndSelector:@selector(noEmailAlertDidEnd::contextInfo:) contextInfo:NULL];

What looks strange to me is the @selector(noEmailAlertDidEnd::contextInfo:) 
that got created by Xcode's code completion. The signature of the method is:

- (void)noEmailAlertDidEnd:(NSAlert*) returnCode:(NSInteger)retCode 
contextInfo:(void*)ctxInfo {

So why does code completion put two colons in a row instead of returnCode: and 
if I insert returnCode: in the @selector I get an unrecognized selector 
exception when I run it. It does work fine with the two colons in a row. What 
am I missing as I don't understand why it works with the two colons and why it 
does not work with the returnCode:?

This is on 10.6.7 using Xcode 4.0.2

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

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


Re: Mac App Store requirements

2011-04-10 Thread davelist

And you also have add code to verify a valid receipt. There's a few samples of 
how to do this on github (you should modify them to make the app more difficult 
to crack unless you're giving the app away for free). Apple has more about this 
that you can read once you join the developer program.

Dave

On Apr 10, 2011, at 3:48 PM, Tom Hohensee wrote:

 Not yet. You have some setup work to do in itunesconnect.  
 Apple provides a step by step guideline for submission
 
 Sent from my iPhone
 
 On Apr 10, 2011, at 2:28 PM, Artemiy Pavlov artemiy.pav...@ukrpost.ua wrote:
 
 I am aware of this, and I meant only the technical side. So I built a Cocoa 
 app with XCode, so I can join the developer programme and I am ready to go 
 just like that?
 
 A.
 
 On 10 Apr 2011, at 21:47, Laurent Daudelin wrote:
 
 There is a set of guidelines about things you should avoid if you don't 
 want your app to be rejected. Not sure if it's available to non-registered 
 Mac developers but I think it should.
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelinhttp://www.nemesys-soft.com/
 Logiciels Nemesys Software  laur...@nemesys-soft.com
 
 On Apr 10, 2011, at 11:16, Artemiy Pavlov wrote:
 
 Hey all,
 
 I am not yet a member of the Mac Developer program, but I am experimenting 
 with my own Cocoa OS X app and I would like to know what are the 
 requirements on getting it into the Mac App Store.
 
 I mean, I have a 32/64 bit Intel build of a vanilla Cocoa app in XCode. 
 Where will I go from there? Apart from signing the code with a certificate 
 that you receive from Apple, what one needs to do to get his app bundle 
 into the Mac App Store? 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/tom.hohensee%40gmail.com
 
 This email sent to tom.hohen...@gmail.com
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/davelist%40mac.com
 
 This email sent to davel...@mac.com

___

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

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

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

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


Re: specifying new document types that an app opens

2011-02-12 Thread davelist

On Feb 11, 2011, at 8:04 PM, davel...@mac.com wrote:

 I'm working on a document-based app for the Mac App Store. The data file I'm 
 reading/writing is actual a Sqlite database file. I've been able to get it to 
 work with the following in my info.plist file (although for this email I've 
 used appname in place of the actual appname and file extension I'm using.
 
   keyCFBundleDocumentTypes/key
array
dict
keyCFBundleTypeExtensions/key
array
stringappname/string
/array
keyCFBundleTypeIconFile/key
stringAppName.icns/string
keyCFBundleTypeName/key
stringAppName Document/string
keyCFBundleTypeRole/key
stringEditor/string
keyNSDocumentClass/key
stringMyDocument/string
/dict
/array
 
keyUTExportedTypeDeclarations/key
array
dict
keyUTTypeDescription/key
stringAppName document/string
keyUTTypeIdentifier/key
stringcom.dave256apps.appname/string
keyUTTypeTagSpecification/key
dict
keypublic.filename-extension/key
stringappname/string
/dict
/dict
/array
 
 It appears CFBundleTypeExtensions is deprecated and I should be using 
 LSItemContentTypes, but I can't get it to work with that. What exactly should 
 the plist file look like to work with that?
 
 Also, will making these changes prevent me from opening documents I've 
 already created with it set up as above? If so, is there a way around it.
 
 Thanks in advance,
 Dave


I'm not certain what was wrong, but I deleted the document information from the 
Xcode project and re-added it and everything seems to be working ok now with 
LSItemContentTypes.

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


specifying new document types that an app opens

2011-02-11 Thread davelist
I'm working on a document-based app for the Mac App Store. The data file I'm 
reading/writing is actual a Sqlite database file. I've been able to get it to 
work with the following in my info.plist file (although for this email I've 
used appname in place of the actual appname and file extension I'm using.

   keyCFBundleDocumentTypes/key
array
dict
keyCFBundleTypeExtensions/key
array
stringappname/string
/array
keyCFBundleTypeIconFile/key
stringAppName.icns/string
keyCFBundleTypeName/key
stringAppName Document/string
keyCFBundleTypeRole/key
stringEditor/string
keyNSDocumentClass/key
stringMyDocument/string
/dict
/array

keyUTExportedTypeDeclarations/key
array
dict
keyUTTypeDescription/key
stringAppName document/string
keyUTTypeIdentifier/key
stringcom.dave256apps.appname/string
keyUTTypeTagSpecification/key
dict
keypublic.filename-extension/key
stringappname/string
/dict
/dict
/array

It appears CFBundleTypeExtensions is deprecated and I should be using 
LSItemContentTypes, but I can't get it to work with that. What exactly should 
the plist file look like to work with that?

Also, will making these changes prevent me from opening documents I've already 
created with it set up as above? If so, is there a way around it.

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

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


Re: UIDatePicker displays incorrect day in UIDatePickerDateAndTime mode for zones 12+ hours ahead of defaultZone

2011-01-14 Thread davelist

I'm not the original author of this thread, but I submitted a bug back in 
August 2010 about these issues. It was marked as a duplicate and I've never 
heard anything more. Perhaps I don't know how to properly follow duplicates. My 
bug # is 8320528.

Dave


On Jan 14, 2011, at 4:34 PM, Deborah Goldsmith wrote:

 Did you write a bug for this? What is the bug number?
 
 Thanks,
 Deborah Goldsmith
 Apple Inc.
 
 On Jan 10, 2011, at 10:12 AM, Steve Mykytyn wrote:
 
 UIDatePicker (4.2.1) shows differing dates for the modes 
 
 UIDatePickerDate (correct),  and
 
 UIDatePickerDateAndTime (incorrect) 
 
 when the timezone you assign to the UIDatePicker is 
 
 - more than 12 hours ahead (east) of the systemTimeZone of the iPhone.
 
 For example, 
 
 device system time zone = America/Los Angeles = GMT - 8
 
 Honolulu date: Dec 7, 1941 7:48am
 
 Tokyo date: Dec 8, 1941 3:18am
 
 UIDatePicker will show the Tokyo date for mode
 
 UIDatePickerDate (correct): Dec 8, 1941
 
 UIDatePickerDateAndTime: Dec 7, 1941
 
 In fact, UIDatePicker will show incorrect dates in this case for any time 
 zone east of GMT + 4 (always one day before correct day)
 
 
 A work-around in viewDidLoad is:
 
  self.datePicker.datePickerMode = UIDatePickerModeDateAndTime;   
  
  self.datePicker.minuteInterval = 1;
 
  self.datePicker.timeZone = timeZone;
  
  [NSTimeZone setDefaultTimeZone:timeZone];  //  *** add this line to 
 force date picker to show correct date in all modes
  
  [self.datePicker setDate:tzDate animated:YES];  
 
 and in viewWillDisappear add:
 
  [NSTimeZone resetSystemTimeZone];
 
  [NSTimeZone setDefaultTimeZone:[NSTimeZone systemTimeZone]];
 
 Not super happy about the work-around, but it should be fairly robust even 
 if this bug is fixed in future.
 
 If anyone can shed some light on this behavior, please advise.  No amount of 
 fooling around with calendars, locales, etc. fixed this until i reset the 
 default zone.
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/goldsmit%40apple.com
 
 This email sent to golds...@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:
 http://lists.apple.com/mailman/options/cocoa-dev/davelist%40mac.com
 
 This email sent to davel...@mac.com

___

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

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

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

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


binding NSSearchField to an NSArrayController

2010-12-18 Thread davelist
I can't seem to get the NSSearchField bindings to work properly for searching 
items in an NSTableView (whose columns are bound to an NSArrayController).

I have an NSArrayController and its array contains Student objects. Student has 
a property named last that is the last name and displays in a column of the 
NSTableView.

In the Search bindings of the NSSearchField, I bind to the NSArrayController, 
set the Controller Key to filterPredicate, set the Display Name to Last, but I 
can't figure out what to put in the Predicate Format (or if I need a Model Key 
Path) setting.

I've tried: last contains $value

but I get the error:
Exception detected while handling key input.
Can't use in/contains operator with collection LAST (not a collection)

I've tried: last like $value

but I get no errors and no filtering when I press the enter key.

What should I be doing to get the search to work?

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

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


Re: Using bindings to lessen amount of code

2010-12-14 Thread davelist

On Dec 13, 2010, at 12:25 PM, Paul Johnson wrote:

 I want to obtain the value at a particular row and column in a table.
 
 
 I implemented the datasource protocol method
 tableView:objectValueForTableVColumn:row:
 
 
 In this method I return [[self.arrangedObjects valueForKey:@symbol]
 objectAtIndex:rowIndex].
 
 
 Is there a way to solely use bindings to accomplish this and not implement
 the datasource protocol method at all?


Yes. You create an NSArrayController and then bind each table column. See the 
appropriate examples here:

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

HTH,
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: NSDocument app where the document is a SQLite file

2010-12-10 Thread davelist

On Dec 7, 2010, at 11:13 AM, davel...@mac.com wrote:

 I've written a few small personal Mac apps and one iOS app and now am 
 attempting to write my first NSDocument-based Mac application. I would like 
 the document itself to be a SQLite file (with specific tables for my app - 
 not a generic SQLite file). I've been reading through the NSDocument 
 documentation and it appears this can be done, but I'm not 100% certain of 
 the steps and wanted to make certain I wasn't going down a path I shouldn't 
 before getting too far into it. Here is what I think I need to do:
 
 Here's what I think I need to do in my NSDocument subclass.
 
 When the user chooses a File-New, the method - (id)initWithType:(NSString 
 *)typeName error:(NSError **)outError is called so in it I would create a 
 SQLite database file in a temporary location and call setFileURL: to store 
 the location of that SQLite file (and store a connection to the SQLite 
 database file).
 
 In the - (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
 error:(NSError **)outError, if the passed absoluteURL matches the return 
 value of fileURL:  I would do something like commit the SQLite transactions. 
 If the absoluteURL did not match the returned value of fileURL: I need to 
 copy the current SQLite file to this location. Will this work ok?
 
 In the - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
 error:(NSError **)outError  I would just open the SQLite file and store my 
 connection to it for use in the other methods for updating the file.
 
 Am I missing something? Is attempting to use a SQLite file as the document 
 file a bad idea?
 
 I'm also considering an iOS application that uses the same SQLite database 
 files so that's why I'd like to use SQLite on the Mac if possible. I'm also 
 not ready to tackle using Core Data although that may be the better option if 
 there are reasons that SQLite doesn't map well to a NSDocument based 
 application. My other option is to not use the NSDocument architecture, and 
 just open one file at a time in my GUI but I thought I'd try to learn about 
 the NSDocument architecture while writing it.
 
 Thanks,
 Dave

Nobody replied, but in case anyone else wants to try this, I think the best 
solution is to use the special sqlite :memory: database and load and save files 
between the file and the :memory: database. See 
http://www.sqlite.org/backup.html  In my case the sqlite files will never be 
more than 100KB so storing them in memory is a reasonable solution. Obviously 
if your files are much closer to the amount of RAM, this wouldn't be a good 
solution. 

If I run into issues farther along in the process with this approach, I'll post 
a follow-up to this thread, but as of now, I don't see any reason why it won't 
work.

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


NSDocument app where the document is a SQLite file

2010-12-07 Thread davelist
I've written a few small personal Mac apps and one iOS app and now am 
attempting to write my first NSDocument-based Mac application. I would like the 
document itself to be a SQLite file (with specific tables for my app - not a 
generic SQLite file). I've been reading through the NSDocument documentation 
and it appears this can be done, but I'm not 100% certain of the steps and 
wanted to make certain I wasn't going down a path I shouldn't before getting 
too far into it. Here is what I think I need to do:

Here's what I think I need to do in my NSDocument subclass.

When the user chooses a File-New, the method - (id)initWithType:(NSString 
*)typeName error:(NSError **)outError is called so in it I would create a 
SQLite database file in a temporary location and call setFileURL: to store the 
location of that SQLite file (and store a connection to the SQLite database 
file).

In the - (BOOL)writeToURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
error:(NSError **)outError, if the passed absoluteURL matches the return value 
of fileURL:  I would do something like commit the SQLite transactions. If the 
absoluteURL did not match the returned value of fileURL: I need to copy the 
current SQLite file to this location. Will this work ok?

In the - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName 
error:(NSError **)outError  I would just open the SQLite file and store my 
connection to it for use in the other methods for updating the file.

Am I missing something? Is attempting to use a SQLite file as the document file 
a bad idea?

I'm also considering an iOS application that uses the same SQLite database 
files so that's why I'd like to use SQLite on the Mac if possible. I'm also not 
ready to tackle using Core Data although that may be the better option if there 
are reasons that SQLite doesn't map well to a NSDocument based application. My 
other option is to not use the NSDocument architecture, and just open one file 
at a time in my GUI but I thought I'd try to learn about the NSDocument 
architecture while writing it.

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

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


Re: Updating progress of UIProgressView. And Getting Better Saving Performance

2010-12-06 Thread davelist

On Dec 6, 2010, at 5:37 PM, Gustavo Pizano wrote:

 Hello.
 
 My application is saving some data, and it takes a while to do it, it can be 
 1 second to 10 sec around.. Im doing some image processing,  The thing is..
 
 I send the saving operation in another thread using the NSThread + 
 detachNewThreadSelector:toTarget:withObject: method,  and in the main thread 
 I update a UIActivityIndicator, and stop it when I receive the 
 NSThreadWillExitNotification.  The problem is that when it takes long to 
 save, it may seem the app is somehow stuck,  even the spinning indicator is 
 running. I wanted to change the ActivityIndicator to a progressview, but then 
 I can't make it work because the saving process not on the main thread, i 
 think.. correct me if Im wrong, Im not so much familiar with multithreaded 
 apps.
 
 As for the saving process, what I do is the following.
 
 I have a Parent view which contains subviews, these subviews are drawing 
 images. The user can modify this images, (scale and rotate), so when I save i 
 encode these views so it will save the view's transform,  and then  I archive 
 the data I encoded for all these subviews.


your code deleted

You are correct that you cannot call GUI methods from other threads, but 
NSObject (which all your UI objects inherit from) has the method.

- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg

So from your other thread, you can update the progress indicator by using it to 
call a method that updates the progress. 


This is even easier if you are targeting iOS 4.0 and higher using Blocks and 
GrandCentral Dispatch.

Code typed in email (i.e., not tested):

   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 
0), ^{
// code you want implemented on another thread goes here:

dispatch_async(dispatch_get_main_queue(), ^{
   // code executed on main thread goes here (i.e., updating the 
progress indicator in your case

});
});

HTH,
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: Updating progress of UIProgressView. And Getting Better Saving Performance

2010-12-06 Thread davelist

On Dec 6, 2010, at 9:21 PM, Laurent Daudelin wrote:

 On Dec 6, 2010, at 17:16, davel...@mac.com wrote:
 
 On Dec 6, 2010, at 5:37 PM, Gustavo Pizano wrote:
 
 Hello.
 
 My application is saving some data, and it takes a while to do it, it can 
 be 1 second to 10 sec around.. Im doing some image processing,  The thing 
 is..
 
 I send the saving operation in another thread using the NSThread + 
 detachNewThreadSelector:toTarget:withObject: method,  and in the main 
 thread I update a UIActivityIndicator, and stop it when I receive the 
 NSThreadWillExitNotification.  The problem is that when it takes long to 
 save, it may seem the app is somehow stuck, even the spinning indicator is 
 running. I wanted to change the ActivityIndicator to a progressview, but 
 then I can't make it work because the saving process not on the main 
 thread, i think.. correct me if Im wrong, Im not so much familiar with 
 multithreaded apps.
 
 As for the saving process, what I do is the following.
 
 I have a Parent view which contains subviews, these subviews are drawing 
 images. The user can modify this images, (scale and rotate), so when I save 
 i encode these views so it will save the view's transform,  and then  I 
 archive the data I encoded for all these subviews.
 
 
 your code deleted
 
 You are correct that you cannot call GUI methods from other threads, but 
 NSObject (which all your UI objects inherit from) has the method.
 
 - (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg
 
 So from your other thread, you can update the progress indicator by using it 
 to call a method that updates the progress. 
 
 
 This is even easier if you are targeting iOS 4.0 and higher using Blocks and 
 GrandCentral Dispatch.
 
 Code typed in email (i.e., not tested):
 
  dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 
 0), ^{
   // code you want implemented on another thread goes here:
 
   dispatch_async(dispatch_get_main_queue(), ^{
  // code executed on main thread goes here (i.e., updating the 
 progress indicator in your case
 
   });
   });
 
 HTH,
 Dave
 
 Maybe I'm missing something but aren't the UI actions supposed to happen in 
 the main thread, in this case, he should really call 
 performSelectorOnMainThread:withObject:waitUntilDone:?
 
 -Laurent.


I copied and pasted the wrong method. Yes, the onMainThread version is the one 
to use for this.

The Grand Central Dispatch code is ok though as Conrad pointed out.

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: App Store code signing

2010-11-18 Thread davelist

On Nov 18, 2010, at 6:43 PM, Chris Idou wrote:

 
 
 Is this the right forum to ask about the whole business of verifying 
 signatures 
 etc for apps in the app store for Mac? I've been trying to get the code to 
 work, 
 but I'm stumped.
 


You should probably use http://devforums.apple.com which requires a paid 
developer account. There's a section in it for the Mac App Store to discuss app 
submission, code signing, etc. Discussion of it on this list may even be 
disallowed, but I don't know that for certain.

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: how to deploy the sqlite file in my Cocoa application installation

2010-07-16 Thread davelist

On Jul 16, 2010, at 5:23 AM, Mike Abdullah wrote:

 SQLite is not part of Cocoa, so this is the wrong list. You should either:
 
 1) Find the SQLite docs/list
 2) Use Core Data instead
 
 On 16 Jul 2010, at 02:39, Wayne Shao wrote:
 
 Hi,
 
 I am using sqlite in my cocoa application (for regular mac desktop/laptop).
 
 1. How do I initialize the sqlite (e.g, make sure empty tables with the
 correct schema is put at the right path)
 as part of the application installation?
 2. Any documentation on the install/packaging of my application in general?
 
 Thanks,
 -- 
 W. Shao


I would think the process of shipping a data file with an app is a fair 
question for this list. What I do (and I think is recommended) in my iPhone app 
is to take your default sqlite file (with the tables created) and add it as a 
resource to your project in Xcode. I take this a slight step farther and have 
the sql commands be issued as part of a build script to create the file (that 
way I can easily modify it later if necessary). Then when your app launches, 
you check for the existence of the data file in the location your app would put 
it (such as a folder in the users's ~/Library/Application Support/YourAppName) 
and if it's not there, copy it from your application's resources to that 
directory.

HTH,
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: Memory management on returning nil in init

2010-06-23 Thread davelist

On Jun 21, 2010, at 2:44 PM, Scott Anguish wrote:

 The old style
 
 if (self = [super init])
 
 will cause a warnings with certain settings now and in the future.
 

Does this also apply to code such as:

if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])

should it be:

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)

and any other initializers?

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

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


Re: Strange autoreleased with no pool in place message

2010-04-17 Thread davelist

On Apr 17, 2010, at 3:39 PM, Alexander Bokovikov wrote:

 
 On 18.04.2010, at 1:30, Jens Alfke wrote:
 
 
 On Apr 17, 2010, at 12:18 PM, Alexander Bokovikov wrote:
 
 *** _NSAutoreleaseNoPool(): Object 0x209fa0 of class NSCFString 
 autoreleased with no pool in place - just leaking
 
 Set a breakpoint at _NSAutoreleaseNoPool and start the app. That should show 
 you where it’s happening.
 
 I'm sorry... but how to do it? Where can I find this line? AFAIU, it is out 
 of my source code... Sorry, I'm a newbie...
 
 Most likely you started an NSThread without putting an autorelease pool in 
 the thread’s main function, or you got a callback on some thread and are 
 making Cocoa calls on it without wrapping your callback in an autorelease 
 pool.
 
 Start NSThread even BEFORE main() ? Is it possible?


The first thing you need to do in your method that the thread calls is create 
an auto release pool. Something like:

-(void) createThread {
 NSThread *loadThread = [[NSThread alloc] initWithTarget:self 
selector:@selector(createSpreadSheetReport) object:nil];
[loadThread start];
[loadThread release];
}

- (void) createSpreadSheetReport {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[self.appModel spreadSheetReport];
[self performSelectorOnMainThread:@selector(setSpreadsheetReport) 
withObject:self waitUntilDone:YES];
[pool release];
}

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: Trouble forking my project

2010-03-25 Thread davelist

On Mar 25, 2010, at 11:12 AM, Sean McBride wrote:

 On Wed, 24 Mar 2010 16:48:49 -0700, Dave Carrigan said:
 
 Create a branch for your feature, do all the work on that branch, then
 merge it to the trunk when it's ready. Put your released product in a
 different branch and do your bugfixes on that branch and merge them to
 trunk. Don't work on trunk at all. except to integrate all merges in
 preparation for the next release.
 
 That's all fine and good until you need to change a xib (or worse,
 nib).  xibs are neither diffable nor auto-mergeable.  In my experience,
 they are the single biggest PITA when trying to work with branches.  I
 actually find myself missing Rez-DeRez.
 
 --
 
 Sean McBride, B. Eng s...@rogue-research.com
 Rogue Researchwww.rogue-research.com
 Mac Software Developer  Montréal, Québec, Canada

I thought xib files were diffable - aren't they just XML files - while nib 
files were binary files and not diffable or mergeable.

I admit I get a little worried when trying to merge multiple changes on some 
XML files such as the project.pbxproj if multiple different files have been 
added to the project on different computers. 

Can anyone speak authoritatively on this? Can you reliably merge the various 
XML files that Xcode/IB uses using the tools in version control systems (I'm 
using Mercurial now)?

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

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


Re: SQLite mime type?

2009-12-29 Thread davelist

On Dec 29, 2009, at 11:56 AM, Paul Archibald wrote:

 I am using SQLite in my iPhone app. and i want to be able to email the 
 database file. I see that attaching it to a message is pretty 
 straightforward, but the addAttachmentData method requires a mime type, and I 
  don't know what that should be. Any ideas out there?


I don't know if this is the correct one, but application/octet-stream seems 
to work fine for me in my Attendance app.

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: How to debug over-release of private Cocoa object?

2009-09-16 Thread davelist


On Sep 15, 2009, at 11:17 PM, Graham Cox wrote:

snip

 (Incidentally, I see in Snow Leopard that all such crashes get sent  
to Apple - there is no 'Cancel' button any more on the crash  
reports. Hope they are finding this entertaining - especially as  
it's increasingly looking like their bug ;-)


snip

I ran into this while working on my iPhone app. I finally pressed  
the ? help button on the reporter dialog and it refers you to the  
Console app. Open the Console app, open its preferences window and  
press the Reset button next to Diagnostic reporting.


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: Inducing a crash?

2009-03-09 Thread davelist


On Mar 9, 2009, at 6:05 PM, Rick Mann wrote:

I want to test how well our background agent is restarted. I'd like  
to programmatically induce a crash. What's a good way to do so?


TIA,
--
Rick



I'm not certain if you mean crashing use a Cocoa method, but this  
should certainly cause a memory fault crash.


  int *x;
  x = 0;
  *x = 5;

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


cocoa design for a database application

2009-01-11 Thread davelist


I've developed some small Cocoa programs and now I'm looking to learn  
some of the more advanced topics (bindings, controllers, etc.). I'd  
like to create a Cocoa program that has multiple document types  
corresponding to tables in a database (i.e., I'll be able to open  
separate windows for various rows in various tables). I've worked  
through the NSArrayController example in chapter 8 of the Hillegas book.


So I'm starting out with a simple prototype to try to learn. I didn't  
use an NSDocument application because my application will eventually  
have multiple document types for the separate tables in the database.


What I want to do is have a window that I can click on a button that  
says new person and I want it to open a window (from a separate nib  
file) with text fields for entering a first and last name. I created a  
separate Window nib file (PersonWindow.xib) for this new window. I put  
a NSObjectController (PersonController) in that nib file that I will  
use for the bindings. What do I need to do in the new person button  
action to tell it to create and open the window for this nib file?


Looking through the documentation made me think I needed a  
NSWindowController so I tried this, but I'm fairly certain it's not  
correct.


-(IBAction)newPressed:(id) sender {
NSLog(@newPressed);
Person *person = [[Person alloc] init];
person.firstName = @blank;
PersonController *pc = [[PersonController alloc]  
initWithContent:person];
NSWindowController *wc = [[NSWindowController alloc]  
initWithWindowNibName:@PersonWindow owner:pc];

NSWindow *window = [wc window];
[window display];
}

The window never opens and I see the message:
Cannot create BOOL from object NSTextField: 0x16bba0 of class  
NSTextField


I don't know if this is because I didn't set up the bindings correctly  
or if something else is wrong (I suspect both).


Also, should my Person class just have a NSMutableDictionary (for  
storing the first and last names) or should I declare NSString ivars  
for the first and last names in the person class (as properties so  
they have the settters/getters necessary to work with bindings).


Pointers to relevant documentation are also welcome.

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

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