{"id":16886675,"url":"https://github.com/alisoftware/ohactionsheet","last_synced_at":"2025-09-21T12:32:37.682Z","repository":{"id":9959505,"uuid":"11981280","full_name":"AliSoftware/OHActionSheet","owner":"AliSoftware","description":"UIActionSheet subclass that uses blocks to handle its callback (which make the code much more easier and readable)","archived":false,"fork":false,"pushed_at":"2014-07-22T19:23:03.000Z","size":388,"stargazers_count":27,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-29T01:15:48.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/AliSoftware.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":"2013-08-08T16:44:21.000Z","updated_at":"2017-10-18T02:16:08.000Z","dependencies_parsed_at":"2022-08-31T13:24:06.704Z","dependency_job_id":null,"html_url":"https://github.com/AliSoftware/OHActionSheet","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FOHActionSheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FOHActionSheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FOHActionSheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AliSoftware%2FOHActionSheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AliSoftware","download_url":"https://codeload.github.com/AliSoftware/OHActionSheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233753246,"owners_count":18724821,"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-10-13T16:40:41.475Z","updated_at":"2025-09-21T12:32:37.344Z","avatar_url":"https://github.com/AliSoftware.png","language":"Objective-C","readme":"## About this class\n\nThis class make it easier to use `UIActionSheet` with blocks.\n\nThis allows you to provide directly the code to execute (as a block) in return to the tap on a button,\ninstead of declaring a delegate and implementing the corresponding methods.\n\nThis also has the huge advantage of **simplifying the code especially when using multiple `UIActionSheets`** in the same object (as in such case, it is not easy to have a clean code if you share the same delegate)\n\n_Note: You may also be interested in [OHAlertView](https://github.com/AliSoftware/OHAlertView)_\n\n## Usage Example\n\n    NSArray* flavours = [NSArray arrayWithObjects:@\"chocolate\",@\"vanilla\",@\"strawberry\",nil];\n\t\n\t[OHActionSheet showSheetInView:self.window\n\t\t\t\t\t\t\t   title:@\"Ice cream?\"\n\t\t\t\t   cancelButtonTitle:@\"Maybe later\"\n\t\t\t  destructiveButtonTitle:@\"No thanks!\"\n\t\t\t\t   otherButtonTitles:flavours\n\t\t\t\t\t\t  completion:^(OHActionSheet *sheet, NSInteger buttonIndex)\n\t {\n\t\t NSLog(@\"button tapped: %d\",buttonIndex);\n\t\t if (buttonIndex == sheet.cancelButtonIndex) {\n\t\t\t self.status.text = @\"Your order has been postponed\";\n\t\t } else if (buttonIndex == sheet.destructiveButtonIndex) {\n\t\t\t self.status.text = @\"Your order has been cancelled\";\n\t\t } else {\n\t\t\t NSString* flavour = [flavours objectAtIndex:(buttonIndex-sheet.firstOtherButtonIndex)];\n\t\t\t self.status.text = [NSString stringWithFormat:@\"You ordered a %@ ice cream.\",flavour];\n\t\t }\n\t }];\n     \n## ActionSheets with timeout\n\nYou can also use this class to generate an ActionSheet that will be dismissed after a given time.\n_(You can even add a dynamic text on your sheet to display the live countdown)_\n\n    NSArray* flavours = [NSArray arrayWithObjects:@\"apple\",@\"pear\",@\"banana\",nil];\n\n\t[[[OHActionSheet alloc] initWithTitle:@\"What's your favorite fruit?\"\n                 cancelButtonTitle:@\"Don't care\"\n            destructiveButtonTitle:nil\n                 otherButtonTitles:flavours\n                        completion:^(OHActionSheet *sheet, NSInteger buttonIndex)\n\t {\n\t\t NSLog(@\"button tapped: %d\",buttonIndex);\n\t\t if (buttonIndex == sheet.cancelButtonIndex) {\n\t\t\t self.status.text = @\"You didn't answer the question\";\n\t\t } else if (buttonIndex == -1) {\n\t\t\t self.status.text = @\"The action sheet timed out\";\n\t\t } else {\n\t\t\t NSString* fruit = [flavours objectAtIndex:(buttonIndex-sheet.firstOtherButtonIndex)];\n\t\t\t self.status.text = [NSString stringWithFormat:@\"Your favorite fruit is %@.\",fruit];\n\t\t }\n\t }] showInView:self.window withTimeout:8 timeoutButtonIndex:-1];\n\n## Compatibility Notes\n\n* This class uses blocks, which is a feature introduced in iOS 4.0.\n* This class is compatible with both ARC and non-ARC projects.\n\n## License\n\nThis code is under MIT License.\n\n## CocoaPods\n\nThis class is referenced in CocoaPods, so you can simply add `pod OHActionSheet` to your Podfile to add it to your pods.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisoftware%2Fohactionsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisoftware%2Fohactionsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisoftware%2Fohactionsheet/lists"}