{"id":16482779,"url":"https://github.com/shaps80/spxdefines","last_synced_at":"2025-07-25T12:39:53.006Z","repository":{"id":15263021,"uuid":"17992154","full_name":"shaps80/SPXDefines","owner":"shaps80","description":"Assertion handling for Objective-C","archived":false,"fork":false,"pushed_at":"2015-05-24T16:57:23.000Z","size":433,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-11T14:21:33.929Z","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":"Khan/aphrodite","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shaps80.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-21T19:45:06.000Z","updated_at":"2015-04-20T16:33:50.000Z","dependencies_parsed_at":"2022-09-05T13:41:20.300Z","dependency_job_id":null,"html_url":"https://github.com/shaps80/SPXDefines","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FSPXDefines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FSPXDefines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FSPXDefines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaps80%2FSPXDefines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaps80","download_url":"https://codeload.github.com/shaps80/SPXDefines/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241214483,"owners_count":19928323,"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-11T13:12:01.234Z","updated_at":"2025-02-28T19:42:35.440Z","avatar_url":"https://github.com/shaps80.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Purpose\n--------------\n\nUseful macro's for Objective-C projects.\n\n\nSupported OS \u0026 SDK Versions\n-----------------------------\n\n* Supported build target - iOS 7.1\n* Earliest supported deployment target - iOS 2.0\n\n\nARC Compatibility\n------------------\n\nThe SPXDefines macro's will work correctly with or without ARC enabled.\n\n\nInstallation\n--------------\n\nTo use the SPXDefines in an app, just drag the files into your project and import the header file into any class where you wish to make use of the SPXDefines functionality.\n\nIf you're using PODs, simply include it in your Podfile: `pod 'SPXDefines'`\n\nMacro's\n-------------\n\n**Description Overrides**\n\nWhen building custom classes its often good practice to override -description to provide other developers better output in the console. To make this easier and get better type safety you can use my new description methods.\n\n```objc\n- (NSString *)description\n{\n  return SPXDescription(SPXKeyPath(name), SPXKeyPath(age));\n}\n```\n\nWhich expands to:\n\n```objc\n- (NSString *)description\n{\n  return [super.description stringByAppendingFormat:@\"%@\", [self dictionaryWithValuesForKeys:@[ @\"name\", @\"age\" ].description];\n}\n```\n\n_Note: This method only supports properties or methods since internally it uses KVO on self._\n \n**SPXAssertionDefines**\n\nProvides better assertion handling in an iOS project. It will NEVER crash in a RELEASE build, but will assert and break on the offending line of code in DEBUG builds. There are equivalent `SPXCAssertTrueOr...` methods for usage inside C functions.\n\nThe following code will assert 'condition', if it fails, write the assertion to the console and break on the offending line of code. In a release build it will simply return.\n\n```objc\nSPXAssertTrueOrReturnNo(condition);\nSPXAssertTrueOrReturnNil(condition);\nSPXAssertTrueOrReturnError(condition);\nSPXAssertTrueOrReturn(condition);\n```\n\nThe following code will also assert 'condition', but instead of returning, it will perform the specified action.\n\t\t\n`SPXAssertTrueOrPerformAction(condition, NSLog(@\"Help!\"));`\n\n\n**SPXEncodingDefines**\n\nThe following code will encode or decode variables using NSCoding. It uses `SPXEncode()` and `SPXDecode()` which expand to `[aEncoder encodeObject:name forKey:@\"name\"]` and `[aDecoder decodeObjectForKey:@\"name\"]` respectively. If you prefer to provide a custom encoder, decoder, you can use the SPXEncodeE and SPXDecodeE equivalents.\n\t\n```objc\n@property (nonatomic, copy) NSString *name;\n@property (nonatomic, copy) NSInteger age;\n\n...\n\n- (instancetype)initWithCoder:(NSCoder *)aDecoder\n{\n  self = [super init];\n  if (!self) return nil;\n  \n  decode(name);\t\n  decode(age);\n\t\n  return self;\n} \n\n- (void)encodeWithCoder:(NSCoder *)aCoder\n{\n  encode(name);\n  encode(age);\t\n}\n\t\n```\n\n\n**SPXLoggingDefines**\n\nThe following methods will first look for CocoaLumberjack and if it exists, use that for logging. If not it will fall back to NSLog but with much improved logging ;)\n\nThe pretty format\n\n`YYYY-MM-DD HH:MM:SS | LINE # | CLASS | SELECTOR | MESSAGE`\n\nExample\n\n`2014-03-21 14:31:22 | 23 | AppDelegate | applicationDidFinishLaunchingWithOptions: | Hello World!`\n\n```objc\nlogMethod; // simply logs the current class and selector\nSPXLog(@\"Hello World!\");\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Fspxdefines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaps80%2Fspxdefines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaps80%2Fspxdefines/lists"}