Skip to content

Commit

Permalink
!
Browse files Browse the repository at this point in the history
  • Loading branch information
iapplus committed Sep 28, 2021
1 parent dc6aab9 commit 993b819
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 12 deletions.
22 changes: 18 additions & 4 deletions test.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
E87A234826E75DCF00F7BB35 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E87A238B26E7F44E00F7BB35 /* request.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = request.swift; sourceTree = "<group>"; };
E87A238E26E7F6CB00F7BB35 /* HttpBinGet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HttpBinGet.swift; sourceTree = "<group>"; };
E8E0E4B227009E79002E2095 /* test.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = test.entitlements; sourceTree = "<group>"; };
E8F9847427008ED600B7B4D8 /* SwiftUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -70,6 +71,7 @@
E87A233E26E75DCE00F7BB35 /* test */ = {
isa = PBXGroup;
children = (
E8E0E4B227009E79002E2095 /* test.entitlements */,
E80C9AC626FCFAE2002E4F3C /* MyStoryBoard.storyboard */,
E87A238D26E7F6AE00F7BB35 /* model */,
E87A238A26E7F43700F7BB35 /* utils */,
Expand Down Expand Up @@ -319,6 +321,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = test/test.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"test/Preview Content\"";
DEVELOPMENT_TEAM = BBJZY9C346;
Expand All @@ -329,10 +334,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = iapplus.test;
PRODUCT_BUNDLE_IDENTIFIER = com.iapplus.test;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Debug;
};
Expand All @@ -341,6 +349,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = test/test.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_ASSET_PATHS = "\"test/Preview Content\"";
DEVELOPMENT_TEAM = BBJZY9C346;
Expand All @@ -351,10 +362,13 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = iapplus.test;
PRODUCT_BUNDLE_IDENTIFIER = com.iapplus.test;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SUPPORTS_MACCATALYST = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = "1,2,6";
};
name = Release;
};
Expand Down
Binary file not shown.
20 changes: 20 additions & 0 deletions test/Home2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ struct Home2:View {
Spacer(minLength: 100)
Button(ip) {
print("网络请求")

let json = """
{
"name": "Durian"
}
""".data(using: .utf8)!



if let decodedResponse = try? JSONDecoder().decode(Person.self, from: json){
print(decodedResponse.name)
}
Task{
let rrr = Request()
await rrr.test()
}
Request.get(url: "https://httpbin.org/get") { data in
let decoder = JSONDecoder()

Expand Down Expand Up @@ -105,3 +121,7 @@ struct Home2:View {
})
}
}

struct Person:Codable{
let name: String
}
20 changes: 20 additions & 0 deletions test/Home3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ struct Home3:View {
@State private var isShow:Bool = true
@State private var isNetwork:Bool = false

@ObservedObject var td = TestData()

var body: some View {

VStack {
ForEach(td.data,id:\.self){ d in
Text(d)
}

Button("点击") {
td.data.append("ok")
}
if isNetwork {
List(contacts) { contact in
HStack {
Expand Down Expand Up @@ -83,6 +92,7 @@ struct Home3:View {
}
}.padding()
}.onAppear {
print("网络请求---")

Request.get(url: "https://httpbin.org/get") { data in
let decoder = JSONDecoder()
Expand All @@ -98,3 +108,13 @@ struct Home3:View {
}
}
}

//Note 这个WindowGroup的onChange方法率先执行

class TestData:ObservableObject{
@Published var data:[String]
init() {
data = ["a","b","c"]
print("TestData初始化一次")
}
}
5 changes: 5 additions & 0 deletions test/test.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
8 changes: 0 additions & 8 deletions test/testApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,3 @@ struct testApp: App {
}
}



class AppDelegate:NSObject,UIApplicationDelegate{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

return true
}
}
12 changes: 12 additions & 0 deletions test/utils/request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ class Request {
}
}.resume()
}

//异步函数的使用
func listPhotos(inGallery name: String) async -> String {
let result = "哈哈"
print("执行了")
return result
}

func test() async{
let name = await listPhotos(inGallery: "okokok")
print("执行了\(name)")
}
}

0 comments on commit 993b819

Please sign in to comment.