Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I vote for the option that doesn’t make me wish that ABI stability never happened.

Adbot
ADBOT LOVES YOU

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Has anyone had a chance to try out Metal in Simulator yet? Or observed faster boot times (excluding the first time that sim starts up)?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
On my 2014 mbp the simulator only ever repaints when the window gains focus so I have to spend a lot of time cmd-tabbing between it and xcode. I have no idea if that's due to it using metal though.

chaosbreather
Dec 9, 2001

Wry and wise,
but also very sexual.

Does anyone know any best practices or examples or anything for Core Data and SwiftUI? I watched all the lectures and they were like "you don't need controllers any more" but I'm not seeing a way to hook up core data poo poo to SwiftUI without painstakingly building a bunch of controllers for all this poo poo. There was like one slide about integrating it in the Core Data preso and that was it.

Are they all shut up about it because they've got a replacement for Core Data in the works that is actually Swifty, did they just forget about it, or are they just abandoning it because it seems like Core Data does a lot of boring tricky things that I would very much like to not have to do.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
There isn’t “integration” in the sense of having things in Swift UI or Core Data specifically to make using them together trivial, there’s no equivalent to NSFetchedResultsController for example. Can you describe a little more what you feel integration between Swift UI and Core Data would look like?

Core Data objects are just objects and you can use them from Swift just fine; as such, making them fit in with Swift UI (like conforming to Identifiable) is quite straightforward.

For example, it wouldn’t be a stretch at all to switch the RoomStore used in the first Swift UI session on Tuesday out for one that uses Core Data and where Room is a subclass of NSManagedObject. It might even be a good exercise to go through.

Good Sphere
Jun 16, 2018

Update

I needed to pass an option to allow user interaction on both animation calls:

code:
let transforms: CGAffineTransform = .identity

mirroredButton.transform = transforms

UIView.animate(withDuration: 0.05, delay: 0.0, options: .allowUserInteraction, animations: {
	mirroredButton.transform = transforms.scaledBy(x: 0.75, y: 0.75)
},
completion: { _ in
	UIView.animate(withDuration: 0.1, delay: 0.0, options: .allowUserInteraction, animations: {
		mirroredButton.transform = transforms.scaledBy(x: 1.0, y: 1.0)
	}, completion:nil)
})


Anyone know how to prevent a UIButton's animation ignoring calling the target's selector while animating? It's a short animation, but I want to let users touch the button rapidly if they wanted.

To clarify, this is at the end of a function that's called when touching the button, and while it is animating, the function is completely ignored.

code:
let transforms: CGAffineTransform = .identity

mirroredButton.transform = transforms

UIView.animate(withDuration: 0.05, animations: {
	mirroredButton.transform = transforms.scaledBy(x: 0.75, y: 0.75)
},
completion: { _ in
	UIView.animate(withDuration: 0.1) {
		mirroredButton.transform = transforms.scaledBy(x: 1.0, y: 1.0)
	}
})

Good Sphere fucked around with this message at 20:21 on Jun 14, 2019

lord funk
Feb 16, 2004

Simulated posted:

Has anyone had a chance to try out Metal in Simulator yet? Or observed faster boot times (excluding the first time that sim starts up)?

Oh poo poo is this a thing now? I hope my machines are supported.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

lord funk posted:

Oh poo poo is this a thing now? I hope my machines are supported.

Indeed it is. If your machine can run 10.15 then it is supported.

Also disregard the Metal docs statement about ATSC not being supported; that’s a doc bug. We transparently decompress ATSC textures on the CPU. We also simulate memoryless and shared texture support in some cases (others require a workaround).

Good Sphere
Jun 16, 2018

I've been having trouble with this for a while. I'm trying to mask a UIPickerView, so that it does not show the squished words outside the bounds of the background layer, which you can see on the left and right:



I tried masking it with a CAShapeLayer, but it removes all the text in the UIPickerView instead: (ignore the beige color; that is just what the camera is picking up)



To make sure my CAShapeLayer was the right size and shape, I added it as a layer and commented out the mask:



