Date   

BRCloudDocsErrorDomain Code=12 “App library not found

Gerriet M. Denkmann
 

Starting an document based app in macOS 13.1 I get:

[…] [default] [ERROR] Failed getting container for URL: [ ~/Desktop/the current document]
r, error: Error Domain=BRCloudDocsErrorDomain Code=12 “App library not found: ‘com.apple.Desktop’” UserInfo={NSDescription=App library not found: ‘com.apple.Desktop’}

What does this mean?
I am not using Cloud storage and the document does not live on the desktop.

Apart from this annoying log message, all seems to be working fine.

Gerriet.


Re: Centering image view in scroll view

Graham Cox
 

You need to subclass NSClipView and implement the behaviour there. It’s annoying that there’s no built-in solution since it’s an ‘obvious’ requirement to me.

The better news is that the needed behaviour isn’t hard to achieve - this stack overflow answer gives a good solution: https://stackoverflow.com/questions/22072105/how-do-you-get-nsscrollview-to-center-the-document-view-in-10-9-and-later


—Graham

On 17 Nov 2017, at 3:04 am, Steve Mills <sjmills@...> wrote:

Ack. I'm having a hard time figuring out how to make an NSImageView in an NSScrollView act like it does in Preview.app, where it will stay centered within the window when any axis is smaller than the window, but still be zoomable by the user. What magic combination of settings, methods, and/or constraints do I need?

I have an NSViewController, if I need to override some methods there. Its view contains the scroll view. I initially want the image to fit within the window, so I calculate and set the scroll view's magnification in viewWillAppear.


Re: Centering image view in scroll view

Quincey Morris
 

On Nov 16, 2017, at 08:04 , Steve Mills <sjmills@...> wrote:

I'm having a hard time figuring out how to make an NSImageView in an NSScrollView act like it does in Preview.app, where it will stay centered within the window when any axis is smaller than the window, but still be zoomable by the user. What magic combination of settings, methods, and/or constraints do I need?

I don’t think there’s any magical solution. From what I see in Preview, it has a 2-phase approach — it lets you zoom normally via a pinch gesture (that is, doesn’t force any centering), then fixes the centering when you let go.

However, figuring it out is a bit complicated, because you’ve at least got these things going on:

— Is it resizing the image within the image view, or the image view within the scroll view, or both?

— To get “gray” areas around the image when the image/image view is smaller than the window/scroll view, you may need a container view for the image view. (In a scroll view, if the document view is smaller than the clip view, I don’t think you can reliably control where in the clip view the document view appears. You need the container to be at least the size of the clip view, so you can position the actual content within it.)

— There’s a difference between zooming and scaling. A scroll view’s zooming takes the document view and applies a transform to it. Scaling renders the document view at a higher resolution for a larger size.

In the old days, I did this manually by observing the clip view’s frame and bounds change notifications, and manually resizing and repositioning the document view to get the right result. It’s ugly, and it’s easy to end up with a cascading cycle notifications, but it’s doable. It’s not clear to me whether autolayout is any help.


Re: Simple iOS App with Foundation InputStream and OutputStream...

listservices@...
 

Hi Brandon.
 
One other consideration with iOS is that you may need to whitelist the destinations you want to connect to by declaring them in your info.plist under the NSAppTransportSecurity key. I don’t know if this applies to streams or not(?). 
 
In any event, this is done in your app's info.plist. Here is some sample XML with some different options you might need. I’ve added some explanatory comments. For the official guide, go here:
 
 
and search for NSAppTransportSecurity on the page.
 
 
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key> // As you might expect, this lets you load from arbitrary locations which can be useful during development
<true/>
<key>NSExceptionDomains</key>. // The domains you are going to whitelist go here
<dict>
<key>akamaihd.net</key> // The domain (or subdomain) you want to whitelist.
<dict>
<key>NSIncludesSubdomains</key> // In this case, any akamaihd.net subdomain is allowed. 
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> // This allows non https loads, which are blocked by default.
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSTemporaryExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
 
Hopefully this is helpful.
 
— Erikheath


Re: Simple iOS App with Foundation InputStream and OutputStream...

 



On Nov 15, 2017, at 9:48 AM, Brandon Peters <bap04e@...> wrote:

Thanks for reply. I thought the +[NSStream getStreamsToHostWithName:…] was deprecated in iOS 11+?

Just take a look at the header. It’s only the older version that takes an NSHost that’s deprecated:

@interface NSStream (NSSocketStreamCreationExtensions)

+ (void)getStreamsToHostWithName:(NSString *)hostname port:(NSInteger)port inputStream:(NSInputStream * _Nullable * _Nullable)inputStream outputStream:(NSOutputStream * _Nullable * _Nullable)outputStream API_AVAILABLE(macos(10.10), ios(8.0), tvos(9.0)) __WATCHOS_PROHIBITED;

