Post

Replies

Boosts

Views

Activity

Reply to Text Alignment in SwiftUI
Use a VStack to position your content below your heading... ...then add a Spacer, to force everything to the top. struct HomeScreen: View { var body: some View { VStack { HStack{ Text("Tasks") .font(.largeTitle) .fontWeight(.bold) .frame(maxWidth: .infinity, alignment: .leading) .padding() } // TODO: your content goes here... Text("content...") Spacer() /// forces content to top } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Looking for recommendation for s/w development machine
If you want your Mac to last for several years, and you take the longer view, then M-series chips are clearly the future. It seems likely that Apple (and other) software will become increasingly optimised for the M-series. I wouldn't consider any Intel Mac now. If you are pushed for cash, consider an Apple refurbished model? M-series chips have clear battery-life advantages. If you ever intend to use it unplugged, then that is a factor. If you're always plugged-in, then consider a Mac Mini instead.
Jun ’22
Reply to using and calling functions inside my view file
As the compiler says, you have put too much functionality into one View. Even if the code is legal, it's not good practice. Refactor, breaking up your functionality into smaller components. You have made it a bit hard to be more specific, as your sample code includes a lot of external/undefined objects and functionality. As a starting point, you could refactor the internal VStack and HStacks into separate Views. You could factor out the Button, like this: struct StoreFaveArtworkButtonView: View { let artwork: Artwork private func storeFaveArtwork(artwork: Artwork) { guard let uid = FirebaseManager.shared.auth.currentUser?.uid else { return } let artData = ["id": artwork.id, "uid": uid] as [String : Any] FirebaseManager.shared.firestore.collection("favourites") .document(uid).setData(artData) { err in if let err = err { print(err) return } print("Success") } } var body: some View { Button { storeFaveArtwork(artwork: artwork) } label: { HStack { Spacer() Text("Favourite") .foregroundColor(.white) .padding(.vertical, 10) .font(.system(size: 14, weight: .semibold)) Spacer() }.background(Color.blue) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to NSDateFormatter dealloc EXC_BAD_ACCESS
DateFormatter is now threadsafe, but creating one is quite expensive. You certainly shouldn't be creating one every time you call logToFile! So you might try using an extension, like this: extension DateFormatter { static let myFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS" formatter.timeZone = TimeZone(secondsFromGMT: TimeZone.current.secondsFromGMT()) formatter.locale = Locale(identifier: "en_US_POSIX") return formatter }() } (Give it a more meaningful name, of course) Then in your logToFile, you can use it like this: let localDate = DateFormatter.myFormatter.string(from: Date()) This will be more efficient, and should fix your issue.
Topic: App & System Services SubTopic: General Tags:
Jun ’22
Reply to How to align content of SwiftuUI ScrollView to top? (MacOS)
It looks like having both axes in your ScrollView is forcing the content to the center. Removing .horizontal sends it to the top. So as a possible fix (here's a minimal example), try: var body: some View { ScrollView(.horizontal, showsIndicators: true) { ScrollView(.vertical, showsIndicators: true) { ZStack { Text("content appears at top") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Allow developer access to only 1 app
On App Store Connect, under Users and Access: Having set the "Role" for a developer, you can set the "Apps" that they have access to. This can be: All Apps or one or more specific apps (which you can choose from a drop-down list) Of course, the Apple account itself, and the Account Holder role, should be under your control. For the "Developer" role, you may need to add additional permissions such as "Access to Certificates, Identifiers and Profiles", depending on how you manage the app. A full list of permissions for each role is shown, on tapping the role.
Jun ’22
Reply to Changing Views Bar
Try something like this, to get started: struct TabScreen: View { var body: some View { TabView() { Text("HomeScreen") .tabItem { Image(systemName: "house") Text("Home") } Text("NotificationsScreen") .tabItem { Image(systemName: "bell") Text("Notifications") } Text("ExploreScreen") .tabItem { Image(systemName: "binoculars") Text("Explore") } Text("ProfileScreen") .tabItem { Image(systemName: "person") Text("Profile") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22