{"id":1026,"url":"https://github.com/tarunon/AnyObjectConvertible","last_synced_at":"2025-07-30T20:30:45.852Z","repository":{"id":56902080,"uuid":"50495972","full_name":"tarunon/AnyObjectConvertible","owner":"tarunon","description":"Convert your own struct/enum to AnyObject easily.","archived":true,"fork":false,"pushed_at":"2016-09-16T16:21:17.000Z","size":18,"stargazers_count":61,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T16:04:49.211Z","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/tarunon.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-01-27T09:20:27.000Z","updated_at":"2024-03-04T04:10:51.000Z","dependencies_parsed_at":"2022-08-20T18:50:30.656Z","dependency_job_id":null,"html_url":"https://github.com/tarunon/AnyObjectConvertible","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunon%2FAnyObjectConvertible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunon%2FAnyObjectConvertible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunon%2FAnyObjectConvertible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tarunon%2FAnyObjectConvertible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tarunon","download_url":"https://codeload.github.com/tarunon/AnyObjectConvertible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228179111,"owners_count":17881135,"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-01-05T20:15:37.334Z","updated_at":"2024-12-04T19:32:35.326Z","avatar_url":"https://github.com/tarunon.png","language":"Swift","funding_links":[],"categories":["Data Structures / Algorithms"],"sub_categories":["Getting Started","Other free courses","Linter"],"readme":"# AnyObjectConvertible\n[![Build Status](https://travis-ci.org/tarunon/AnyObjectConvertible.svg?branch=master)](https://travis-ci.org/tarunon/AnyObjectConvertible)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![CocoaPods compatible](https://img.shields.io/cocoapods/v/AnyObjectConvertible.svg?style=flat)](https://cocoapods.org/pods/AnyObjectConvertible)\n\nConvert your own struct/enum to AnyObject easily.\n\n## Sumally \n\n\u003cb\u003e We can cast everything as AnyObject at Swift3.0 🎉 \u003c/b\u003e \u003cbr\u003e\n\u003cb\u003e So, we would not need this library no longer \u003c/b\u003e\n\n\n\nIn swift, struct or enum cannot convert to AnyObject\n```swift\nNSNotificationCenter.defaultCenter().postNotificationName(\"foo\", object: YourOwnStruct()) // Fail\n```\nOf course, you may wrap value using Box\\\u003cT\\\u003e.\n```swift\nclass Box\u003cT\u003e {\n  let value: T\n  init(value: T) {\n    self.value = value\n  }\n}\nNSNotificationCenter.defaultCenter().postNotificationName(\"foo\", object: Box(value: YourOwnStruct())) // OK\n```\n\nBut Box\\\u003cT\\\u003e unwrap is too lazy.\n```swift\nlet value = (notification.object as? Box\u003cYourOwnStruct\u003e)?.value\n```\n\nYou can cast your struct/enum directory if implement AnyObjectConvertible at that type.\n```swift\nextension YourOwnStruct: AnyObjectConvertible {}\n\nNSNotificationCenter.defaultCenter().postNotificationName(\"foo\", object: YourOwnStruct()) // OK\nlet value = notification.object as? YourOwnStruct\n```\n\n## Installation\n#### CocoaPods\nYou can use [CocoaPods](http://cocoapods.org/) to install `AnyObjectConvertible` by adding it to your `Podfile`:\n\n```ruby\nplatform :ios, '8.0'\nuse_frameworks!\npod 'AnyObjectConvertible'\n```\n\nTo get the full benefits import `AnyObjectConvertible` wherever you import UIKit\n\n``` swift\nimport UIKit\nimport AnyObjectConvertible\n```\n#### Carthage\nCreate a `Cartfile` that lists the framework and run `carthage bootstrap`. Follow the [instructions](https://github.com/Carthage/Carthage#if-youre-building-for-ios) to add `$(SRCROOT)/Carthage/Build/iOS/YourLibrary.framework` to an iOS project.\n\n```\ngithub \"tarunon/AnyObjectConvertible\"\n```\n#### Manually\n1. Download and drop ```AnyObjectConvertible.swift``` in your project.  \n2. Congratulations!  \n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunon%2FAnyObjectConvertible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftarunon%2FAnyObjectConvertible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftarunon%2FAnyObjectConvertible/lists"}