#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
+ (void)getStreamsToHost:(NSHost *)host port:(NSInteger)port inputStream:(NSInputStream * _Nullable * _Nullable)inputStream outputStream:(NSOutputStream * _Nullable * _Nullable)outputStream API_DEPRECATED("Please use getStreamsToHostWithName:port:inputStream:outputStream: instead", macos(10.3,10.10)) API_UNAVAILABLE(ios, watchos, tvos);
#endif

@end


Centering image view in scroll view

Steve Mills
 

Ack. I'm having a hard time figuring out how to make an NSImageView in an NSScrollView act like it does in Preview.app, where it will stay centered within the window when any axis is smaller than the window, but still be zoomable by the user. What magic combination of settings, methods, and/or constraints do I need?

I have an NSViewController, if I need to override some methods there. Its view contains the scroll view. I initially want the image to fit within the window, so I calculate and set the scroll view's magnification in viewWillAppear.

Steve via iPhone


Re: Simple iOS App with Foundation InputStream and OutputStream...

Brandon Peters <bap04e@...>
 

Jens,

Thanks for reply. I thought the +[NSStream getStreamsToHostWithName:…] was deprecated in iOS 11+?

--Brandon

On Nov 15, 2017, at 12:41, Jens Alfke <jens@...> wrote:



On Nov 15, 2017, at 8:25 AM, Brandon Peters <bap04e@...> wrote:

All,

I created a simple iOS app to connect to a server and receive a message. I am doing this as an example app using InputStream, OutputStream, and StreamDelegate.

Consider using NSURLSessionStreamTask; it’s higher-level with IMHO a better API, and it supports proxies.

The Server is a simple Java app running on my MacBook Pro. The iOS app is running on my iPhone 7. I use the address of my laptop on the local network and the port the Java app is listening on (xxx.xxx.xxx.xxx:ppppp) in the URL object. Despite this, my InputStream and OutputStream objects are nil after calling their initializers.

If you’re using an NSURL for this, I don’t think you’re doing it correctly. URLs have schemes, which identify what protocol to use. Since you’re just making a raw TCP connection you don’t have a defined protocol that NSURL knows about.

The API for creating raw NSStreams for a TCP client connection is +[NSStream getStreamsToHostWithName:…].

—Jens





Re: Simple iOS App with Foundation InputStream and OutputStream...

 

On Nov 15, 2017, at 8:25 AM, Brandon Peters <bap04e@...> wrote:

All,

I created a simple iOS app to connect to a server and receive a message. I am doing this as an example app using InputStream, OutputStream, and StreamDelegate.
Consider using NSURLSessionStreamTask; it’s higher-level with IMHO a better API, and it supports proxies.

The Server is a simple Java app running on my MacBook Pro. The iOS app is running on my iPhone 7. I use the address of my laptop on the local network and the port the Java app is listening on (xxx.xxx.xxx.xxx:ppppp) in the URL object. Despite this, my InputStream and OutputStream objects are nil after calling their initializers.
If you’re using an NSURL for this, I don’t think you’re doing it correctly. URLs have schemes, which identify what protocol to use. Since you’re just making a raw TCP connection you don’t have a defined protocol that NSURL knows about.

The API for creating raw NSStreams for a TCP client connection is +[NSStream getStreamsToHostWithName:…].

—Jens


Simple iOS App with Foundation InputStream and OutputStream...

bap04e@...
 

All,


I created a simple iOS app to connect to a server and receive a message. I am doing this as an example app using InputStream, OutputStream, and StreamDelegate. The Server is a simple Java app running on my MacBook Pro. The iOS app is running on my iPhone 7. I use the address of my laptop on the local network and the port the Java app is listening on (xxx.xxx.xxx.xxx:ppppp) in the URL object. Despite this, my InputStream and OutputStream objects are nil after calling their initializers. If I use netcat in terminal I can connect to the server. But my running iOS app cannot. Is there something missing in the iOS app that I need, like a permission of some sort?


Re: Cancelling dispatch_after?

dhoerl
 

The way I always do this:

- create a weakSelf, then in the block assign it to a strongSelf, and test strongSelf for nil
- have a property on your class "delayedBlockCancelled" (you can use an ivar too, then use "->" instead of ".")
- in your dispatch block, if strongSelf is not nil, then see if the property is set or not.

If property is set, then don't do anything.


Re: Add overflow indicator to text

Steve Mills
 

On Nov 9, 2017, at 13:39:20, Alex Zavatone <zav@...> wrote:

