not debuggable?

2014-06-10 Thread Torsten Curdt
I got this iOS project where I access the calendar - and I am
completely baffled.

[store requestAccessToEntityType:EKEntityTypeEvent
completion:^(BOOL granted, NSError *accessError) {
if (granted) {

NSString *calendarIdentifier = [[NSUserDefaults
standardUserDefaults] valueForKey:kCalendarIdentifier];

EKCalendar *calendar;

NSLog(@calendarIdentifier: %@, calendarIdentifier);

if (calendarIdentifier) {
calendar = [store calendarWithIdentifier:calendarIdentifier];
}

NSLog(@calendar: %@, calendar);


When running on the device I only see

  calendarIdentifier: ...

The next line never shows!

  calendar: ...

I don't see how that is even possible.

So I try the debugger. The debugger should catch all exceptions and I
set a breakpoint to step through. But when I step over
calendarWithIdentifier: it just continues(!) the app and also never
reaches the second log line!

Whaaat!?

Anyone a clue what could be going wrong here? ...or what else to try?


cheers,
Torsten
___

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

Please do not post admin requests or moderator comments to the list.
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: not debuggable?

2014-06-10 Thread Uli Kusterer

On 10 Jun 2014, at 11:47, Torsten Curdt tcu...@vafer.org wrote:

 I got this iOS project where I access the calendar - and I am
 completely baffled.
 
[store requestAccessToEntityType:EKEntityTypeEvent
 completion:^(BOOL granted, NSError *accessError) {
if (granted) {
 
NSString *calendarIdentifier = [[NSUserDefaults
 standardUserDefaults] valueForKey:kCalendarIdentifier];
 
EKCalendar *calendar;
 
NSLog(@calendarIdentifier: %@, calendarIdentifier);
 
if (calendarIdentifier) {
calendar = [store calendarWithIdentifier:calendarIdentifier];
}
 
NSLog(@calendar: %@, calendar);
 
 
 When running on the device I only see
 
  calendarIdentifier: ...
 
 The next line never shows!
 
  calendar: ...
 
 I don't see how that is even possible.
 
 So I try the debugger. The debugger should catch all exceptions and I
 set a breakpoint to step through. But when I step over
 calendarWithIdentifier: it just continues(!) the app and also never
 reaches the second log line!
 
 Whaaat!?
 
 Anyone a clue what could be going wrong here? ...or what else to try?

 You've set a *throw* breakpoint, not a *catch* breakpoint, right? Because in 
this case the block is probably queued somewhere and there's nobody ever 
catching the exception. Have you tried wrapping the block's contents in an 
@try? The exception throw breakpoint *should* catch it, but maybe that helps 
things?

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

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

Please do not post admin requests or moderator comments to the list.
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: Other app blocks mine from opening my documents

2014-06-10 Thread Uli Kusterer
On 10 Jun 2014, at 04:36, Seth Willits sli...@araelium.com wrote:
 My app opens SQL files so I declared a UTI for it in Exported UTIs in the app 
 Info.plist with my own identifier, uses sql as an extension, has a text/plain 
 mime type, and conforms to public.plain-text.
 
 My app opens a new document window, I edit it, it autosaves, and on relaunch 
 Cocoa yells at me:
 
 
 -
 This application can't reopen autosaved 
 com.panic.coda.structured-query-language-file files.
 
 -[NSDocumentController 
 reopenDocumentForURL:withContentsOfURL:display:completionHandler:] failed 
 during state restoration. Here's the error:
 Error Domain=NSCocoaErrorDomain Code=256 The autosaved document “(null)” 
 could not be reopened.  UserInfo=0x608000470540 {NSLocalizedDescription=The 
 autosaved document “(null)” could not be reopened. }
 -
 
 
 I'm a bit puzzled. Guidance? 

 Seems, between Panic and you registering their own UTIs for SQL files, the OS 
gets confused which is the actual type. AFAIK Apple assumes there is only one 
UTI for a type. So when it opens the file, it sees your app can do the 
extension, but when then looking up the UTI to go with that extension, it gives 
you Panic's UTI because it doesn't remember which of the registered UTIs was 
yours. Could that be it? I guess what you could do is try to register for 
Panic's UTI as well (and that of any other app that declares one for SQL 
files), then just internally map them all to your SQL document class?

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

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

Please do not post admin requests or moderator comments to the list.
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: not debuggable?

2014-06-10 Thread Torsten Curdt
Indeed it's a *throw* breakpoint. The queueing is good point.
In the end I was so desperate that I restarted the iPhone - that fixed it.

Scary!

But thanks for your help.

On Tue, Jun 10, 2014 at 2:26 PM, Uli Kusterer
witness.of.teacht...@gmx.net wrote:

 On 10 Jun 2014, at 11:47, Torsten Curdt tcu...@vafer.org wrote:

 I got this iOS project where I access the calendar - and I am
 completely baffled.

[store requestAccessToEntityType:EKEntityTypeEvent
 completion:^(BOOL granted, NSError *accessError) {
if (granted) {

NSString *calendarIdentifier = [[NSUserDefaults
 standardUserDefaults] valueForKey:kCalendarIdentifier];

EKCalendar *calendar;

NSLog(@calendarIdentifier: %@, calendarIdentifier);

if (calendarIdentifier) {
calendar = [store calendarWithIdentifier:calendarIdentifier];
}

NSLog(@calendar: %@, calendar);


 When running on the device I only see

  calendarIdentifier: ...

 The next line never shows!

  calendar: ...

 I don't see how that is even possible.

 So I try the debugger. The debugger should catch all exceptions and I
 set a breakpoint to step through. But when I step over
 calendarWithIdentifier: it just continues(!) the app and also never
 reaches the second log line!

 Whaaat!?

 Anyone a clue what could be going wrong here? ...or what else to try?

  You've set a *throw* breakpoint, not a *catch* breakpoint, right? Because in 
 this case the block is probably queued somewhere and there's nobody ever 
 catching the exception. Have you tried wrapping the block's contents in an 
 @try? The exception throw breakpoint *should* catch it, but maybe that helps 
 things?

 Cheers,
 -- Uli Kusterer
 The Witnesses of TeachText are everywhere...
 http://www.zathras.de


___

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

Please do not post admin requests or moderator comments to the list.
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

Set contents of CALayer to animated GIF?

2014-06-10 Thread Charles Carver
Is it possible to set the contents of a CALayer to an animated GIF and have it 
display that animation? I know that I can set the contents to an image like so:

CALayer* subLayer = [CALayer layer];
NSImage *image = [[NSImage alloc] initWithData:data];
subLayer.contents = image;

And the image will show, but if it's animated, the animation will not display. 
Is the only solution to get the individual frames for the GIF, get the frame 
rate, then change the content of the sublayer according to the frame rate? Or 
is there a much simpler method that I'm overlooking?

Another idea I had was to have a blank NSImageView, then display it/fill it 
with the GIF data if the active sublayer included an animated GIF. This kind of 
worked, except only if the top-most NSView wasn’t using core animation. If it 
was using core animation, the GIF would only play if the window was = the size 
of the GIF. If it was smaller, the GIF would simply stop playing (I even 
reproduced this in its own test project, same behavior). But then turning off 
core animation on the top view and having it enabled on the lower ones caused a 
series of unideal behavior (lag, glitches, flickering), as I don’t think a view 
hierarchy is supposed to be setup like that.

Also, my reason for using core animation in the first place is because I'm 
loading a fair number of images at once and then individually showing one at a 
time. I started with just using an NSImageView, but the performance was awful 
compared to core animation. 

Anyways, any other ideas?
___

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

Please do not post admin requests or moderator comments to the list.
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: IKImageBrowserCell

2014-06-10 Thread SevenBits
On Tuesday, June 10, 2014, Daniel Santos daniel.d...@gmail.com wrote:

 Absolutely. What do you have in mind ?

 On Monday, June 9, 2014, SevenBits sevenbitst...@gmail.com
 javascript:_e(%7B%7D,'cvml','sevenbitst...@gmail.com'); wrote:

 On Monday, June 9, 2014, Daniel Luis dos Santos daniel.d...@gmail.com
 wrote:

 Hello all,

 I have a IKImageBrowserView that I want to customise. I want to add a
 button to each IKImageBrowser|Cell that when pushed does some action.

 How can I do that ?


 Is using NSCollectionView an option?


They can be arranged in a grid or other layout like a table view but are
more flexible than a table or IKImageView.





 Thanks


 ___

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

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

 Help/Unsubscribe/Update your Subscription:

 https://lists.apple.com/mailman/options/cocoa-dev/sevenbitstech%40gmail.com

 This email sent to sevenbitst...@gmail.com


___

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

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

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

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

Re: IKImageBrowserCell

2014-06-10 Thread SevenBits
From: *SevenBits* sevenbitst...@gmail.com
Date: Tuesday, June 10, 2014
Subject: IKImageBrowserCell
To: Daniel Santos daniel.d...@gmail.com


On Tuesday, June 10, 2014, Daniel Santos daniel.d...@gmail.com
javascript:_e(%7B%7D,'cvml','daniel.d...@gmail.com'); wrote:

 Absolutely. What do you have in mind ?


Look in the documentation. Specifically, NSCollectionView allows you to do
exactly what you describe; define a view, with a number of sub views, with
one being the image and another your button, and set them up as collection
view objects. I have done this and it works well.

-- SevenBits



 On Monday, June 9, 2014, SevenBits sevenbitst...@gmail.com wrote:

 On Monday, June 9, 2014, Daniel Luis dos Santos daniel.d...@gmail.com
 wrote:

 Hello all,

 I have a IKImageBrowserView that I want to customise. I want to add a
 button to each IKImageBrowser|Cell that when pushed does some action.

 How can I do that ?


 Is using NSCollectionView an option?



 Thanks


 ___

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

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

 Help/Unsubscribe/Update your Subscription:

 https://lists.apple.com/mailman/options/cocoa-dev/sevenbitstech%40gmail.com

 This email sent to sevenbitst...@gmail.com


___

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

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

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

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

Re: Best practices with singletons

2014-06-10 Thread Dave
Hi,

You should take a look at this article:

http://c2.com/cgi/wiki?SingletonsAreEvil

Cheers
Dave

On 8 Jun 2014, at 17:30, William Squires wsqui...@satx.rr.com wrote:

  Okay, I have several classes in my (somewhat large, and growing) project 
 that implement the singleton pattern via a [classname sharedwhatever] 
 class method (and a file-scope static reference) that uses lazy loading to 
 instantiate the singleton the first time a reference is asked for. Is it 
 considered better to put all of these calls in the main() function before any 
 other code executes, or not worry about it, and just access them through the 
 above class methods when and where needed?
  Also, in C, it's common to throw away the return value from a function (a la 
 printf(), which returns an int, but coders rarely use the return value), but 
 is it good practice to throw away the result of the above method calls 
 (messages) just to silence the compiler?
 
 i.e.
 
 -(void)someMethod
 {
 ...
 [MyClass sharedController]; // No warning here.
 ...
 }
 
 as opposed to:
 
 -(void)someMethod
 {
 MyClass *p = [MyClass sharedController]; // - Yellow triangle here for 
 unused variable 'p'
 ...
 }
 
 TIA! :)
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/dave%40looktowindward.com
 
 This email sent to d...@looktowindward.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: Other app blocks mine from opening my documents

2014-06-10 Thread Seth Willits
On Jun 10, 2014, at 5:29 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:

 Seems, between Panic and you registering their own UTIs for SQL files, the OS 
 gets confused which is the actual type. AFAIK Apple assumes there is only one 
 UTI for a type. So when it opens the file, it sees your app can do the 
 extension, but when then looking up the UTI to go with that extension, it 
 gives you Panic's UTI because it doesn't remember which of the registered 
 UTIs was yours. Could that be it?

That's certainly what it seems like.


 I guess what you could do is try to register for Panic's UTI as well (and 
 that of any other app that declares one for SQL files), then just internally 
 map them all to your SQL document class?

The problem with that is there's probably 50 apps that could define this UTI as 
well. Not only I would I have to import all of their UTIs, they'd have to 
import mine and everyone else's too. Otherwise there's always the chance that 
any one of our apps would be rendered useless by simply having any of the other 
apps on the system too.


If that's really how it works, then UTIs are really seriously stupidly broken 
in this kind of case, and I just can't believe that's true.


The only real option I see is to not use UTIs at all.


--
Seth Willits




___

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

Please do not post admin requests or moderator comments to the list.
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: Set contents of CALayer to animated GIF?

2014-06-10 Thread David Duncan

On Jun 10, 2014, at 8:05 AM, Charles Carver charlescar...@mac.com wrote:

 Is it possible to set the contents of a CALayer to an animated GIF and have 
 it display that animation?

No.

 I know that I can set the contents to an image like so:
 
 CALayer* subLayer = [CALayer layer];
 NSImage *image = [[NSImage alloc] initWithData:data];
 subLayer.contents = image;
 
 And the image will show, but if it's animated, the animation will not 
 display. Is the only solution to get the individual frames for the GIF, get 
 the frame rate, then change the content of the sublayer according to the 
 frame rate?

Using strictly CALayers, pretty much.

 Or is there a much simpler method that I'm overlooking?
 
 Another idea I had was to have a blank NSImageView, then display it/fill it 
 with the GIF data if the active sublayer included an animated GIF. This kind 
 of worked, except only if the top-most NSView wasn’t using core animation. If 
 it was using core animation, the GIF would only play if the window was = the 
 size of the GIF. If it was smaller, the GIF would simply stop playing (I even 
 reproduced this in its own test project, same behavior). But then turning off 
 core animation on the top view and having it enabled on the lower ones caused 
 a series of unideal behavior (lag, glitches, flickering), as I don’t think a 
 view hierarchy is supposed to be setup like that.
 
 Also, my reason for using core animation in the first place is because I'm 
 loading a fair number of images at once and then individually showing one at 
 a time. I started with just using an NSImageView, but the performance was 
 awful compared to core animation. 
 
 Anyways, any other ideas?
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 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

--
David Duncan


___

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

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

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

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

Another app's UTI can break your app

2014-06-10 Thread Seth Willits

TLDR:
---
If your app has a document type that may use the same extension as another app, 
you should override typeForContentsOfURL:error: because otherwise the existence 
of that other application on a user's system can break your app. 




Problem summary:
---
My app and Coda both open plain text .sql files. Coda exports a UTI for the 
.sql extension. So does my app. However (because Coda was registered with 
Launch Services first), my app will be prevented from opening ANY .sql file 
because the system and Cocoa think it's a 
com.panic.coda.structured-query-language-file file, and my app can't open files 
with that UTI.

The same would happen even if my app does not use a UTI but simply declares 
that it opens documents with an .sql extension.

This is a critical problem.




Investigatory work:
---

- [NSDocumentController typeForContentsOfURL:error:] is the first method being 
called to determine what class will open a file. The header file (but not the 
documentation) has some useful information:


The default implementation of this method merely returns the URL's 
NSURLTypeIdentifierKey resource value.
You can override this to customize type determination for documents 
being opened.


What this says, is that Cocoa doesn't look at my Info.plist file to see what 
type *my application* would describe the file at the URL as. Instead, it by 
default asks the file system what's the UTI for this URL and Launch Services 
(because Coda registered its sql UTI long before my app) says: It's a Coda 
file.

Cocoa *then* looks in my Info.plist file (essentially), and sees no 
conformity/usage of com.panic.coda.structured-query-language-file so it throws 
a fit, preventing my app from opening .sql files.  

That's very unfortunate and frankly ridiculous because this means that the 
existence of another application on your system can break your app. 

The solution however is easy.




Solution
---

By overriding typeForContentsOfURL:error: as the header suggests, we can cure 
the problem.


- (NSString *)typeForContentsOfURL:(NSURL *)url error:(NSError **)outError;
{
if ([url.pathExtension.lowercaseString isEqual:@sql]) {
return @my.uti.type;
}

return [super typeForContentsOfURL:url error:outError];
}



It's also important to note that if your document type declares a UTI, you need 
to return that UTI from typeForContentsOfURL:error: even though the docs say it 
returns name of the document type (AKA the CFBundleTypeName). If you return 
the type name and not the UTI then the document architecture will get confused 
later and things will fail. However, if you don't declare a UTI type for the 
document, then return the CFBundleTypeName. 




Conclusion
---

That's several hours of investigatory work. I went down many rabbit holes 
during that, but I'm pretty sure that I understand this and have boiled it down 
to the root cause and truth. If I'm wrong, please correct me. (I'd like to be 
wrong!)




--
Seth Willits


___

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

Please do not post admin requests or moderator comments to the list.
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: Another app's UTI can break your app

2014-06-10 Thread Sean McBride
On Tue, 10 Jun 2014 12:21:13 -0700, Seth Willits said:

TLDR:
---
If your app has a document type that may use the same extension as
another app, you should override typeForContentsOfURL:error: because
otherwise the existence of that other application on a user's system can
break your app. 

This is a critical problem.

This is well known, and has been discussed on this list years ago.

I filed a bug back in 2007:

rdar://5540833
9a559: Denial of service; Launch Services changes UTI when new app arrives

That's very unfortunate and frankly ridiculous because this means that
the existence of another application on your system can break your app. 

Yes, a malicious app could probably claim all sorts of UTIs, stopping other 
apps from opening documents.  Then again, a malicious app could also delete a 
bunch of files, so...

I've given up on it ever being fixed (like most everything in Radar).  But hey, 
we're getting new cool translucent stuff! :)

Cheers,

-- 

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



___

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

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

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

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

Re: Another app's UTI can break your app

2014-06-10 Thread Seth Willits
On Jun 10, 2014, at 12:33 PM, Sean McBride s...@rogue-research.com wrote:

 This is a critical problem.
 
 This is well known, and has been discussed on this list years ago.

Sigh. Wish I had been able to find anything on this topic when I searched. At 
least I'm not crazy.




 Yes, a malicious app could probably claim all sorts of UTIs, stopping other 
 apps from opening documents.  Then again, a malicious app could also delete a 
 bunch of files, so...

It's not even about malicious intent. Coda obviously has no malicious intent, 
but it breaks my app. I'd break Coda if it my app was installed before it. 
That's just inconceivable to me.




 I filed a bug back in 2007:
 
 rdar://5540833
 9a559: Denial of service; Launch Services changes UTI when new app arrives
 
 I've given up on it ever being fixed (like most everything in Radar).  But 
 hey, we're getting new cool translucent stuff! :)

A 7 year-old ticket is extremely disappointing. I will file another.




--
Seth Willits




___

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

Please do not post admin requests or moderator comments to the list.
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: Another app's UTI can break your app

2014-06-10 Thread Vincent

 It's not even about malicious intent. Coda obviously has no malicious intent, 
 but it breaks my app. I'd break Coda if it my app was installed before it. 
 That's just inconceivable to me.

I’m not sure associating well known extensions types as .SQL is a good idea in 
the first place. I have some .SQL files, namely the PostGIS geospatial 
extension to PostgreSQL, that have nothing to do with any MacOS app, and that I 
don’t want to open with Coda, but rather TextWrangler, for example.

These “famous” extensions should maybe be excluded from any type of association.

Vincent


___

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

Please do not post admin requests or moderator comments to the list.
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: Another app's UTI can break your app

2014-06-10 Thread Sean McBride
On Tue, 10 Jun 2014 12:54:06 -0700, Seth Willits said:

It's not even about malicious intent. Coda obviously has no malicious
intent, but it breaks my app. I'd break Coda if it my app was installed
before it. That's just inconceivable to me.

The root problem is with file formats that are not your own.  You don't 
control/own the .sql format and neither does Coda, so who gets to choose the 
UTI?

The OS does keep a list of UTIs for common formats: 

/System/Library/CoreServices/CoreTypes.bundle/Contents/Info.plist

You should file a bug to get .sql added there.  I've previously got 'industry 
standard' formats added to the OS (ex: org.nema.dicom) via Radars.

At least you and Coda are talking about the same format.  Worse, is when two 
totally different formats happen to use the same extension, like .img, that 
sucks even worse.

Cheers,

-- 

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



___

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

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

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

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

Problem in notification

2014-06-10 Thread Tom Doan
I have a user of one of my software programs who has been having all kinds of
problems which I can't seem to reproduce, and have no idea how to even debug 
them.
I include below a traceback that he sent me. This is something that occurs 
almost right
away: launch the program, do File-New, and it is in the process of running a 
modal
dialog which includes an NSScrollView. I have an observer on 
viewContentFrameDidChange
and it's while processing that that it fails. 

So far as I can tell, it shouldn't be where it is. If I run it and set a 
breakpoint on the observer, 
it gets called in a completely different situation---the one that I intended. I 
have no idea what
it's trying to do here. (What's an NSScrollerImp?) and no idea how to trap it 
to figure out 
what the problem is. Any help anyone can offer would be appreciated.

Tom Doan
Estima 




Process: WinTDOSX [359] 
Path: /Applications/WinTD 4.20/WinTDOSX.app/Contents/MacOS/WinTDOSX 
Identifier: com.estima.WinTD 
Version: 4.20 (4.20) 
Code Type: X86-64 (Native) 
Parent Process: launchd [154] 
Responsible: WinTDOSX [359] 
User ID: 501 
Date/Time: 2014-06-10 15:34:56.670 -0400 
OS Version: Mac OS X 10.9.2 (13C1021) 
Report Version: 11 
Anonymous UUID: 15F9A42A-3E8C-7B04-D878-7429EA0F52CF 
Crashed Thread: 0 Dispatch queue: com.apple.main-thread 
Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x 
VM Regions Near 0: 
-- 
__TEXT 0001-0001002d3000 [ 2892K] r-x/rwx SM=COW 
/Applications/WinTD 
4.20/WinTDOSX.app/Contents/MacOS/WinTDOSX 
Application Specific Information: 
Performing @selector(respond:) from sender NSMenuItem 0x618af7e0 
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 
0 com.estima.WinTD 0x0001000feadb -[ENSScrollView 
viewContentFrameDidChange:] + 76 
1 com.apple.CoreFoundation 0x7fff8cd2fe0c 
__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 
12 
2 com.apple.CoreFoundation 0x7fff8cc238dd _CFXNotificationPost + 2893 
3 com.apple.AppKit 0x7fff874d8193 -[NSView _postFrameChangeNotification] + 
434 
4 com.apple.AppKit 0x7fff874e1852 -[NSView setFrameSize:] + 1586 
5 com.apple.AppKit 0x7fff8750a212 -[NSClipView setFrameSize:] + 380 
6 com.apple.AppKit 0x7fff874e11d9 -[NSView setFrame:] + 294 
7 com.apple.AppKit 0x7fff8750d178 -[NSScrollView _setContentViewFrame:] + 
669 
8 com.apple.AppKit 0x7fff8750cacd -[NSScrollView _applyContentAreaLayout:] 
+ 131 
9 com.apple.AppKit 0x7fff8750b0a4 -[NSScrollView tile] + 1943 
10 com.apple.AppKit 0x7fff87dc0f3e +[NSScrollerImpPair 
_updateAllScrollerImpPairsForNewRecommendedScrollerStyle:] 
+ 401 
11 com.apple.CoreFoundation 0x7fff8cd2fe0c 
__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ 
+ 12 
12 com.apple.CoreFoundation 0x7fff8cc238dd _CFXNotificationPost + 2893 
13 com.apple.Foundation 0x7fff944d97ba -[NSNotificationCenter 
postNotificationName:object:userInfo:] + 68 
14 libdispatch.dylib 0x7fff917cc1d7 _dispatch_call_block_and_release + 12 
15 libdispatch.dylib 0x7fff917c92ad _dispatch_client_callout + 8 
16 libdispatch.dylib 0x7fff917d0f03 _dispatch_main_queue_callback_4CF + 333 
17 com.apple.CoreFoundation 0x7fff8ccc85a9 
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 
18 com.apple.CoreFoundation 0x7fff8cc837c4 __CFRunLoopRun + 1636 
19 com.apple.CoreFoundation 0x7fff8cc82f25 CFRunLoopRunSpecific + 309 
20 com.apple.HIToolbox 0x7fff8d025a0d RunCurrentEventLoopInMode + 226 
21 com.apple.HIToolbox 0x7fff8d0257b7 ReceiveNextEventCommon + 479 
22 com.apple.HIToolbox 0x7fff8d0255bc 
_BlockUntilNextEventMatchingListInModeWithFilter + 65 
23 com.apple.AppKit 0x7fff874aa3de _DPSNextEvent + 1434 
24 com.apple.AppKit 0x7fff874a9a2b -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] + 122 
25 com.apple.AppKit 0x7fff87808e2e -[NSApplication _realDoModalLoop:peek:] 
+ 642 
26 com.apple.AppKit 0x7fff8780754e -[NSApplication runModalForWindow:] + 
117 
27 com.estima.WinTD 0x0001000f6758 EDialog::Process() + 88 
28 com.estima.WinTD 0x00010007c7e0 Tournament::DoNew() + 80 
29 com.estima.WinTD 0x00010007676d PairingsAppl::DoMenuCommand(long) + 235 
30 com.estima.WinTD 0x0001001692b9 -[MenuHandler respond:] + 87 
31 com.apple.AppKit 0x7fff876c8340 -[NSApplication sendAction:to:from:] + 
327 
32 com.apple.AppKit 0x7fff876e32a8 -[NSMenuItem _corePerformAction] + 394 
33 com.apple.AppKit 0x7fff876e2fe4 -[NSCarbonMenuImpl 
performActionWithHighlightingForItemAtIndex:] + 117 
34 com.apple.AppKit 0x7fff8773248d -[NSMenu 
_internalPerformActionForItemAtIndex:] + 35 
35 com.apple.AppKit 0x7fff87732309 -[NSCarbonMenuImpl 
_carbonCommandProcessEvent:handlerCallRef:] + 104 
36 com.apple.AppKit 0x7fff876d90d6 NSSLMMenuEventHandler + 716 
37 com.apple.HIToolbox 0x7fff8cfff1d4 
DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) 
+ 892 
38 

Re: Problem in notification

2014-06-10 Thread John Pannell
Hi Tom-

What does the implementation of this method look like?

[ENSScrollView viewContentFrameDidChange:] 

This error:

Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x

... makes me think that something is nil that is not supposed to be, according 
to your code.  Since you can't reproduce it, you could trawl through the method 
and see if any calls would not tolerate an unexpected nil.  Total guesswork on 
my part, but is anything in the modal window's view hierarchy coming out of a 
nib, and potentially not wired up yet (i.e. crash before awakeFromNib called)?

It does look like the stack trace makes it through Apple's code and back to 
yours...

John 

On Jun 10, 2014, at 4:42 PM, Tom Doan t...@estima.com wrote:

 I have a user of one of my software programs who has been having all kinds of
 problems which I can't seem to reproduce, and have no idea how to even debug 
 them.
 I include below a traceback that he sent me. This is something that occurs 
 almost right
 away: launch the program, do File-New, and it is in the process of running a 
 modal
 dialog which includes an NSScrollView. I have an observer on 
 viewContentFrameDidChange
 and it's while processing that that it fails. 
 
 So far as I can tell, it shouldn't be where it is. If I run it and set a 
 breakpoint on the observer, 
 it gets called in a completely different situation---the one that I intended. 
 I have no idea what
 it's trying to do here. (What's an NSScrollerImp?) and no idea how to trap it 
 to figure out 
 what the problem is. Any help anyone can offer would be appreciated.
 
 Tom Doan
 Estima 
 
 
 
 
 Process: WinTDOSX [359] 
 Path: /Applications/WinTD 4.20/WinTDOSX.app/Contents/MacOS/WinTDOSX 
 Identifier: com.estima.WinTD 
 Version: 4.20 (4.20) 
 Code Type: X86-64 (Native) 
 Parent Process: launchd [154] 
 Responsible: WinTDOSX [359] 
 User ID: 501 
 Date/Time: 2014-06-10 15:34:56.670 -0400 
 OS Version: Mac OS X 10.9.2 (13C1021) 
 Report Version: 11 
 Anonymous UUID: 15F9A42A-3E8C-7B04-D878-7429EA0F52CF 
 Crashed Thread: 0 Dispatch queue: com.apple.main-thread 
 Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
 Exception Codes: KERN_INVALID_ADDRESS at 0x 
 VM Regions Near 0: 
 -- 
 __TEXT 0001-0001002d3000 [ 2892K] r-x/rwx SM=COW 
 /Applications/WinTD 
 4.20/WinTDOSX.app/Contents/MacOS/WinTDOSX 
 Application Specific Information: 
 Performing @selector(respond:) from sender NSMenuItem 0x618af7e0 
 Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 
 0 com.estima.WinTD 0x0001000feadb -[ENSScrollView 
 viewContentFrameDidChange:] + 76 
 1 com.apple.CoreFoundation 0x7fff8cd2fe0c 
 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 
 12 
 2 com.apple.CoreFoundation 0x7fff8cc238dd _CFXNotificationPost + 2893 
 3 com.apple.AppKit 0x7fff874d8193 -[NSView _postFrameChangeNotification] 
 + 434 
 4 com.apple.AppKit 0x7fff874e1852 -[NSView setFrameSize:] + 1586 
 5 com.apple.AppKit 0x7fff8750a212 -[NSClipView setFrameSize:] + 380 
 6 com.apple.AppKit 0x7fff874e11d9 -[NSView setFrame:] + 294 
 7 com.apple.AppKit 0x7fff8750d178 -[NSScrollView _setContentViewFrame:] + 
 669 
 8 com.apple.AppKit 0x7fff8750cacd -[NSScrollView 
 _applyContentAreaLayout:] + 131 
 9 com.apple.AppKit 0x7fff8750b0a4 -[NSScrollView tile] + 1943 
 10 com.apple.AppKit 0x7fff87dc0f3e +[NSScrollerImpPair 
 _updateAllScrollerImpPairsForNewRecommendedScrollerStyle:] 
 + 401 
 11 com.apple.CoreFoundation 0x7fff8cd2fe0c 
 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ 
 + 12 
 12 com.apple.CoreFoundation 0x7fff8cc238dd _CFXNotificationPost + 2893 
 13 com.apple.Foundation 0x7fff944d97ba -[NSNotificationCenter 
 postNotificationName:object:userInfo:] + 68 
 14 libdispatch.dylib 0x7fff917cc1d7 _dispatch_call_block_and_release + 12 
 15 libdispatch.dylib 0x7fff917c92ad _dispatch_client_callout + 8 
 16 libdispatch.dylib 0x7fff917d0f03 _dispatch_main_queue_callback_4CF + 
 333 
 17 com.apple.CoreFoundation 0x7fff8ccc85a9 
 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 
 18 com.apple.CoreFoundation 0x7fff8cc837c4 __CFRunLoopRun + 1636 
 19 com.apple.CoreFoundation 0x7fff8cc82f25 CFRunLoopRunSpecific + 309 
 20 com.apple.HIToolbox 0x7fff8d025a0d RunCurrentEventLoopInMode + 226 
 21 com.apple.HIToolbox 0x7fff8d0257b7 ReceiveNextEventCommon + 479 
 22 com.apple.HIToolbox 0x7fff8d0255bc 
 _BlockUntilNextEventMatchingListInModeWithFilter + 65 
 23 com.apple.AppKit 0x7fff874aa3de _DPSNextEvent + 1434 
 24 com.apple.AppKit 0x7fff874a9a2b -[NSApplication 
 nextEventMatchingMask:untilDate:inMode:dequeue:] + 122 
 25 com.apple.AppKit 0x7fff87808e2e -[NSApplication 
 _realDoModalLoop:peek:] + 642 
 26 com.apple.AppKit 0x7fff8780754e -[NSApplication runModalForWindow:] + 
 117 
 27 com.estima.WinTD 0x0001000f6758 EDialog::Process() + 88 
 28 com.estima.WinTD 

