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
101
Oct 15, 2012


Vault Dweller

Plorkyeran posted:

Using the storyboard part of storyboards seems to be pretty rare, but ignoring segues and using a storyboard per screen certainly isn’t.

Would there be a reason to do this over using xibs?

Adbot
ADBOT LOVES YOU

101
Oct 15, 2012


Vault Dweller

Glimm posted:

Static UITableViews? Maybe that's possible with xibs now.

SaTaMaS posted:

If you needed a customized UINavigationItem

Fair points. I've never needed to use static TableViews and do nav stuff programmatically.

101
Oct 15, 2012


Vault Dweller
Still pretty confused and intimidated by scroll views. Is there any good resource that'll finally make them click?

and are the new frame and content layout guides the way to go? Seen a few different resources that mention different ways to set them up

101
Oct 15, 2012


Vault Dweller

pokeyman posted:

Start with these WWDC videos (don't mind that they're a few years old):

https://developer.apple.com/videos/play/wwdc2011/104/
https://developer.apple.com/videos/play/wwdc2012/223/
https://developer.apple.com/videos/play/wwdc2013/217/

There was also one in 2014 but the video seems to have been disappeared? https://asciiwwdc.com/2014/sessions/235

And then yep, if you're using auto layout then the newish content guides are great. https://useyourloaf.com/blog/easier-scrolling-with-layout-guides/ is a good overview.

Thanks! I'll check them out when I get some time

101
Oct 15, 2012


Vault Dweller

frogbs posted:

I realize i'm just getting started with Swift, so everything is going to have a learning curve, but i'll be damned if I can't wrap my head around using Codable to parse even moderately complicated/nested JSON.

This can be a big help for creating your data models

lord funk posted:

Yeah good luck. I just went through this a few weeks ago, and was surprised at how difficult heterogenous arrays were to encode / decode.

Yeah I recently had to deal with an endpoint that spat out a bunch of different variations and it was a nightmare

101
Oct 15, 2012


Vault Dweller
Why new collection view over table view?

101
Oct 15, 2012


Vault Dweller
Made a few changes to make it build

Swift code:
class ParentVC: UIViewController {
	
	@objc func apiCall() {}
	
	func test() {
		
		let childVC = ChildVC(message: "Some text", action: apiCall)
		self.present(childVC, animated: true)
	}
}
Swift code:
class ChildVC: UIViewController {
	
	let message: String
	@objc let action: () -> Void
	
	let actionButton = UIButton()
	
	init(message: String, action: @escaping () -> Void) {
		
		self.message = message
		self.action = action
		
		super.init()
	}
	
	required init?(coder: NSCoder) {
		fatalError("init(coder:) has not been implemented")
	}
	
	override func viewDidLoad() {
		super.viewDidLoad()
		
		actionButton.addTarget(self, action: #selector(getter: action), for: .touchUpInside)
	}
}
Not sure if that'll work for you but hopefully it does.

101
Oct 15, 2012


Vault Dweller

pokeyman posted:

Either I've been missing out or that button action still won't do anything. Gotta make a method that calls the passed-in block.

Yeah I just quickly mocked it up with some xibs and you'll need something like

Swift code:
@objc func btnPressed() {
        
        action()
}
in the ChildVC

101
Oct 15, 2012


Vault Dweller

KidDynamite posted:

it's swiftui only though right?

It is not. There's a UIKit section in the GitHub readme, was just looking at it yesterday. Works like Combine from the looks of it.

I think most of all of their videos on it are SwiftUI focused though.

I'm interested in it, but I don't know about using something third party for the whole architecture of the app. Anyone here used it and got any thoughts?

101
Oct 15, 2012


Vault Dweller

Graniteman posted:

Sometimes I’ve found that there wasn’t a good way to do all that, and what I’ve done is made appData an optional inside myViewModel. Then, inside MyView, you can assign it using .onAppear (EnvironmentObjects exist within .onAppear closures). It makes MyViewModel ugly because you need to deal with the optional, but, it’s the only way I know to get something from an @EnvironmentObject into a new object inside a view.

Could you not safely do
code:
appData: AppData!
in the model there, and avoid having it be optional since it's always going to be initialised in onCreate?

101
Oct 15, 2012


Vault Dweller
I feel like I'm going crazy.

Every time I try SwiftUI, I hit some dumb but huge hurdle so quickly.

code:
List {
	
	ForEach(items, id: \.self) { item in
		
		Text(item)
	}
	.onDelete { indexSet in
		
		print("Delete")
	}
}
.onTapGesture {
	
	print("Tapped")
}
So, you have to use ForEach if you want onDelete, it doesn't just work on a List of items.

The tap gesture takes precedence over the onDelete so the onDelete almost never gets triggered or if it rarely does, it's at the same time as the tap gesture.

I've tried using swipeActions instead, both with a ForEach and just a List (they don't work on just a list) and the issue persists.