myLabel.lineBreakMode = NSLineBreakByTruncatingTail;
I'm not sure where my brain was, but I totally blanked this out and was too focused on trying to roll my own. This works just fine in my scenario, even when oddly shaped exclusionPaths are applied. The only time it doesn't work is when I have a rotation xform applied to the UITextView - the truncation ellipsis doesn't appear.

--
Steve Mills
Drummer, Mac geek


TextFields in a Row with AutoLayout

Gerriet M. Denkmann
 

macOS 12.6, Xcode Version 9.1 (9B55).

A window with:

fixedSpace | fixedTextField | fixedSpace | textField(width ≥ 50) | fixedSpace | textField(width ≥ 100) | variableSpace( width ≥ 10)

This implies window.width ≥ sumOfFixedStuff + 50 + 100 + 10.

At the minimum window size both contents of the variable textFields are truncated (assuming big contents).

When the window grows, the textField(width ≥ 50) will expand first (as it is more adverse to having its content squashed with Content Compression Resistance Priority = 751) until it can show all of its content.

When the window grows even more, the textField(width ≥ 100) will eventually also show all its content.

From here on, only the variableSpace( width ≥ 10) will grow.

I don’t see any ambiguity here - but sadly, Xcode does (Inequality Constraint Ambiguity width ≥ 100).

When I run the program, I see variableSpace having its minimum width and textField(width ≥ 100) taking all of the available width, which looks very silly.

I can fix this by changing to textField(width = 50) and textField(width = 100), but then I get the (quite correct warning) that this might result in truncation at runtime.

How to make Xcode behave as I want?

Gerriet.


Re: How to configure NumberFormatter in Xcode

Gerriet M. Denkmann
 

On 10 Nov 2017, at 18:37, Shane Stanley <sstanley@...> wrote:

On 10 Nov 2017, at 9:30 pm, Gerriet M. Denkmann <g@...> wrote:

NSNumberFormatter has a property: maximumFractionDigits - but I can’t find where to use this in Xcode.
Select the formatter and in the Attributes inspector change the Behavior to OS X 10.4+ Custom.
Indeed. The only place where I didn’t look.

Thanks a lot!

Kind regards,

Gerriet.


Re: How to configure NumberFormatter in Xcode

Shane Stanley
 

On 10 Nov 2017, at 9:30 pm, Gerriet M. Denkmann <g@...> wrote:

NSNumberFormatter has a property: maximumFractionDigits - but I can’t find where to use this in Xcode.
Select the formatter and in the Attributes inspector change the Behavior to OS X 10.4+ Custom.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


How to configure NumberFormatter in Xcode

Gerriet M. Denkmann
 

macOS 12.6, Xcode Version 9.1 (9B55).

I added a NumberFormatter (Decimal) to some TextField. This now shows: “12.345”.
Not bad, but I want to see: “12.3”.

NSNumberFormatter has a property: maximumFractionDigits - but I can’t find where to use this in Xcode.

Sure, I can edit MyWindow.xib and change maximumFractionDigits=“3” to maximumFractionDigits=“1”, but somehow this feels not the right and proper way to to things.

Gerriet.


Re: Add overflow indicator to text

Steve Mills
 

Thanks for the input, everyone. I mentioned that exclusionPaths are used, so the text flows inside arbitrary shapes, mostly comic book balloon type blobs. As such, there's rarely a straight bottom edge, straight right edge, or bottom-right corner. So it seems like the best place is to put the marker after the last visible character. If that happens to be outside the bounds of the parent view, I'll try putting it below the last visible char. And if that happens ti be outside the bottom of the parent view, float it over the last visible char. At that point, it doesn't matter of it obscures the char, since it's overflowed and the user needs to choose a smaller text size.

Years ago I worked for MultiAd. Our page layout app Creator put a fat, red ellipsis below the bottom edge of an overflowed text box when editing was active, and above the bottom edge when it was inactive. While active, it double as a button that allowed the user to add a new text block in sequence. When it didn't look right was when the text block was in a non-rectangular shape, like a right triangle whose right angle is at the top-left, so the marker was left floating in space. Which is why it makes sense for it to be near the last visible char, especially since the app I'm working on now is only a viewer, not an editor.

Thanks for talking through it with me.

--
Steve Mills
Drummer, Mac geek


Re: Add overflow indicator to text

Graham Cox
 



This is what we do in a drawing app, which works well for us. When the text box is selected, it shows the + symbol as part of the frame. If not selected that’s not visible, so the text itself isn’t modified by not fitting. If you have some sort of highlighting or frame around the text, something like this could work for you.