CMMotionManager valid data?

2014-06-10 Thread Todd Heberlein
I’ve just started playing with CMMotionManager on my iPhone in an OpenGL 
program. I allocate CMMotionaManger and startDeviceMotionUpdates  in 
-viewDidLoad. In -update I check if deviceMotionActive and print the roll value.

motionManager.deviceMotion.attitude.roll

For the first few times it is 0.0, but after a while a new value kicks in that 
seems right (e.g., 90-ish degrees or 50* or something that reflects how I am 
holding my phone.

(1) Does CMMotionManager need a little bit of time before deviceMotion.attitude 
values are valid?

(2) Is there a proper way to determine when deviceMotion.attitude has valid 
values?

Thanks,

Todd



signature.asc
Description: Message signed with OpenPGP using GPGMail
___

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

Please do not post admin requests or moderator comments to the list.
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: CMMotionManager valid data?

2014-06-10 Thread Graham Cox
Not sure if it's relevant but I've noticed that since iOS 7, motion-sensitive 
apps ask for a calibration almost every time, where the phone has to be rolled 
around until a circle completes. It never used to do that, or only in very 
specific cases, or when the user clicked a calibration button. That change 
suggests that perhaps the sensor needs calibrating a lot more often that was 
previously thought, and maybe your app needs to do the same before it gets 
reliable values.

--Graham


On 11 Jun 2014, at 10:11 am, Todd Heberlein todd_heberl...@mac.com wrote:

 I’ve just started playing with CMMotionManager on my iPhone in an OpenGL 
 program. I allocate CMMotionaManger and startDeviceMotionUpdates  in 
 -viewDidLoad. In -update I check if deviceMotionActive and print the roll 
 value.
 
   motionManager.deviceMotion.attitude.roll
 
 For the first few times it is 0.0, but after a while a new value kicks in 
 that seems right (e.g., 90-ish degrees or 50* or something that reflects how 
 I am holding my phone.
 
 (1) Does CMMotionManager need a little bit of time before 
 deviceMotion.attitude values are valid?
 
 (2) Is there a proper way to determine when deviceMotion.attitude has valid 
 values?
 
 Thanks,
 
 Todd


___

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

Please do not post admin requests or moderator comments to the list.
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: Another app's UTI can break your app

2014-06-10 Thread Uli Kusterer
On 10 Jun 2014, at 21:21, Seth Willits sli...@araelium.com wrote:
 - (NSString *)typeForContentsOfURL:(NSURL *)url error:(NSError **)outError;
 {
   if ([url.pathExtension.lowercaseString isEqual:@sql]) {
   return @my.uti.type;
   }
   
   return [super typeForContentsOfURL:url error:outError];
 }

 I suppose that this works should be mentioned in your bug. It means Apple 
could easily fix it by making the default implementation take a first stab at 
looking up the UTI from your Info.plist instead of from Launch Services.

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


___

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

Please do not post admin requests or moderator comments to the list.
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

document inexplicably becomes locked and fails to save under sandboxing

2014-06-10 Thread Martin Wierschin
Hello everyone,

I'm sandboxing an NSDocument based application for OS X. In addition to Apple's 
standard Open Recent menu, this app also provides the user a few ways to reopen 
commonly used documents. To make that work under sandboxing, I capture a 
security-scoped bookmark for each such document. Then later, when the users 
wants to reopen the file, I resolve that bookmark data back to a URL. The code 
is something like:

NSData* bookmark = XXLoadDocumentBookmarkData();
NSURLBookmarkResolutionOptions ops = 
NSURLBookmarkResolutionWithSecurityScope;
NSURL* url = [NSURL URLByResolvingBookmarkData:bookmark options:ops 
relativeToURL:nil bookmarkDataIsStale:NULL error:NULL];

[url startAccessingSecurityScopedResource];
NSDocument* doc = [[NSDocumentController sharedDocumentController] 
openDocumentWithContentsOfURL:url display:YES error:NULL];
[url stopAccessingSecurityScopedResource];

Anyways, that code works just fine: the document is reopened with proper 
read/write access.

The problem is that after some period of time, the reopened documents become 
locked and saving fails. Both autosave and manual save operations fail with the 
error: you don’t own the file and don't have permission to write to it. In 
the document's titlebar the suffix — Locked is shown, and Cocoa prevents me 
from unlocking the document using the popup options. The issue never occurs 
immediately, only after some successful saves and perhaps a few minutes have 
passed. I have discerned no pattern to when or what triggers the locking.

Does anyone have any idea what's going wrong? Why is sandbox access for these 
documents being cut off while they remain open?

I can somewhat workaround the problem by overriding -[NSDocument 
performSynchronousFileAccessUsingBlock:], wrapping super's implementation with 
-[NSURL startAccessingSecurityScopedResource] for the relevant URL. However, 
that feels like a hack and makes me very nervous that other things could be 
broken. Also, while that restores successful saving, it doesn't prevent — 
Locked from appearing in the document's titlebar.

Thank you for any ideas or help!

Best,
Martin Wierschin


___

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

Please do not post admin requests or moderator comments to the list.
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