Just as I expected, the CAShapeLayer is the right size and in the correct position.

What is wrong with my code? BG is the background layer. filterSelection is the UIPickerView.

code:
guard let BG = filterSelectionBG else { return }
let maskLayer = CAShapeLayer()
maskLayer.backgroundColor = UIColor.red.cgColor
maskLayer.fillColor = UIColor.red.cgColor
let path = CGMutablePath()
path.addRect(BG.frame)
maskLayer.path = path

filterSelection.layer.mask = maskLayer

Good Sphere fucked around with this message at 21:37 on Jun 19, 2019

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

I spent some time trying to figure out some of my old code, and I found two versions of a project, one is a bit newer. I'm guessing converting CGImageRef to NSImage is less efficient but if it's the better way to do it for some reason, I'm all ears.

Which is the more efficient way of drawing an image? They're rendering pop-up thumbnails of a sort.

code:
	[[previewThumbnails objectAtIndex:i] getValue:&thumbRetrieve];
        NSImage *thumb = [[NSImage new] initWithCGImage:thumbRetrieve size:NSZeroSize];
        [thumb setSize:NSMakeSize(previewWidth, previewHeight)];
        [thumb drawAtPoint:NSMakePoint(x, 100.0+previewBorder)
                      fromRect:NSZeroRect
                     operation:NSCompositingOperationCopy
                      fraction:1.0];
vs:

code:
    
    NSRect bounds = [self bounds];
    CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    CGRect renderRect = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    CGContextDrawImage(ctx, renderRect, backgroundImage);
    CGImageRelease(backgroundImage);

Doc Block
Apr 15, 2003
Fun Shoe
If you already have the CGImage, and you’re doing custom drawing anyway, might as well skip converting it to an NSImage.

But if you’re only doing this once in a while, it probably won’t matter.

Good Sphere
Jun 16, 2018

Xcode 2FA question: My dev phone has my own account, but I use another account for development. Xcode is now giving me an error message upon building:

quote:

You currently don't have access to this membership resource. To resolve this issue, your team's Account Holder, [person's name], must agree to the latest Program License Agreement.

I logged into the Developer Portal with the dev account, and it says "Your Apple ID needs to be updated" and a red exclamation point for "Two-factor Authentication".

My dev phone has 2FA enabled, but it's my own account. As far as I know, there's no iOS device associated with the dev account. How to proceed?

NoDamage
Dec 2, 2000
Ran into this recently as well. You need to add your dev account with 2FA to your phone or computer.

https://developer.apple.com/support/account/authentication/

Good Sphere
Jun 16, 2018

NoDamage posted:

Ran into this recently as well. You need to add your dev account with 2FA to your phone or computer.

https://developer.apple.com/support/account/authentication/

Thank you! I'm so relieved I'm able to use the 2FA on my computer. I thought I'd have to log out of the account on my phone or something.

brap
Aug 23, 2004

Grimey Drawer
Are there any good articles about migration from UIKit to SwiftUI? I am thinking of rewriting my app's UI (moving from Storyboards and xibs) and would like to know if I need to basically start from scratch or if there's a way to recreate the UI one view controller at a time.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

brap posted:

Are there any good articles about migration from UIKit to SwiftUI? I am thinking of rewriting my app's UI (moving from Storyboards and xibs) and would like to know if I need to basically start from scratch or if there's a way to recreate the UI one view controller at a time.

The approach is quite different so there isn’t really the concept of “porting”.

However you can mix and match, which makes it easy to replace things over time rather than throwing everything out.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Got my new home dev machine up and running and I've been going through the SwiftUI tutorials - pretty interesting so far. The old soul in me is wary of this level of abstraction but it is quite nice.

Anyone else been playing around with it?

brap posted:

Are there any good articles about migration from UIKit to SwiftUI? I am thinking of rewriting my app's UI (moving from Storyboards and xibs) and would like to know if I need to basically start from scratch or if there's a way to recreate the UI one view controller at a time.

Rewriting this early on with something as nascent as SwiftUI sounds scary to me.

Doctor w-rw-rw-
Jun 24, 2008

Doh004 posted:

Rewriting this early on with something as nascent as SwiftUI sounds scary to me.

It's Apple so it probably baked in their special projects group or some team like that for a couple of years, and it's conceptually similar to stuff that's been around for a while. I think it's less risky than most things you could choose.

Stringent
Dec 22, 2004


image text goes here
The backwards compatibility is the only reason I'm not messing with it yet. I like what I've seen just playing with it though.

brap
Aug 23, 2004

Grimey Drawer

Doh004 posted:

Rewriting this early on with something as nascent as SwiftUI sounds scary to me.

Yeah, I'm probably punting on it until the designer is available in a non-beta macOS, and it's a personal project so not a ton of risk.

Good Sphere
Jun 16, 2018

Is there something in Xcode that automatically makes other pixel density images for different devices by dragging and dropping in the highest resolution image?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Apple doesn’t really do framework ADD so I don’t think there’s any chance of SwiftUI just being abandoned, but it’d still be crazy to port a real app to it before there’s even a non-beta release of it.

Pulcinella
Feb 15, 2019
SwiftUI doesn’t have a CollectionView equivalent yet so I won’t be using it for a real app anytime soon, but I am very excited about the possibilities. I’m hoping that it will make tons of interface builder and auto layout style problems just go away. I say that as someone who actually like IB, storyboards, and autolayout. When they work it’s amazing, but after awhile XIB files seem to get crusty and IB gets cranky and will just fail to render them and throw IB errors no matter what you do.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Good Sphere posted:

Is there something in Xcode that automatically makes other pixel density images for different devices by dragging and dropping in the highest resolution image?

Not that I’ve found. I usually search for some site that will do it because I’ve totally failed to actually solve the problem for myself :)

