Hi! I'm new to Apple developing. Could anyone please tell me how to configure a quick look for my document? Also, how to print my document? Thanks🙏
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm tired of opening up safari to open developer.apple.com so I'm trying to embed the website into an app, but sth is definitely wrong. It's been loading for ten mins and is still white. here's the code
import SwiftUI
import WebKit
import UIKit
struct WebViewPage : UIViewRepresentable {
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
let req = URLRequest(url: URL(string:"developer.apple.com")!)
uiView.load(req)
}
}
#if DEBUG
struct WebViewPage_Previews : PreviewProvider {
static var previews: some View {
WebViewPage()
}
}
#endif
app delegate:
import SwiftUI
@main
struct Developer_WebpageApp: App {
var body: some Scene {
WindowGroup {
WebViewPage()
}
}
}
I'm trying to make an app that'll suggest a color based on a keyword the user inputs. I store prediction from the model to a [String: Double] array and then compute the output color. However, I'm stuck on two strange errors.
Here's my code:
extension Array where Element == [String: Double]{
func average() -> RGBList{
var returnValue = (r: 0, g: 0, b: 0)
var r = 0
var g = 0
var b = 0
for key in self{
r = Int(key[0].split(",")[0]) * key[1]
...
}
...
}
}
How can I store a struct in @AppStorage?
I've been trying
struct TodoItem: Codable, Hashable, Identifiable {
var id: UUID = UUID()
var name: String = "New Todo"
var description: String = "Description here..."
var done: Bool
}
@AppStorage("todo") var todo: [TodoItem] = [] // No exact matches in call to initializer
Any help is appreciated🙏🙏
I'm doing a app that needs a toolbar but it wont come out:
ContentView()
.toolbar {
ToolbarItem {
Button {
data.data.append(TodoItem())
} label: {
Image(systemName: "plus")
}
}
}
I'm using SwiftUI on Mac Catalyst:
@main
struct TodoApp: App {
@StateObject private var eventData = TodoData()
var body: some Scene {
WindowGroup {
ContentView().environmentObject(eventData)
}
#if os(macOS)
Settings{
TodoSettings()
}
#endif
}
}
I'm trying to follow the Date Planner tutorial and the symbol picker went really weird.
I changed sth, and the whole app stoped working
I changed it back, it still wont work.
SymbolPicker code:
struct PickerView: View {
@State var item: TodoItem
@State private var showingPopover: Bool = false
var columns = Array(repeating: GridItem(.flexible()), count: 6)
var body: some View {
LazyVGrid(columns: columns){
ForEach(SymbolOptions.symbolNames, id: \.self){ symbol in
Button {
item.symbol = symbol
} label: {
Image(systemName: symbol).foregroundColor(item.color)
}
}
}
}
}
I can now how define part of the about page but how about the whole?
Thanks
better in swiftUI
Still about appstorage
Can a store a @StateObject in @AppStorage?
I can't do this:
@AppStorage("Data") // No exact matches in call to initializer
@StateObject private var Data = TodoData()
I want to include a button that could export some data but I'm stuck:
I want a NSSavePanel open up and when I choose the pass and click save the JSON file will appear but it didn't.
code:
Button {
let export = exportToJSON(toExported(data.data))
let openPanel = NSSavePanel()
openPanel.message = "Choose the exported path:"
openPanel.begin { response in
if response == .OK {
print("\(openPanel.url!)")
url = openPanel.url!
let fileManager = FileManager()
let success = fileManager.createFile(atPath: "\(url)", contents: export)
debugPrint(success)
}
}
} label: {
Image(systemName: "square.and.arrow.down")
}.padding().buttonStyle(.plain)
console:
file:///Users/xxx/Documents/Untitled
false
My iPhone SE 1st will be stuck every 30 secs or so
I think it's sth because it's a second-handed one
I've used Instruments but can't find anything
Anyone HELP
Thanks🙏
I'm trying to add a quick look preview extension to my app.
But
I can't find any reference on this
On a earlier thread (https://developer.apple.com/forums/thread/704155)
everyone seems to misunderstand my question.
I MEAN THE QUICK LOOK YOU CAN TOGGLE IN FINDER THAT WILL SHOW YOU A PREVIEW OF A DOCUEMNT
I don't want to add the tag QuickLook because that's not I want to do.
How could I create an icon with an alpha/beta/dev badge?
like this⬇️
How can I make it work?
jsonString = """
["foo", "bar"]
"""
let decoder = JSONDecoder
var whatIWant = decoder.decode(Array<String>.self, jsonString)
for i in whatIWant {
print(i)
}
EDIT:
Minor syntax mistake ignore this thread sorry everyone
OK after I'm done with my last issue I came across some weird UI layout
this is really a serious issue because afterward it looks like this😂
why?
I've never met this kind of issue before in my same code before upgrading to Ventura
code:
List {
...
Section {
ForEach(data) { datum in
TableRow(data: datum)
.swipeActions {
Button(role: .destructive) {
data.delete(datum)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
}
...
}