{"id":22691876,"url":"https://github.com/cmst0us/nsobjectsignals","last_synced_at":"2026-05-05T05:35:15.819Z","repository":{"id":162874554,"uuid":"183374252","full_name":"CmST0us/NSObjectSignals","owner":"CmST0us","description":"Qt信号/槽机制在Objective-C上的实现。","archived":false,"fork":false,"pushed_at":"2019-08-31T19:01:27.000Z","size":33,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T17:52:13.608Z","etag":null,"topics":["kvo","nsobject","objective-c","qt","signals","slots"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","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/CmST0us.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-25T06:51:37.000Z","updated_at":"2021-07-23T20:39:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"9d198370-68f7-45ff-98ac-cd4eefebf6bc","html_url":"https://github.com/CmST0us/NSObjectSignals","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/CmST0us%2FNSObjectSignals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CmST0us%2FNSObjectSignals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CmST0us%2FNSObjectSignals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CmST0us%2FNSObjectSignals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CmST0us","download_url":"https://codeload.github.com/CmST0us/NSObjectSignals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246215817,"owners_count":20741894,"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":["kvo","nsobject","objective-c","qt","signals","slots"],"created_at":"2024-12-10T01:12:46.247Z","updated_at":"2026-05-05T05:35:15.793Z","avatar_url":"https://github.com/CmST0us.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NSObjectSignals\n\nQt信号/槽机制在Objective-C上的实现。\n\n## 导入工程\n1. 为你的工程使用Xcode Workspace，并添加你的工程与本工程`NSObjectSignals/NSObjectSignals.xcodeproj`\n2. 在你的工程`Embedded Binaries`配置下添加本工程的framework\n3. `#import \u003cNSObjectSignals/NSObject+SignalsSlots.h\u003e`\n\n## 使用\n\n和Qt下信号槽操作类似，首先为类声明信号\n\n``` Objective-C\n- (NS_SIGNAL)clickView;\n```\n\n再声明，并实现监听此信号的槽函数\n\n```Objective-C\n// xxx.h\n- (NS_SLOT)onClickView;\n\n// xxx.m\n- (NS_SLOT)onClickView {\n    NSLog(@\"View clicked;\");\n}\n```\n\n然后连接信号与槽\n\n```Objective-C\n[self connectSignal:@selector(clickView) forObserver:observer slot:@selector(onClickView)];\n```\n\n触发信号的方式和Qt有些许差别\n```Objective-C\n[self emitSignal:@selector(clickView) withParams:nil];\n```\n\n## 其他说明\n\n- 非线程安全，如果需要线程安全需求，可使用`dispatch_queue`操作。\n- 信号声明后，不需要实现。可以使用`NS_CLOSE_SIGNAL_WARN()`宏关闭未实现警告\n- 连接同时支持block方法，使用方法见Demo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmst0us%2Fnsobjectsignals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmst0us%2Fnsobjectsignals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmst0us%2Fnsobjectsignals/lists"}