To detect whether this is drawn or not, we ask the layout manager of the text system for the -glyphRangeForTextContainer:, and compare it to the -glyphRangeForCharacterRange: for the entire text. The symbol is displayed when they are unequal. This is simple and reliable, though NSLayoutManagerDelegate has -layoutManager:didCompleteLayoutForTextContainer:atEnd: where the atEnd: part tells you whether it completed the job. 

—Graham



On 10 Nov 2017, at 4:41 am, Steve Mills <sjmills@...> wrote:

I'm using NSTextContainer with exclusionPaths, NSLayoutManager, and UITextView for rendering text into balloons, and the user can control the font size. When overflow occurs, I'd like to show an indicator. Just looking for thoughts on the best way to show that. My first thought is to insert a red ellipsis after that last visible character, although that could certainly cause it to re-wrap and overflow in a different spot. Other thoughts involve drawing something in a new layer at the overflow location, such as an ellipsis in a semi-transparent capsule shape.



Re: Add overflow indicator to text

Alex Zavatone
 


On Nov 9, 2017, at 12:28 PM, Quincey Morris <quinceymorris@...> wrote:

On Nov 9, 2017, at 09:41 , Steve Mills <sjmills@...> wrote:

drawing something in a new layer at the overflow location

In text layout apps that I’ve used, which can flow text through multiple containers, there’s typically a small box outside the top-left and bottom-right corners of the container frame. The boxes contain some indicator if the container is linked to another preceding or following container, and if the last container is overset, the bottom-right box typically shows a red plus sign, which you can click on to go into an add-new-container mode.

Given all that, I think drawing an overflow icon over the bottom corner would be a familiar choice. If you draw an ellipsis in a capsule, you could put it just outside the frame, or float it centered over the frame edge.

Putting it inside the frame inline with the text doesn’t seem like a terrible idea, but it might be easier for the user to miss, and it leaves you open to subtle layout problems where the indicator doesn’t show at all.
_

Quincy, your observation reminds me of how Quark Xpress handled this in circa 1989.  It was a surprisingly nice indicator that “there is more to this text box”.  I think they may have put a small bottom-right box indicator and then added a chain link graphic in the box it the text container was linked to another text container.

Thinking of Steve’s original problem and ideas solution, I am wondering about the red ellipsis as well and thinking just how much of this will already be solved by the NSTextContainer or UITextView.   

What I mean is that a UILabel will display an ellipsis at the end when it has the following settings:

myLabel.adjustsFontSizeToFitWidth = NO;
myLabel.lineBreakMode = NSLineBreakByTruncatingTail;
In that case, the text is already properly truncated for you.  The only thing would be needed would be to change the color of the ellipsis that is displayed at the end or find the position of the last character and draw your own ellipsis over it…

Of course, that’s on iOS with a UILabel.  I’m not sure how a NSTextContainer or UITextView would handle this.  


Thinking about how this might look to the user, a red color often is associated with something being wrong, or a destructive action, like deleting data, as we all know.  

The trick might be getting it to work first, then once you are able to get the character position of the ellipsis, simply figuring out what you want to display there.  

Quincy’s suggestions seem to be pretty user friendly and also more straightforward to implement though.

Good luck.
Alex Zavatone




Re: Cancelling dispatch_after?

Quincey Morris
 

On Nov 9, 2017, at 08:57 , Jens Alfke <jens@...> wrote:

because then blocks would always be copied to the heap, even in common cases where they don’t escape

Yes, that sounds correct. I was thinking that there was a problem for the original caller (the one in whose stack frame the block resides), because the block might have moved after the call returns. But (I presume) this could be handled with one level of indirection in the caller, so that it doesn’t care where the block happens to be, plus the passing of a reference to the pointer, so that the pointer can be updated in the event of a (real) copy.

By contrast, in Swift, block (aka closure) parameters are explicitly annotated as escaping or non-escaping, so this kind of hack is avoidable.


Re: Add overflow indicator to text

Quincey Morris
 

On Nov 9, 2017, at 09:41 , Steve Mills <sjmills@...> wrote:

drawing something in a new layer at the overflow location

In text layout apps that I’ve used, which can flow text through multiple containers, there’s typically a small box outside the top-left and bottom-right corners of the container frame. The boxes contain some indicator if the container is linked to another preceding or following container, and if the last container is overset, the bottom-right box typically shows a red plus sign, which you can click on to go into an add-new-container mode.

Given all that, I think drawing an overflow icon over the bottom corner would be a familiar choice. If you draw an ellipsis in a capsule, you could put it just outside the frame, or float it centered over the frame edge.

Putting it inside the frame inline with the text doesn’t seem like a terrible idea, but it might be easier for the user to miss, and it leaves you open to subtle layout problems where the indicator doesn’t show at all.

1061 - 1080 of 1478