Am I missing something, or am I giving up on SwiftUI for another few years?

101
Oct 15, 2012


Vault Dweller

commie kong posted:

Hey, give this a try:

That seems to work, thanks. I did try something similar, but the Spacer turned out to be the secret sauce I was missing.

Also, just got an interview with a company whose apps are built 'entirely' in SwiftUI, so I guess I'd better keep tooling around with it.

I want to like it, but UIKit is like a warm blanket comparatively. Is this how people felt during the ObjC -> Swift transition?

101
Oct 15, 2012


Vault Dweller

101 posted:

I feel like I'm going crazy.

Every time I try SwiftUI, I hit some dumb but huge hurdle so quickly.

...

Am I missing something, or am I giving up on SwiftUI for another few years?

Welp, I got an offer I couldn't refuse from a company whose app is built entirely in SwiftUI. Guess I'm gonna have to get to grips with it.

101
Oct 15, 2012


Vault Dweller

pokeyman posted:

Congrats!

Also lol

Cheers. I'm stuck between lolling and nerves myself.

former glory posted:

I'm such a declarative UI convert after learning SwiftUI that this sounds like a nice scenario, congrats and good luck with the change. In my experience so far, once you get the UI to do what you need in 100% swift, it's rock solid and has far fewer unexpected cases. But it can be a bit of a fight at first.

Thanks.

I'm hoping I'm the same, since it's clearly the way iOS development is going. The app is built using a Redux/TCA type system, which I really like using when I've tooled around with it. It seems like the system that makes the most sense to my brain with declarative stuff.

It's also (embarrassingly) the first company I'll have worked for that cares about test coverage, and it actually looks like they'll actually be enjoyable to write with this approach. Always happy to have more tools in my belt.

101
Oct 15, 2012


Vault Dweller

Small White Dragon posted:

I need some GPU features that don't work on A8 (or earlier) chips. Not that I expect there are a ton of these still floating around in active use, but is there a way to specify that in Info.plist rather than just "Hey, this won't work if you have these models" in the App Store description?

A look at the Wikipedia page seems to suggest no devices on iOS 16 run A8s, so you could specify a minimum that way?

101
Oct 15, 2012


Vault Dweller
I somehow missed that Strings support Markdown now, and I'm in love

101
Oct 15, 2012


Vault Dweller
Mannnn… async await, TCA, and their swift-dependencies system are just so god-drat good.

I honestly don't think I'd enjoy SwiftUI 10x as much as I do if not for them.

Adbot
ADBOT LOVES YOU

101
Oct 15, 2012


Vault Dweller

Fate Accomplice posted:

anyone have experience using Pointfree's Swift Composable Architecture?

some teams around me are implementing it and I'm investigating what that'll mean for my codebase.

Yes. I have encouraged and assisted in moving both our teams iOS and macOS codebases over to it in the last year. I think it’s fantastic and has an excellent ecosystem of other niceties around it too (dependencies, navigation etc)

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