{"id":19614817,"url":"https://github.com/leancloud/swift-sample-code","last_synced_at":"2025-04-28T02:30:45.987Z","repository":{"id":42423206,"uuid":"62189777","full_name":"leancloud/Swift-Sample-Code","owner":"leancloud","description":"Swift SDK 文档中的示例代码 。","archived":false,"fork":false,"pushed_at":"2016-06-30T15:40:47.000Z","size":368,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-05T05:03:43.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leancloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-29T02:40:47.000Z","updated_at":"2020-02-11T05:41:35.000Z","dependencies_parsed_at":"2022-09-23T16:11:02.581Z","dependency_job_id":null,"html_url":"https://github.com/leancloud/Swift-Sample-Code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2FSwift-Sample-Code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2FSwift-Sample-Code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2FSwift-Sample-Code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2FSwift-Sample-Code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leancloud","download_url":"https://codeload.github.com/leancloud/Swift-Sample-Code/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251237839,"owners_count":21557351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T10:53:53.871Z","updated_at":"2025-04-28T02:30:45.584Z","avatar_url":"https://github.com/leancloud.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LeanCloud Swift SDK 文档示例代码\n## 文档地址\n[Swift 数据存储开发指南](https://leancloud.cn/docs/leanstorage_guide-swift.html)\n\n## 功能\n当开发者阅读文档的代码片段，想要阅读更多关于执行代码片段使用的前置条件时，可以阅读本项目里面一一对应的代码片段的测试用例，这样可以方便开发者使用接口的时候有一个最佳实践的参考。\n\n## 贡献代码\n从文档中找到对应代码片段的 Test Case 的源代码，修改，然后发出 PR，主分支(master)会有 travis CI 的脚本自动运行单元测试，只有测试全都通过才可以被合并到主分支，而文档对应的地方也应该及时修改。\n\n## 代码示例\n\n```swift\n//\n//  LCObject#saveWithProperties.swift\n//  Swift-Sample-Code\n//\n//  Created by WuJun on 6/28/16.\n//  Copyright © 2016 leancloud. All rights reserved.\n//\n\nimport XCTest\nimport LeanCloud\n\nclass LCObject_saveWithProperties: BaseTestCase {\n    \n    func testSaveTodoWithPropeties() {\n        \n        await(\"Save Todo with properties\") { (exception) in\n            // className 参数对应控制台中的 Class Name\n            let todo = LCObject(className: \"Todo\")\n            todo.set(\"title\", value:\"工作\" as LCString)\n            todo.set(\"content\", object: \"每周工程师会议，周一下午2点\")\n            \n            todo.save { result in\n                XCTAssertTrue(result.isSuccess)\n                exception.fulfill()\n            }\n        }\n    }\n}\n\n```\n\n其中 `await(\"Save Todo with properties\") { (exception) in}` 标明是正在测试一个异步的接口，但是一定要在测试用例内部显示的调用一下 `exception.fulfill()`，否则一定会测试失败。\n\n## FAQ\nQ：SDK 更新会对当前项目产生影响么？\n\nA：会，目前 Swift SDK 每一次有新的 PR 被 merge 进主分支，都会发送一个 PR 到当前项目，这样也会触发 travis CI 进行自动化检测，测试结果没有通过，会及时通知文档维护人员进行查看，需要手动的去比对文档中的代码，这样可以避免过期方法或者接口更名对用户造成的困扰。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancloud%2Fswift-sample-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleancloud%2Fswift-sample-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancloud%2Fswift-sample-code/lists"}