There’s always sips

Family Values
Jun 26, 2007


Good Sphere posted:

Is there something in Xcode that automatically makes other pixel density images for different devices by dragging and dropping in the highest resolution image?

Put it in the asset catalog cataloged at the correct resolution and enable auto scaling:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Does that actually work on iOS? I had no idea.

Does it work for app icons?

Good Sphere
Jun 16, 2018

Family Values posted:

Put it in the asset catalog cataloged at the correct resolution and enable auto scaling:



That's cool. Doesn't that require the device to do some extra work on resizing a large image possibly, instead of loading the right size for the right device? Smaller app file size; more work on the hardware.

Also, my app is suddenly giving me a greeting when I preview all the apps that are open! I didn't even update the OS. How is this happening. i.e., It says "Good afternoon" at the bottom of my screen. No other app is doing this.

Family Values
Jun 26, 2007


Good Sphere posted:

That's cool. Doesn't that require the device to do some extra work on resizing a large image possibly, instead of loading the right size for the right device? Smaller app file size; more work on the hardware.


No, the resizing happens at build (and the unnecessary resolutions are thinned by the Store when it’s downloaded to a device)

Good Sphere
Jun 16, 2018

Family Values posted:

No, the resizing happens at build (and the unnecessary resolutions are thinned by the Store when it’s downloaded to a device)

That is amazing. Thank you.

Chamook
Nov 17, 2006

wheeeeeeeeeeeeee

Good Sphere posted:

Also, my app is suddenly giving me a greeting when I preview all the apps that are open! I didn't even update the OS. How is this happening. i.e., It says "Good afternoon" at the bottom of my screen. No other app is doing this.

This is from handoff or something I think. We got a support case from a customer that had set their name to “dumb head” in some Apple settings and then they were mad that our app was suddenly showing a “Good morning dumb head!” message

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<
Is there any reason I can't/shouldn't detect whether a user has a particular app installed, like this? I want to show a link to some company's website, but if the user has that company's app installed, offer that as an option instead/also. Facebook acts like it's doing that, but it's not; I don't have the NYTimes app, so that link just takes me to the app store. Which is weird. I'd like to offer that link if they have the app, but remove it if they don't.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Apple does not want you to be able to detect if a user has an app installed because that would be a violation of their privacy.

Froist
Jun 6, 2004

jackpot posted:

