Re: Triggering a segue from code

2016-09-22 Thread Shane Stanley
On 23 Sep. 2016, at 1:17 pm, Kyle Sluder  wrote:
> 
> -close used to render windows more thoroughly dead

So can we assume that the close button generally calls -close?

On a tangent here...

In Safari, it used to be that if a script asked for the app's windows, 
-orderedWindows would return a list of open windows. Under Sierra, however, the 
list returned can include windows that have been closed via the close box -- 
you might have closed them half-an-hour ago. They show with a visible property 
of false, but by setting it to true they reappear -- no Web contents, but the 
URL, title, etc all intact. And the only way to close them is again via script 
-- their close buttons do nothing.

It's probably just a bug, although DTS don't seem to think so, but these 
windows seem surprisingly resistant to death.

-- 
Shane Stanley 
, 



___

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

Please do not post admin requests or moderator comments to the list.
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: Triggering a segue from code

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 20:17 , Kyle Sluder  wrote:
> 
> And as Eric has discovered, it instructs the
> Storyboard runtime to create a new instance of the window controller
> rather than unhiding the existing one.

Thanks for clarifying this all. I think the upshot of it is that closing a 
window has a number of side effects (that are unsurprising), but there’s also a 
private “is closed” state that controls its future behavior, but is not 
accessible by developers.

The follow-on question (Life of Brian notwithstanding) is then what state 
transitions the window can have after it’s closed. Can it be shown? How does it 
relate to the window controller or document later?

___

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

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

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

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

Re: Triggering a segue from code

2016-09-22 Thread Kyle Sluder
On Thu, Sep 22, 2016, at 02:47 PM, Quincey Morris wrote:
> On Sep 22, 2016, at 12:34 , Kyle Sluder  wrote:
> > 
> > -close asks the window’s delegate (via -windowShouldClose:) if it should
> > close. If the window is owned by a window controller that’s associated
> > with a document, the document will also get a chance to weigh in via
> > -shouldCloseWindowController:…. It will also send
> > NSWindowWillCloseNotification.
> > 
> > -orderOut: just hides the window (removes it from the window list). You
> > can always order it back in again later.
> 
> Yes, but ignore for a moment the “shouldClose…” interaction, and assume
> the window is NOT set to release on close. What *else* does “close” do
> vs. “orderOut”?

This question sounds vaguely similar to “What have the Romans done for
us?” from Life of Brian. ;-)

> 
> The example app mentioned in this thread demonstrates that “close” has
> some other effect beyond what “orderOut” does. In particular, a
> “single”-mode storyboard segue re-uses an ordered-out window, but not a
> closed one.

I must first admit, especially for the benefit of anyone who read the
documentation after I replied to you, that I was mistaken.
-shouldCloseWindowController: and -windowShouldClose: are only sent from
-performClose:, not from -close. Which makes sense: -close is the
unconditional way for an app (that might have even implemented its own
confirmation flow) to close a window.

Having made my apologies, -orderOut: and -close live at two levels of
abstraction. -orderOut deals with the window’s order and membership in
the window list. -close deals with higher-level semantics like window
controllers, documents, and notifications. As part of these higher-level
semantics, -close calls -orderOut:. For document-based apps, it also
dissociates the window from the document (and the window controller the
document made for it). And as Eric has discovered, it instructs the
Storyboard runtime to create a new instance of the window controller
rather than unhiding the existing one.

(-close used to render windows more thoroughly dead in the era of
releaseWhenClosed and one-shot backing stores. But those days are in the
past.)

--Kyle Sluder

___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Shane Stanley
On 22 Sep. 2016, at 10:20 pm, Dave  wrote:
> 
> myNetworkleScriptSourceString = [[NSString alloc] 
> initWithContentsOfFile:myNetworkleScriptFilePath 
> encoding:NSUTF8StringEncoding error:];
> if (myErrorInfo != nil)

You should be testing for !myNetworkleScriptSourceString; you shouldn't touch 
myErrorInfo unless myNetworkleScriptSourceString is nil.

> [myNetworkleScript executeAndReturnError:];
> if (myErrorDictionary != nil)

Check the result of executeAndReturnError: first.

> So I’m wondering if it is something to do with the AppleScript handling?

What happens if you just comment out the execution line? (My guess is it will 
make no difference.)

-- 
Shane Stanley 
, 



___

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

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

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 16:52 , Charles Srstka  wrote:
> 
> Actually nope, it showed up in 10.3, making it younger than the 
> target/selector approach.

In that case, I have no plausible rationale why this was done differently. It’s 
possible there was a performance-related reason. It’s possible it was a design 
preference on the part of the engineer who introduced the capability. It’s 
possible it has to do with the ease of overriding the behavior in subclasses. 
(It’s sometimes awkward to customize the “didEnd”-style behavior.)

___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Shane Stanley
On 23 Sep. 2016, at 1:42 am, Jens Alfke  wrote:
> 
> AFAIK, AppleScripts can only be run on the main thread. But it’s been many OS 
> releases since I worked with them.

FYI, that hasn't been the case for quite some time.

-- 
Shane Stanley 
, 



___

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

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

2016-09-22 Thread Doug Hill

> On Sep 22, 2016, at 4:19 PM, Sandor Szatmari  
> wrote:
> 
> So there was lots of discussion and plenty of 'don't do anything that equates 
> to this' --> @"myString" == @"myString", and I agree.  
> 
> I wanted to get some opinions on the following which I have done in the past 
> and perceive as different because the string constant is introduced and 
> defined once and only once.
> 
> // my .m file
> static NSString * const kMyContext = @"my fantastic context";
> 
> // later on
> - (void) observeValueForKeyPath: (NSString *) keyPath   ofObject: (id) object
>   change: (NSDictionary *) change context: (void *) 
> context
> {
>  if ( context == kMyContext )
>  { // do my stuff }
>  else
>  // call super
> }
> 
> My interpretation of how to use context has been as an arbitrary pointer...  
> Does this run afoul of anyone's sensibility?
> 
> Sandor Szatmari

This appears to follow Apple recommended practice. I think after all the 
discussion on this thread, pretty much the only thing you should do is compare 
the context to a static pointer. And a static string maybe makes it easier to 
identify a particular context. I’m actually changing some old code right now to 
use these recommendations.

Good luck!

Doug Hill


___

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

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

2016-09-22 Thread Charles Srstka
> On Sep 22, 2016, at 6:07 PM, Quincey Morris 
>  wrote:
> 
> But that’s because the KVO notification mechanism is a more ancient design 
> concept, where it likely seemed simple, adequate and flexible. I assume it 
> comes from NeXTStep days (late 80s or early 90s), not OS X 10.0 days (early 
> 2000s), although I don’t know for sure.

Actually nope, it showed up in 10.3, making it younger than the target/selector 
approach.

Charles

___

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

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

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

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

Exception - completion routine is not called

2016-09-22 Thread Dan S
Hello, I have an 'NSInternalInconsistencyException': 'Completion handler
passed to -[ViewController
webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]
was not called'

JavaScript sends message to wkwebkit, and imediatelly after runs
alert('test') (from same jscript function)

The message sent to webkit will trigger some UI to come up from 3rd party
pod (via presentViewController), and the return, and alert will get fired
from script.

The alert is NOT visible now (because the UI from pod came up), But now
when I dismiss the ui, the app trhows exception above.

What dismisses the alert (or why does alert's completion routine is not
called if it wasn't dismissed with button)?


Script part:

window.webkit.messageHandlers.external.postMessage({some json data} );
alert('test');

cocoa in webkit to receive messages:

- (void)userContentController:(WKUserContentController
*)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
//...

AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]
delegate];
[app someDelegateMethod];
//...
}

// now in app delegate:
- (void) someDelegateMethod {
//...
UIViewController *uiView = [[... //this returned from a 3rd party cocoa pod)
[[self topViewController] presentViewController:uiView animated:YES
completion:nil];
//...
}

// wk alert message
- (void)webView:(WKWebView *)webView
runJavaScriptAlertPanelWithMessage:(NSString *)message
initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void
(^)(void))completionHandler {
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:webView.URL.host message:message
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"Close", "Close (panel/dialog/alert)")
style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
completionHandler();
}]];
[self presentViewController:alertController animated:YES
completion:nil];
}


// utils, for getting topViewController
- (UIViewController*)topViewController {
return [self topViewControllerWithRootViewController:[UIApplication
sharedApplication].keyWindow.rootViewController];
}
-
(UIViewController*)topViewControllerWithRootViewController:(UIViewController*)rootViewController
{
if ([rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController* tabBarController =
(UITabBarController*)rootViewController;
return [self
topViewControllerWithRootViewController:tabBarController.selectedViewController];
} else if ([rootViewController isKindOfClass:[UINavigationController
class]]) {
UINavigationController* navigationController =
(UINavigationController*)rootViewController;
return [self
topViewControllerWithRootViewController:navigationController.visibleViewController];
} else if (rootViewController.presentedViewController) {
UIViewController* presentedViewController =
rootViewController.presentedViewController;
return [self
topViewControllerWithRootViewController:presentedViewController];
} else {
return rootViewController;
}
}

Thank you
___

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

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

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

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

Re: Stupid objective-c question

2016-09-22 Thread Sandor Szatmari
So there was lots of discussion and plenty of 'don't do anything that equates 
to this' --> @"myString" == @"myString", and I agree.  

I wanted to get some opinions on the following which I have done in the past 
and perceive as different because the string constant is introduced and defined 
once and only once.

// my .m file
static NSString * const kMyContext = @"my fantastic context";

// later on
- (void) observeValueForKeyPath: (NSString *) keyPath   ofObject: (id) object
   change: (NSDictionary *) change context: (void *) context
{
  if ( context == kMyContext )
  { // do my stuff }
  else
  // call super
}

My interpretation of how to use context has been as an arbitrary pointer...  
Does this run afoul of anyone's sensibility?

Sandor Szatmari
___

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

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

2016-09-22 Thread Jens Alfke

> On Sep 22, 2016, at 3:45 PM, Gabriel Zachmann  wrote:
> 
> I don't see why that should not be possible in Obj-C - I just would need a 
> mechanism to add tell the system the names / function pointers to be 
> registered as observers.

That’s more like the way NSNotificationCenter works — you specify the target 
and selector, which together act similarly to a function pointer.

I’m not sure why, but KVO uses a single method to deliver all notifications. 
That’s just the way Apple designed it, and KVO is newer than 
NSNotificationCenter so they must have had a good reason for doing so. That 
means the only thing that can uniquely distinguish different KVO registrations 
is the ‘context’ value.

—Jens
___

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

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

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

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

Re: MLMediaLibrary sometimes does not call my KVO

2016-09-22 Thread Graham Cox

> On 22 Sep 2016, at 10:45 PM, Gabriel Zachmann  wrote:
> 
>> I’ve run into some unreliability in MLMediaLibrary. It appears to be a bug 
>> because it sometimes can be seen in places that use MLMediaLibrary within 
>> general standard components, such as NSOpenPanel (this adds a media browsing 
>> section if it is set up to allow image types, for example). 
> 
> Thanks a lot for your insights.
> 
> I am wondering: how does Microsoft Word , for instance, do it?
> I've never seen that application behave funny when it shows the image browser 
> (it faithfully shows all 10,000 images from my Photos library).
> 
> Does it use a different API?

It’s very hard for a sandboxed app to get access to the internals of Photos 
without using MLMediaLibrary, though not too difficult for non-sandboxed. 
MLMediaLibrary was added because of this need.

There is a standard component - NSMediaLibraryBrowserController 
(https://developer.apple.com/reference/appkit/nsmedialibrarybrowsercontroller?language=objc)
 that gives you a standardised panel for browsing. Unfortunately it’s a 
standalone panel rather than a view that you can embed within a larger UI, but 
it’s sufficient for many needs, and is easy to use. You could look at that and 
see if its behaviour is more reliable than your own code. I have tried it and 
it isn’t for me - I get the same problems with it that I see in NSOpenPanel, or 
when using KVO on MLMediaLibrary elements, which is why the problem seems to be 
in the lower-level layers of MLMediaLibrary.

—Graham



___

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

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

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

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

Re: Stupid objective-c question

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 15:45 , Gabriel Zachmann  wrote:
> 
> Sure, but an observation method is what would be called a "callback" in plain 
> C.
> In C, I can have many different callbacks.
> I don't see why that should not be possible in Obj-C - I just would need a 
> mechanism to add tell the system the names / function pointers to be 
> registered as observers.

It is of course possible in Obj-C. There are APIs that have a “didEnd” 
selector, such as (deprecated) ‘[NSApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:]’. That’s 
similar to the KVO notification method concept, except that you get to specify 
a selector and a target object. Note, however, that such APIs tend to have a 
context parameter, too**.

But that’s because the KVO notification mechanism is a more ancient design 
concept, where it likely seemed simple, adequate and flexible. I assume it 
comes from NeXTStep days (late 80s or early 90s), not OS X 10.0 days (early 
2000s), although I don’t know for sure.

It’s not that there *can’t* be a better mechanism, just that there isn’t***.


** In the “didEnd” selector mechanism, the context parameter is likely used for 
actual context information, rather than for identifying the source of the 
invocation. It can be used that way with KVO notifications, too, but the fact 
that they’re funneled through a single method in the observer object means that 
the context is implicitly known anyway, and the context parameter has been 
appropriated as a marker for the source of the observation.

*** Yet. KVO is one of the things that Swift hasn’t touched, even though it 
doesn’t translate very naturally. I believe (suspect) that’s because there’s an 
intention to replace it with a completely re-designed property notification 
system at some indefinite future time, but I’ve seen no discussion of what a 
new observer architecture might look like.

___

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

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

2016-09-22 Thread Gabriel Zachmann
> 
> Because the observer is an object. Your observation and a superclass 
> observation come from the same object. Whether these are to be treated as 
> different observations** cannot be determined automatically, hence the need 
> for a “context”.

Sure, but an observation method is what would be called a "callback" in plain C.
In C, I can have many different callbacks.
I don't see why that should not be possible in Obj-C - I just would need a 
mechanism to add tell the system the names / function pointers to be registered 
as observers.

Anyways, the concept of a block gets closer to what I mean, except it is still 
not a named function/method.

Best regards, 
Gabriel.


___

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

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

Defaults occasionally get confused

2016-09-22 Thread Gabriel Zachmann
I have a funny problem with the defaults of my screensaver.
Let me try to explain:

I read/write from/to the defaults like this:

defaults_ = [[ScreenSaverDefaults defaultsForModuleWithName: 
@"de.zach"] retain];
[defaults_ registerDefaults: appDefaults];
[defaults_ synchronize];
fontSize_ = [defaults_ integerForKey: @"FontSize"];


Later, when the user has modified some default values, I write to the default 
file like so:

[defaults_ setInteger: fontSize_ forKey: @"FontSize"];
[defaults_ synchronize];

This creates a file de.zach.855E4C13-F312-5D3A-BCA7-BDFFC2C65E42.plist

Now, occasionally, a new defaults file appears with a different ID (the long 
number at the end of the file name).
I never created that ID, but it makes my screensaver "forget" the original 
defaults.

Any ideas why this happens will be appreciated.

Best regards, 
Gabriel.


___

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

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

2016-09-22 Thread Volker in Lists
I am rendering sound sonagrams as contents of CALayers which have dimensions of 
height 1024 pixels and width above 3 pixel. No problem as long as you don’t 
use CIFilters. With them roughly 12000 pixels will work and larger images won’t 
get the filters applied to. I have solved that by using multiple CATiledLayers 
just aligned horizontally. 

The CATiledLayers call drawLayer:inContext and from there I directly draw the 
image (if necessary scaled down). The image is stored as one large CGImage in a 
property of my controller class. For 10.12 the tile size is drastically 
influencing performance, larger tile sizes are better.

So depending on your needs that may be a useful approach. 

volker

> Am 22.09.2016 um 15:14 schrieb Gabriel Zachmann :
> 
> 
> What is the maximum size of a bitmap image I can render using the Core 
> Graphics framework and CALayer ?
> 
> So far, I had assumed it is the maximum texture size the graphics card can 
> handle, so I determined the limits via
>   glGetIntegerv( GL_MAX_TEXTURE_SIZE, _ );
> 
> But apparently , the limits are much higher.
> 
> How can I determine the limit, so that my app can filter out images over the 
> limit, so that it does not crash in such cases?
> 
> I have checked the documentation, in particular 
> CGImageSourceCreateImageAtIndex() et al., to no avail.
> 
> 
> 
> Best regards, 
> Gabriel.
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/volker_lists%40ecoobs.de
> 
> This email sent to volker_li...@ecoobs.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: Passing param by reference then using within block throws exception

2016-09-22 Thread Steve Mills

On Sep 22, 2016, at 02:45 PM, "Gary L. Wade"  
wrote:

Look at these two lines:

   __block NSString* noFillMeIn;
...
         *noFillMeIn = @"wow";

Unless the original code is correct, you've got mismatched pointers, and you 
should try turning on more warnings and reading what they say, as well as 
trying the analyzer.

Copy & paste mistake. The quoted syntax won't even compile.

Sent from iCloud's ridiculous UI, so, sorry about the formatting

 
___

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

Please do not post admin requests or moderator comments to the list.
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: Triggering a segue from code

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 12:34 , Kyle Sluder  wrote:
> 
> -close asks the window’s delegate (via -windowShouldClose:) if it should
> close. If the window is owned by a window controller that’s associated
> with a document, the document will also get a chance to weigh in via
> -shouldCloseWindowController:…. It will also send
> NSWindowWillCloseNotification.
> 
> -orderOut: just hides the window (removes it from the window list). You
> can always order it back in again later.

Yes, but ignore for a moment the “shouldClose…” interaction, and assume the 
window is NOT set to release on close. What *else* does “close” do vs. 
“orderOut”?

The example app mentioned in this thread demonstrates that “close” has some 
other effect beyond what “orderOut” does. In particular, a “single”-mode 
storyboard segue re-uses an ordered-out window, but not a closed one.

___

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

Please do not post admin requests or moderator comments to the list.
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: Re: Passing param by reference then using within block throws exception

2016-09-22 Thread Steve Mills

On Sep 22, 2016, at 02:31 PM, Kyle Sluder  wrote:

Are you able to reproduce this in a sample app? I tried the following
but got no crash:

I haven't tried. The real method this came from is much more complex than my 
simplified example; 6 enumerate* loop blocks on dicts and arrays (a couple 
nested), another parameter before the reference parameter, lots of object 
allocation. After spending the bulk of my day on tracking down the problem, I 
don't want to waste more trying to come up with a sample that duplicates it. 
I'm sure you understand. If ARC can't do the right thing, it should be flagged 
as something that the user should change.

Sent from iCloud's ridiculous UI, so, sorry about the formatting

 
___

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

Please do not post admin requests or moderator comments to the list.
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: Passing param by reference then using within block throws exception

2016-09-22 Thread Gary L. Wade
Look at these two lines:

>__block NSString* noFillMeIn;
...
>  *noFillMeIn = @"wow";


Unless the original code is correct, you've got mismatched pointers, and you 
should try turning on more warnings and reading what they say, as well as 
trying the analyzer.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Sep 20, 2016, at 2:06 PM, Steve Mills  wrote:
> 
> I'm turning on ARC for a project (yay) and have run into a problem I can't 
> wrap my head around. It always worked fine before ARC. When I turn zombies 
> on, doing "memory history 0x610004279ac0" can't find it in the history. 
> Here's the method and the call to it:
> 
> -(void) doStuff:(NSString**)fillMeIn
> {
>[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
>   if(obj.flag) {
>  *stop = YES;
>  *fillMeIn = @"wow";
>   }
>}];
> }
> 
> NSString* getFilledIn;
> 
> [thing doStuff:];
> 
> The call to doStuff: results in EXC_BAD_ACCESS, or "*** -[CFString retain]: 
> message sent to deallocated instance 0x610004279ac0" if I turn zombies on.
> 
> I tried changing the param type to (NSString** _Nonnull), thinking it was 
> confused about my knowing that the reference will never be nil, but it didn't 
> help. Then I got to thinking about the reference being assigned inside the 
> block and changed it to:
> 
> -(void) doStuff:(NSString** _Nonnull)fillMeIn
> {
>__block NSString* noFillMeIn;
>
>[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL* stop) {
>   if(obj.flag) {
>  *stop = YES;
>  *noFillMeIn = @"wow";
>   }
>}];
>
>*fillMeIn = noFillMeIn;
> }
> 
> That seems to fix it. Is there a better way to deref and assign to the param 
> from within the block?
> 
> Sent from iCloud's ridiculous UI, so, sorry about the formatting
___

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

Please do not post admin requests or moderator comments to the list.
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: Triggering a segue from code

2016-09-22 Thread Kyle Sluder
On Mon, Sep 19, 2016, at 10:07 PM, Quincey Morris wrote:
> On Sep 19, 2016, at 18:10 , mail...@ericgorr.net
>  wrote:
> > 
> > The strange behavior I am now seeing is that when I show & hide the panel 
> > using the buttons are what appears to be two (not three, not four, etc.) 
> > different instances of the inspector panel. The autosave information only 
> > appears to apply to one but not the other.
> 
> A couple of things:
> 
> 1. You’re keeping the panel window instance reference in
> InspectorWindowController.sharedInstance, but not keeping a reference to
> its window controller. That causes its window controller to be
> deallocated early, although that likely has nothing to with the rest of
> the problem, since the panel doesn’t have any custom behavior yet. You
> should keep a reference to the window controller instead, and that will
> keep the panel alive too.
> 
> 2. You’re doing a “performClose” to hide the panel. If you do an orderOut
> instead, you get the behavior you want.
> 
> Note that you are getting a new instance of the panel because the window
> segue mechanism decides the first one has disappeared. Again because it’s
> not documented how window segues work, there’s no way of knowing what the
> “correct” behavior is supposed to be. (Your panel window is correctly set
> to “Single” mode in the storyboard, which is what’s supposed to prevent
> multiple instances from appearing.)
> 
> Also undocumented — forever AFAIK although others on this list may know
> more about this — is what a window “close” (or “performClose”) does,
> other than ordering out the window and (if it’s set to release on close)
> to release it.

-performClose: is documented to highlight the Close button, so that it
is highlighted if any “unsaved changes” confirmation sheets are
displayed. That helps the user understand what will happen to the
document window if they confirm the Save panel.

-close asks the window’s delegate (via -windowShouldClose:) if it should
close. If the window is owned by a window controller that’s associated
with a document, the document will also get a chance to weigh in via
-shouldCloseWindowController:…. It will also send
NSWindowWillCloseNotification.

-orderOut: just hides the window (removes it from the window list). You
can always order it back in again later.

--Kyle Sluder

> Whatever a “close” actually does, it’s making the
> storyboard mechanism unable to find the panel instance, so it creates a
> new one. (Your panel is *not* set to release on close, and I was able to
> verify that it’s not being released regardless, so this is not anything
> you appear to be doing wrong.)
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: Re: Passing param by reference then using within block throws exception

2016-09-22 Thread Kyle Sluder
On Wed, Sep 21, 2016, at 09:22 AM, Steve Mills wrote:
> On Sep 21, 2016, at 08:53 AM, Alex Zavatone  wrote:
> 
> Stab in the dark here, but I'm stabbing blank. Is there an Instruments
> tool or debugging option to detect this? 
> 
> Thanks for getting stabby. Fourvel appreciates it (only relevant if
> you're a CBB fan). It doesn't appear that anything will detect this. When
> zombies is on, it says an address is attempting to be retained but was
> previously released. That's a bit of a red herring, since the only 2
> variables being uses have just been declared and initialized right before
> the call to the method. If anything, the process of converting to ARC or
> the static analyzer should've flagged this as a problem.

Are you able to reproduce this in a sample app? I tried the following
but got no crash:

#include 
#import 

static void foo(NSString **fillMeIn) {
[@[@"a"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx,
BOOL *stop) {
*fillMeIn = obj;
*stop = YES;
}];
}

int main(int argc, char **argv) {
@autoreleasepool {
NSString *out;
foo();
printf("%s", out.UTF8String);
}
return 0;
}


--Kyle
___

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

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

2016-09-22 Thread Jens Alfke

> On Sep 22, 2016, at 10:03 AM, Gary L. Wade  
> wrote:
> 
> If you are dealing with truly astronomical image data, consider that "trying 
> it yourself" may require multiple machines and/or multiple dedicated GPUs 
> similar like how you see those multi-monitor displays shown at conferences 
> and marketing displays.

Or just (conceptually) break the image into tiles, and only load tiles into 
memory when they’re being displayed or edited, probably using an LRU eviction 
scheme. You’ll probably also need to store some scaled-down versions of the 
image, if you ever display a zoomed-out view that can display a large subset of 
the image at once.

This is nothing new. Old versions of Photoshop had to do this, back when RAM 
was scarce and most computers didn’t have virtual memory. (Heck, Photoshop 
probably still does this, because people do edit ridiculously large images in 
it, like 1200dpi posters.)

—Jens
___

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

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

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

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

Re: Stupid objective-c question

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 03:16 , Gabriel Zachmann  wrote:
> 
> That makes me wonder: why isn't it possible to register several, different 
> observers for the same thing?
> That way, I wouldn't need to care about observations I didn't create, would I?

Because the observer is an object. Your observation and a superclass 
observation come from the same object. Whether these are to be treated as 
different observations** cannot be determined automatically, hence the need for 
a “context”.

The reason it’s messy is that the observer/notification API is old and doesn’t 
follow modern API design practices. If this were being designed today, the 
“observeValueForKeyPath…” method would likely be replaced by a block/closure 
(similar to a completion handler) that’s passed as a parameter to the 
“addObserver…” call, and there wouldn’t be any contexts.


** That is, a superclass ‘addObserver’ may be in common code that’s used by all 
the subclasses, or it may be a private observation that’s separate from what 
subclasses use. Where the observation is created is insufficient to determine 
whether it’s an observation “you” created, or you “care about”.
___

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

Please do not post admin requests or moderator comments to the list.
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: Entitlements for non-appstore developer-id signed apps

2016-09-22 Thread Quincey Morris
On Sep 22, 2016, at 05:24 , Roland King  wrote:
> 
> I was reading a review of MacOS Sierra and it was claiming that Developer ID 
> signed, non mac-appstore apps now have access to more of iCloud than they did 
> previously, however it wasn’t very clear about exactly what those available 
> entitlements are. 

According to “Platforms State of the Union” at WWDC 2016, iCloud is now 
available for developer ID apps. Not “more of iCloud”, just iCloud.

I don’t know if there’s a list of what was changed, but if you want to find out 
which entitlement-based capabilities are allowed for a given target, select the 
project item in the Xcode navigator, select the target, select the Capabilities 
tab, and expand the descriptions of the entitlements. The ones that require MAS 
distribution say:

Developer ID distribution does not support this capability.

At present, the only ones that say this are Game Center and In-App Purchase.

___

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

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

2016-09-22 Thread Gary L. Wade
If you are dealing with truly astronomical image data, consider that "trying it 
yourself" may require multiple machines and/or multiple dedicated GPUs similar 
like how you see those multi-monitor displays shown at conferences and 
marketing displays.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Sep 22, 2016, at 9:53 AM, David Duncan  wrote:
> 
> If you know you will be dealing with very large images (a definition that 
> varies from year to year mind you) you will probably want to deal with the 
> largeness yourself, if only for initial loading performance reasons.
___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Gary L. Wade
If it's possible, I would ask the tool developer to provide you with a command 
line or XPC version and try accessing these state transitions in a more 
UI-thread-friendly manner.

Have you stopped your debugger when the freeze happens to see what your main 
thread stack frame looks like? It might give you a clue what you can do, if 
anything. Use that, Instruments, and the Activity Monitor app if ran on a 
non-developer's machine.
--
Gary L. Wade (Sent from my iPhone)
http://www.garywade.com/

> On Sep 22, 2016, at 9:09 AM, Dave  wrote:
> 
> Ok, will do thanks a lot. The AppleScript is/should be on the Main Thread. I 
> am assuming that the App the Script has finished when it returns but maybe 
> that is not the case. I will look into that too.
> 
> Thanks a lot for your help. 
> 
> Cheers
> Dave
> 
> 
>> On 22 Sep 2016, at 16:42, Jens Alfke  wrote:
>> 
>> 
>>> On Sep 22, 2016, at 5:20 AM, Dave >> > wrote:
>>> 
>>> So I’m wondering if it is something to do with the AppleScript handling?
>> 
>> AFAIK, AppleScripts can only be run on the main thread. But it’s been many 
>> OS releases since I worked with them.  Even if it’s legal to run them from a 
>> background thread now, they might be doing something like dispatching the 
>> actual execution to the main thread? (I’m just speculating.)
>> 
>> Anyway, if the main thread is unresponsive, then drop into the debugger and 
>> look at its stack to see what it’s blocked in. Experiment.
>> 
>> —Jens
>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com
> 
> This email sent to garyw...@desisoftsystems.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: Maximum image size ?

2016-09-22 Thread David Duncan

> On Sep 22, 2016, at 6:14 AM, Gabriel Zachmann  wrote:
> 
> 
> What is the maximum size of a bitmap image I can render using the Core 
> Graphics framework and CALayer ?

CoreGraphics is generally limited by main memory, and CALayer by GPU memory. 
CoreAnimation automatically tiles images that are larger than the GPU max image 
size.

However, you also generally don’t want to get anywhere near such limits, as 
performance tends to fall off a cliff before those points (due to many many 
implementation details and due to your own competition with the rest of the 
system).

If you know you will be dealing with very large images (a definition that 
varies from year to year mind you) you will probably want to deal with the 
largeness yourself, if only for initial loading performance reasons.

> 
> So far, I had assumed it is the maximum texture size the graphics card can 
> handle, so I determined the limits via
>   glGetIntegerv( GL_MAX_TEXTURE_SIZE, _ );
> 
> But apparently , the limits are much higher.
> 
> How can I determine the limit, so that my app can filter out images over the 
> limit, so that it does not crash in such cases?
> 
> I have checked the documentation, in particular 
> CGImageSourceCreateImageAtIndex() et al., to no avail.
> 
> 
> 
> Best regards, 
> Gabriel.
> 
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> 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

Re: Normalising file names on macOS

2016-09-22 Thread Alastair Houghton
On 22 Sep 2016, at 16:30, Ken Thomases  wrote:
> 
> Without undermining Alastair's recommendations, you can achieve what you want 
> by round-tripping the string through -[NSString fileSystemRepresentation] and 
> -[NSFileManager stringWithFileSystemRepresentation:length:].  That handles 
> the normalization, but it doesn't do anything about characters that aren't 
> legal in file names on a given file system.

:-)  I pondered mentioning -fileSystemRepresentation but decided it didn’t 
really solve the problem.  Right now, you’re right, it does normalise strings, 
but that isn’t documented and it’s probably undesirable - the HFS 
implementation can already cope with precomposed characters and by decomposing 
before passing to the BSD APIs there’s a risk that the present implementation 
will prevent a Cocoa program from opening the correct file (or any file at all) 
on some filesystems.

(It also has no way to know what filesystem’s rules it’s supposed to use, so it 
isn’t as if Apple could selectively disable normalisation to resolve this 
problem.)

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Dave
Ok, will do thanks a lot. The AppleScript is/should be on the Main Thread. I am 
assuming that the App the Script has finished when it returns but maybe that is 
not the case. I will look into that too.

Thanks a lot for your help. 

Cheers
Dave


> On 22 Sep 2016, at 16:42, Jens Alfke  wrote:
> 
> 
>> On Sep 22, 2016, at 5:20 AM, Dave > > wrote:
>> 
>> So I’m wondering if it is something to do with the AppleScript handling?
> 
> AFAIK, AppleScripts can only be run on the main thread. But it’s been many OS 
> releases since I worked with them.  Even if it’s legal to run them from a 
> background thread now, they might be doing something like dispatching the 
> actual execution to the main thread? (I’m just speculating.)
> 
> Anyway, if the main thread is unresponsive, then drop into the debugger and 
> look at its stack to see what it’s blocked in. Experiment.
> 
> —Jens
> 

___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Jens Alfke

> On Sep 22, 2016, at 5:20 AM, Dave  wrote:
> 
> So I’m wondering if it is something to do with the AppleScript handling?

AFAIK, AppleScripts can only be run on the main thread. But it’s been many OS 
releases since I worked with them.  Even if it’s legal to run them from a 
background thread now, they might be doing something like dispatching the 
actual execution to the main thread? (I’m just speculating.)

Anyway, if the main thread is unresponsive, then drop into the debugger and 
look at its stack to see what it’s blocked in. Experiment.

—Jens

___

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

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

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

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

Re: Normalising file names on macOS

2016-09-22 Thread Ken Thomases
On Sep 22, 2016, at 6:04 AM, John Brownie  wrote:
> 
> I find that I am in need of dealing with versions of strings that may be 
> turned into file names, and thus I need to be comparing normalised forms. 
> However, according to 
> https://developer.apple.com/library/content/qa/qa1173/_index.html, "For 
> example, HFS Plus (Mac OS Extended) uses a variant of Normal Form D in which 
> U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through U+2FAFF are 
> not decomposed (this avoids problems with round trip conversions from old Mac 
> text encodings)."
> 
> Is there a way to get at this variant? [NSString 
> decomposedStringWithCanonicalMapping] returns "A string made by normalizing 
> the string’s contents using the Unicode Normalization Form D." That seems not 
> to give what I need, but I haven't seen a better option. Is there such a 
> method?

Without undermining Alastair's recommendations, you can achieve what you want 
by round-tripping the string through -[NSString fileSystemRepresentation] and 
-[NSFileManager stringWithFileSystemRepresentation:length:].  That handles the 
normalization, but it doesn't do anything about characters that aren't legal in 
file names on a given file system.

Regards,
Ken


___

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

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

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

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

Re: Maximum image size ?

2016-09-22 Thread Alex Zavatone
I would RELY on what the limits are.

I remember back in the day when we were adding more graphic channels to 
Macromedia Director and we went from 64 to simply what the computer running our 
implementation had the RAM and processor power to handle.

We set it higher (I forget what) but it was limited by the machine's 
capabilities.  That way we could up the max amount as machines gained 
capability.

So, it might be able to support more, but not consistently across every 
machine/device.

That's my guess.


On Sep 22, 2016, at 9:50 AM, kata wrote:

>  I don't know the definition but my experience.
> JPEG accepts up to 65500 pixels width and height.  Core Graphics framework 
> supports more than that of course, and also PNG accepts more. Some 
> NSBezierPath methods will fail to draw around 8 and many methods fail 
> over 12, then i support up to 65500 now.
> 
> Yoshiaki Katayanagi
> http://www.jizoh.jp/english.html
> 
>> 2016/09/22 22:14、Gabriel Zachmann  wrote:
>> 
>> 
>> What is the maximum size of a bitmap image I can render using the Core 
>> Graphics framework and CALayer ?
>> 
>> So far, I had assumed it is the maximum texture size the graphics card can 
>> handle, so I determined the limits via
>>  glGetIntegerv( GL_MAX_TEXTURE_SIZE, _ );
>> 
>> But apparently , the limits are much higher.
>> 
>> How can I determine the limit, so that my app can filter out images over the 
>> limit, so that it does not crash in such cases?
>> 
>> I have checked the documentation, in particular 
>> CGImageSourceCreateImageAtIndex() et al., to no avail.
>> 
>> 
>> 
>> Best regards, 
>> Gabriel.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@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: Maximum image size ?

2016-09-22 Thread kata
  I don't know the definition but my experience.
JPEG accepts up to 65500 pixels width and height.  Core Graphics framework 
supports more than that of course, and also PNG accepts more. Some NSBezierPath 
methods will fail to draw around 8 and many methods fail over 12, then 
i support up to 65500 now.

Yoshiaki Katayanagi
http://www.jizoh.jp/english.html

> 2016/09/22 22:14、Gabriel Zachmann  wrote:
> 
> 
> What is the maximum size of a bitmap image I can render using the Core 
> Graphics framework and CALayer ?
> 
> So far, I had assumed it is the maximum texture size the graphics card can 
> handle, so I determined the limits via
>   glGetIntegerv( GL_MAX_TEXTURE_SIZE, _ );
> 
> But apparently , the limits are much higher.
> 
> How can I determine the limit, so that my app can filter out images over the 
> limit, so that it does not crash in such cases?
> 
> I have checked the documentation, in particular 
> CGImageSourceCreateImageAtIndex() et al., to no avail.
> 
> 
> 
> Best regards, 
> Gabriel.

___

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

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

Maximum image size ?

2016-09-22 Thread Gabriel Zachmann

What is the maximum size of a bitmap image I can render using the Core Graphics 
framework and CALayer ?

So far, I had assumed it is the maximum texture size the graphics card can 
handle, so I determined the limits via
   glGetIntegerv( GL_MAX_TEXTURE_SIZE, _ );

But apparently , the limits are much higher.

How can I determine the limit, so that my app can filter out images over the 
limit, so that it does not crash in such cases?

I have checked the documentation, in particular 
CGImageSourceCreateImageAtIndex() et al., to no avail.



Best regards, 
Gabriel.





___

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

Please do not post admin requests or moderator comments to the list.
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: MLMediaLibrary sometimes does not call my KVO

2016-09-22 Thread Gabriel Zachmann
> I’ve run into some unreliability in MLMediaLibrary. It appears to be a bug 
> because it sometimes can be seen in places that use MLMediaLibrary within 
> general standard components, such as NSOpenPanel (this adds a media browsing 
> section if it is set up to allow image types, for example). 

Thanks a lot for your insights.

I am wondering: how does Microsoft Word , for instance, do it?
I've never seen that application behave funny when it shows the image browser 
(it faithfully shows all 10,000 images from my Photos library).

Does it use a different API?

Best regards, 
Gabriel.





___

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

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

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

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

Re: How to update UI from a background thread

2016-09-22 Thread Dave
Hi Jens,

There is definitely something fishy going on, I’ll explain the process and how 
I am handling it. There is probably a much better way of doing it and if so I’m 
happy to redesign it.

In order to kick off a Network an third part App needs to be run which starts 
up a process that “looks” for available networks. When it finds one it makes it 
available for my App.

My App needs to grab the state of a Network which is handling by a third party 
package. The only way in which to check if a network is available is to attempt 
to create a Network Object (e.g. myNetwork [[Network alloc] initWithX];). 
If it returns nil, then the Network was not available. So the only way to 
ensure a Network is available is to Poll it. 

My App does this:

User Clicks the  “Connect” button, this launches the Third Party App and then 
runs an AppleScript to tell it to start looking for Network.

The Button handler in my App then starts a timer that Polls the Network every 
0.10 seconds. The Timer handler basically does a Alloc/Init and if it gets nil 
restarts the timer to try again a bit later on. If it gets non nil, then it 
sends a “NetworkConnected” notification. 

The Button Handler then calls “waitForNetworkConnection” which checks if there 
is a valid Network stored in a “connectedNetworksDictionary which is a property 
of the WindowController.
If it is not in the dictionary it calls itself back after a delay. So the 
button handler will return, but the “waitForNetworkConnection” will be called 

The  “NetworkConnected” notification handler then the stores the Network in the 
“connectedNetworksDictionary” property.

Accesses to the “connectedNetworksDictionary” are protected in an @synchronised 
block.

I noticed that the UI stops responding while stepping through the following 
code.

//** THIS STATUS MESSAGE IS SEEN

myNetworkStatusString = [[NSString alloc] initWithFormat:@"Executing Script %@ 
for Target Network: 
%@",myNetworkleScriptFilePath,theNetworkConfigInfo.pNetworkConfigInternalID];
[self updateUIStatusWithInfoMessage:myNetworkStatusString];

myNetworkleScriptSourceString = [[NSString alloc] 
initWithContentsOfFile:myNetworkleScriptFilePath encoding:NSUTF8StringEncoding 
error:];
if (myErrorInfo != nil)
{
myNetworkStatusString = [[NSString alloc] initWithFormat:@"Script 
Compile Error %@ for Target Network: 
%@",myNetworkleScriptFilePath,theNetworkConfigInfo.pNetworkConfigInternalID];
[self updateUIStatusWithErrorMessage:myNetworkStatusString];
return NO;
}

myNetworkleScript = [[NSNetworkleScript alloc] 
initWithSource:myNetworkleScriptSourceString];
[myNetworkleScript executeAndReturnError:];
if (myErrorDictionary != nil)
{
myNetworkStatusString = [[NSString alloc] initWithFormat:@"Script 
Execution Error %@ for Target Network: 
%@",myNetworkleScriptFilePath,theNetworkConfigInfo.pNetworkConfigInternalID];
[self updateUIStatusWithErrorMessage:myNetworkStatusString];
return NO;
}

//** UI STOPS UPDATING HERE

myNetworkStatusString = [[NSString alloc] initWithFormat:@"Script Complete %@ 
for Target Network: 
%@",myNetworkleScriptFilePath,theNetworkConfigInfo.pNetworkConfigInternalID];
[self updateUIStatusWithInfoMessage:myNetworkStatusString];

So I’m wondering if it is something to do with the AppleScript handling? The 
Script works ok if I run it from the Script Editor and it compiles and runs ok.

Any help on this would be greatly appreciated.

All the Best
Dave

> On 21 Sep 2016, at 17:20, Dave  wrote:
> 
> Hi,
> 
> This doesn’t work probably because the Class is that is calling back the 
> delegate method that updates the Scroll View is also being run on the main 
> thread. Sorry I should have said this earlier. I tried updating the UI on a 
> background thread and it seemed to work BUT I got warning message from 
> CALayer or maybe CATransaction and I think it caused the App to hang.
> 
> The time consuming method I am calling is in a third party library and it 
> must be called in the main thread. 
> 
> All the Best
> Dave
> 
>> On 21 Sep 2016, at 17:01, Sandor Szatmari  
>> wrote:
>> 
>> In general, one simple form is:
>> 
>> dispatch_async( dispatch_get_main_queue(), ^{
>> // do UI updates on the main thread.
>> });
>> 
>> This can also be done with NSOperationQueue:
>> 
>> [[NSOperationQueue mainQueue] addOperationWithBlock:^{
>> // do UI updates on main thread.
>> }];
>> 
>> Sandor Szatmari
>> 
>> On Sep 21, 2016, at 11:40, Dave > > wrote:
>> 
>>> Hi All,
>>> 
>>> How can I update my UI from a background thread?
>>> 
>>> I have a method that does a LOT of intense processing, it calls a delegate 
>>> method in my Window Controller which appends it to a Logging Scroll View, 
>>> however nothing shows up in the Scroll View although it NSLog’s the string 
>>> ok.
>>> 
>>> Firstly is it ok to 

Entitlements for non-appstore developer-id signed apps

2016-09-22 Thread Roland King
I was reading a review of MacOS Sierra and it was claiming that Developer ID 
signed, non mac-appstore apps now have access to more of iCloud than they did 
previously, however it wasn’t very clear about exactly what those available 
entitlements are. 

I’ve hunted around the documentation, in the Entitlements section, the iCloud 
section and a few other places but I can’t find a table, or similar resource, 
which says what entitlements are available to Developer ID signed apps and 
which are still reserved for mac app store apps in MacOS Sierra.

Has anyone seen such a table and have a link for it please? 
___

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

Please do not post admin requests or moderator comments to the list.
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: Normalising file names on macOS

2016-09-22 Thread John Brownie
Thanks, that sounds like a couple of good options. I'll try some options 
with the second one, and fall back on the first if necessary.


Alastair Houghton wrote:

My recommendation would be as follows:

1. If possible, don’t base the filename on the user’s input.  Instead, generate 
your own filename (one option might be to use a UUID) and then store a 
dictionary mapping the user’s input to the filename somewhere in your bundle.  
This avoids any problems with filename encoding completely.  You will still 
have to worry about normalising the user’s input, but that’s then just a matter 
of choosing a normalisation.

2. If you must base the filename on user input, do so by stripping out 
non-ASCII characters and replacing them with e.g. ‘_’s.  You’ll also need to 
make sure that the result is unique, otherwise a user might specify two names 
that both map to the same ASCIIfied name.  You’ll still want to store the 
dictionary mapping the user’s input.

The benefit of the second approach is that your bundle is more easily 
understood by a human being.  The downside is that it’s more complicated to 
implement.

Both will work, whatever the filesystem is, as they don’t rely on filesystem 
encoding behaviour.

(You might also then ponder whether you want things to be case-sensitive or 
not; the above will be.  Making it not case-sensitive is a little tricky in 
that just converting to upper or lower case doesn’t*quite*  work; the correct 
approach would be to use CFStringFold() to case-fold the string,*after*  
normalising, before using it as a dictionary key.)

John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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

Please do not post admin requests or moderator comments to the list.
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: Normalising file names on macOS

2016-09-22 Thread Alastair Houghton
On 22 Sep 2016, at 12:46, John Brownie  wrote:
> 
> OK, the situation is that the user provides a name, which comes in through a 
> standard text field in a dialog. That name is used as a key for a dictionary 
> which gives a collection of information about that item. It is also used to 
> create a file, hence it becomes a file name (with an appropriate extension). 
> A complication is that the document is stored as a bundle, and the name is 
> used as a file name for a file in the Resources directory and referenced in 
> the info.plist file.
> 
> When reading the document from disk, I need to match up the file name with 
> the appropriate entry in the info.plist. Currently that works as long as I 
> don't hit the normalisation issue. If I get a precomposed character given to 
> me, then the file name becomes the decomposed version, and I've lost the 
> mapping.

My recommendation would be as follows:

1. If possible, don’t base the filename on the user’s input.  Instead, generate 
your own filename (one option might be to use a UUID) and then store a 
dictionary mapping the user’s input to the filename somewhere in your bundle.  
This avoids any problems with filename encoding completely.  You will still 
have to worry about normalising the user’s input, but that’s then just a matter 
of choosing a normalisation.

2. If you must base the filename on user input, do so by stripping out 
non-ASCII characters and replacing them with e.g. ‘_’s.  You’ll also need to 
make sure that the result is unique, otherwise a user might specify two names 
that both map to the same ASCIIfied name.  You’ll still want to store the 
dictionary mapping the user’s input.

The benefit of the second approach is that your bundle is more easily 
understood by a human being.  The downside is that it’s more complicated to 
implement.

Both will work, whatever the filesystem is, as they don’t rely on filesystem 
encoding behaviour.

(You might also then ponder whether you want things to be case-sensitive or 
not; the above will be.  Making it not case-sensitive is a little tricky in 
that just converting to upper or lower case doesn’t *quite* work; the correct 
approach would be to use CFStringFold() to case-fold the string, *after* 
normalising, before using it as a dictionary key.)

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

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

Re: Normalising file names on macOS

2016-09-22 Thread John Brownie



Alastair Houghton 
22 September 2016 at 14:31

This is rather a hairy problem, actually. You don’t know that the 
filesystem is actually HFS+. The filename in question could refer to a 
file on an NTFS volume, or (in future) an APFS volume. It could also 
be a network filesystem, which could be mounted on a system running a 
completely different operating system with unknown character encoding 
behaviour; typically UNIX behaviour, for instance, is to completely 
ignore the filename encoding problem and treat filenames as a string 
of bytes (thus you are free to interpret them as UTF-8 if you so wish, 
but the filesystem will regard U+00E9 as different from U+0065 U+0301, 
even though the two names will display the same on screen).

True, it could be another file system. Another wrinkle!
Additionally, the version specified in HFS+ was based on a particular 
version of the Unicode standard (I forget which), but importantly 
*not* the current version, which is what the NSString APIs will use.


Perhaps we should start by understanding the context of your question. 
Is there a specific reason you want to match the filesystem behaviour 
precisely?
OK, the situation is that the user provides a name, which comes in 
through a standard text field in a dialog. That name is used as a key 
for a dictionary which gives a collection of information about that 
item. It is also used to create a file, hence it becomes a file name 
(with an appropriate extension). A complication is that the document is 
stored as a bundle, and the name is used as a file name for a file in 
the Resources directory and referenced in the info.plist file.


When reading the document from disk, I need to match up the file name 
with the appropriate entry in the info.plist. Currently that works as 
long as I don't hit the normalisation issue. If I get a precomposed 
character given to me, then the file name becomes the decomposed 
version, and I've lost the mapping.


The most obvious solution is to create the file and then see what I get 
back, and use that for the key. However, saving the whole bundle can be 
an expensive operation, so I wouldn't want to do it lightly. Then I 
might get the issue of different file systems, though it's less likely 
to be an issue, or at least it's less likely that a user would save it 
to two different file systems.


I could perhaps create a scratch file with the given name, but that runs 
into the possibility of different file systems. Still, if there's no 
better option, I can work with that.


Oh, and if it makes any difference, I'm supporting back to OS X 10.8 
currently.


John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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

Please do not post admin requests or moderator comments to the list.
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: Normalising file names on macOS

2016-09-22 Thread Alastair Houghton
On 22 Sep 2016, at 12:04, John Brownie  wrote:
> 
> I find that I am in need of dealing with versions of strings that may be 
> turned into file names, and thus I need to be comparing normalised forms. 
> However, according to 
> https://developer.apple.com/library/content/qa/qa1173/_index.html, "For 
> example, HFS Plus (Mac OS Extended) uses a variant of Normal Form D in which 
> U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through U+2FAFF are 
> not decomposed (this avoids problems with round trip conversions from old Mac 
> text encodings)."
> 
> Is there a way to get at this variant? [NSString 
> decomposedStringWithCanonicalMapping] returns "A string made by normalizing 
> the string’s contents using the Unicode Normalization Form D." That seems not 
> to give what I need, but I haven't seen a better option. Is there such a 
> method?

This is rather a hairy problem, actually.  You don’t know that the filesystem 
is actually HFS+.  The filename in question could refer to a file on an NTFS 
volume, or (in future) an APFS volume.  It could also be a network filesystem, 
which could be mounted on a system running a completely different operating 
system with unknown character encoding behaviour; typically UNIX behaviour, for 
instance, is to completely ignore the filename encoding problem and treat 
filenames as a string of bytes (thus you are free to interpret them as UTF-8 if 
you so wish, but the filesystem will regard U+00E9 as different from U+0065 
U+0301, even though the two names will display the same on screen).

Additionally, the version specified in HFS+ was based on a particular version 
of the Unicode standard (I forget which), but importantly *not* the current 
version, which is what the NSString APIs will use.

Perhaps we should start by understanding the context of your question.  Is 
there a specific reason you want to match the filesystem behaviour precisely?

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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

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

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

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

Normalising file names on macOS

2016-09-22 Thread John Brownie
I find that I am in need of dealing with versions of strings that may be 
turned into file names, and thus I need to be comparing normalised 
forms. However, according to 
https://developer.apple.com/library/content/qa/qa1173/_index.html, "For 
example, HFS Plus (Mac OS Extended) uses a variant of Normal Form D in 
which U+2000 through U+2FFF, U+F900 through U+FAFF, and U+2F800 through 
U+2FAFF are not decomposed (this avoids problems with round trip 
conversions from old Mac text encodings)."


Is there a way to get at this variant? [NSString 
decomposedStringWithCanonicalMapping] returns "A string made by 
normalizing the string’s contents using the Unicode Normalization Form 
D." That seems not to give what I need, but I haven't seen a better 
option. Is there such a method?


John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea
___

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

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