Is there any reason I can't/shouldn't detect whether a user has a particular app installed, [URL=https://stackoverflow.com/questions/22156042/detect-if-some-other-is-app-installed-on-ios-device]like this?

Note that the question/answer is from early 2014, and I think the behaviour has changed since then - I’ve had trouble getting similar functionality working. Having just checked the docs quickly, it seems since iOS9 you have to specify the url schemes you’ll query in your info.plist. I can’t see any documentation on the limits of what you can specify in that list (e.g. whether the schemes need to be owned by another app on your developer account), but there is presumably some additional restriction.

Plorkyeran posted:

Apple does not want you to be able to detect if a user has an app installed because that would be a violation of their privacy.

Basically this.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

jackpot posted:

Is there any reason I can't/shouldn't detect whether a user has a particular app installed, like this? I want to show a link to some company's website, but if the user has that company's app installed, offer that as an option instead/also. Facebook acts like it's doing that, but it's not; I don't have the NYTimes app, so that link just takes me to the app store. Which is weird. I'd like to offer that link if they have the app, but remove it if they don't.



I think the general idea is just open the website URL, and if the user has the app installed and the app has Universal Links set up correctly then it’ll open in the app or in Safari as appropriate without you doing anything special. This has the additional benefit of avoiding URL scheme collisions.

If life is more complicated, you may find openURL with UIApplicationOpenExternalURLOptionsKey useful? The completion handler is told whether the open succeeded, and if it fails you can open the website instead.

Finally, for things like “open in Chrome”, I think the working theory is share the URL using UIActivityViewController and let Chrome add its own activity. If you want something more direct then you can add Chrome’s URL scheme to your Info.plist and call canOpenURL.

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<

pokeyman posted:

I think the general idea is just open the website URL, and if the user has the app installed and the app has Universal Links set up correctly then it’ll open in the app or in Safari as appropriate without you doing anything special.
Yeah I think that's the way to go; even if I could make it work anything else is just needlessly complicated. For the thing (sorry I'm vague, it's for work) I'm designing there's some benefit to keeping the user in my in-app browser, but in most cases that's outweighed by the benefits of them using the dedicated app.

Good Sphere
Jun 16, 2018

Chamook posted:

This is from handoff or something I think. We got a support case from a customer that had set their name to “dumb head” in some Apple settings and then they were mad that our app was suddenly showing a “Good morning dumb head!” message

lol

Thanks I'll look into it. I never remembered setting anything differently, but my app is still showing this message, so it must be somewhere.

Doctor w-rw-rw-
Jun 24, 2008
Any word on whether Swift will support async/await at some point in the future?

EDIT: after some research I came upon https://gist.github.com/lattner/429b9070918248274f25b714dcfc7619 (btw, "Proposal: SE-XXXX"? <_<) - but it's not an official one.

Doctor w-rw-rw- fucked around with this message at 07:43 on Jul 18, 2019

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doctor w-rw-rw- posted:

Any word on whether Swift will support async/await at some point in the future?

EDIT: after some research I came upon https://gist.github.com/lattner/429b9070918248274f25b714dcfc7619 (btw, "Proposal: SE-XXXX"? <_<) - but it's not an official one.

I asked in the PL thread a little while back and the answer was "yes, but it’s complicated so not as soon as you might hope, maybe 2020". Also the limitations of the proposal you linked were acknowledged (turn the page at the PL thread link for more info).

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

pokeyman posted:

I asked in the PL thread a little while back and the answer was "yes, but it’s complicated so not as soon as you might hope, maybe 2020". Also the limitations of the proposal you linked were acknowledged (turn the page at the PL thread link for more info).

drat, this is a great explanation I missed skipping through that thread. I don't get the feeling that most people realize how much codegen C#-et-al do to make those keywords work, and the tradeoffs that need to be considered implementing them.

Adbot
ADBOT LOVES YOU

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
and that they’re not something you can just sprinkle around your codebase like fairy dust to make faster

kind of like people discovered about dispatch, that it’s something you have to think about

(also as long as there’s a sane memory model I’ve never found myself actually wanting async/await)

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply