{"id":18271490,"url":"https://github.com/petejkim/ConciseKit","last_synced_at":"2025-04-05T02:30:31.925Z","repository":{"id":712447,"uuid":"1117337","full_name":"petejkim/ConciseKit","owner":"petejkim","description":"A set of Objective-C additions and macros that helps you write code more quickly.","archived":false,"fork":false,"pushed_at":"2022-05-03T06:13:31.000Z","size":545,"stargazers_count":554,"open_issues_count":8,"forks_count":53,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-04T11:12:01.994Z","etag":null,"topics":[],"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/petejkim.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":"2010-11-27T17:50:30.000Z","updated_at":"2024-12-18T11:57:35.000Z","dependencies_parsed_at":"2022-08-08T06:00:01.731Z","dependency_job_id":null,"html_url":"https://github.com/petejkim/ConciseKit","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/petejkim%2FConciseKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petejkim%2FConciseKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petejkim%2FConciseKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petejkim%2FConciseKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petejkim","download_url":"https://codeload.github.com/petejkim/ConciseKit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166168,"owners_count":20894654,"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-05T11:39:20.297Z","updated_at":"2025-04-05T02:30:31.894Z","avatar_url":"https://github.com/petejkim.png","language":"Objective-C","readme":"# ConciseKit\n\nA set of Objective-C additions and macros that lets you to write code more quickly.\n\n## Pull requests are welcome!\n\n## USAGE\n\nUse [CocoaPods](https://github.com/CocoaPods/CocoaPods)\n\n```ruby\ndependency 'ConciseKit', '~\u003e 0.1.2'\n```\n\nor\n\n1. Copy files under `src/` to your project.\n\n```objective-c\n#import \"ConciseKit.h\"\n```\n\n## $ class\n\n### Method Swizzling\n\n        [$ swizzleMethod:@selector(foo) with:@selector(bar) in:[Foo class]]\n        [$ swizzleMethod:@selector(foo) in:[Foo class] with:@selector(bar) in:[Bar class]]\n\n        [$ swizzleClassMethod:@selector(foo) with:@selector(bar) in:[Foo class]]\n        [$ swizzleClassMethod:@selector(foo) in:[Foo class] with:@selector(bar) in:[Bar class]]\n\n### Path\n\n        [$ homePath]     =\u003e path to user's home directory\n        [$ desktopPath]  =\u003e path to user's desktop directory\n        [$ documentPath] =\u003e path to user's document directory\n        [$ appPath]      =\u003e path to app directory\n        [$ resourcePath] =\u003e path to app's resources directory\n\n### waitUntil\n\nUseful when writing tests for asynchronous tasks. Default timeout is 10 seconds, checking is done every 0.1 seconds.\n\n        [$ waitUntil:^{ return (BOOL)(someConditionIsMet == YES) }]\n        [$ waitUntil:^{ return (BOOL)(someConditionIsMet == YES) } timeOut:10.0]\n        [$ waitUntil:^{ return (BOOL)(someConditionIsMet == YES) } timeOut:10.0 interval:0.1]\n\n## Singleton\n\n### Creating Singletons\n\n        @interface Foo\n        - (id)initSingleton; // \u003c= add these to the interface\n        + (Foo *)sharedFoo;  // \u003c= where Foo is the class name\n        @end\n\n        @implementation Foo\n        $singleton(Foo);     // =\u003e makes Foo a singleton class\n\n        - (id)initSingleton {\n          foo = 1;           // do initialization in -initSingleton method\n          bar = 2;\n          return self;\n        }\n        @end\n\n### Using Singletons\n\n        $shared(Foo)         // =\u003e returns the shared instance\n        /* or */\n        [Foo sharedFoo]\n\n## Macros\n\n### General shorthands\n\n        $new(Foo)       =\u003e [[[Foo alloc] init] autorelease]\n        $eql(foo, bar)  =\u003e [foo isEqual:bar]\n        $safe(obj)      =\u003e (obj == [NSNull null] ? nil : obj)\n\n### NSArray shorthands\n\n        $arr(foo, bar)          =\u003e  [NSArray arrayWithObjects:foo, bar, nil]\n        $marr(foo, bar)         =\u003e  [NSMutableArray ...]\n        $marrnew or $marr(nil)  =\u003e  [NSMutableArray array]\n\n### NSSet shorthands\n\n        $set(foo, bar)          =\u003e  [NSSet setWithObjects:foo, bar, nil]\n        $mset(foo, bar)         =\u003e  [NSMutableSet ...]\n        $msetnew or $mset(nil)  =\u003e  [NSMutableSet set]\n\n### NSDictionary shorthands\n\n        $dict(v1, k1, v2, k2)     =\u003e  [NSDictionary dictionaryWithObjectsAndKeys:v1, k1, v2, k2, nil]\n        $mdict(v1, k1, v2, k2)    =\u003e  [NSMutableDictionary ...]\n        $mdictnew or $mdict(nil)  =\u003e  [NSMutableDictionary dictionary]\n\n### NSString shorthands\n\n        $str(@\"foo: %@\", bar)   =\u003e [NSString stringWithFormat:@\"foo: %@\", bar]\n        $mstr(@\"foo: %@\", bar)  =\u003e [NSMutableString ...]\n        $mstrnew or $mstr(nil)  =\u003e [NSMutableString string]\n\n### NSNumber shorthands\n\n        $bool(YES)    =\u003e [NSNumber numberWithBool:YES]\n        $int(123)     =\u003e [NSNumber numberWithInt:123]\n        $float(123.4) =\u003e [NSNumber numberWithFloat:123.4]\n\n        $char(), $double(), $integer(), $long(), $longlong(), $short(),\n        $uchar(), $uint(), $uinteger(), $ulong(), $ulonglong(), $ushort()\n\n### NSValue shorthands\n        $nonretained(), $pointer(), $point(), $range(), $rect(), $size()\n\n## Additions\n\n### NSArray\n\n        [array $first] =\u003e [array objectAtIndex:0]\n        [array $last]  =\u003e [array lastObject]\n        [array $at:1]  =\u003e [array objectAtIndex:1]\n\n        [array $each:^(id obj) {\n          NSLog(@\"%@\", obj);\n        }]\n\n        [array $eachWithIndex:^(id obj, NSUInteger i) {\n          NSLog(@\"%d %@\", i, obj);\n        }]\n\n        [array $eachWithStop:^(id obj, BOOL *stop) {\n          NSLog(@\"%@\", obj);\n          if($eql(obj, @\"foo\")) {\n            *stop = YES;\n          }\n        }]\n\n        [array $eachWithIndexAndStop:^(id obj, NSUInteger i, BOOL *stop) {\n          NSLog(@\"%d %@\", i, obj);\n          if(i == 1) {\n            *stop = YES;\n          }\n        }]\n\n        [array $map:^(id obj) {\n          return $integer([obj integerValue] * 2);\n        }]\n\n        [array $mapWithIndex:^(id obj, NSUInteger i) {\n          return $integer([obj integerValue] * 2 + i);\n        }]\n\n        [array $reduce:^(id obj) {\n          return $integer([obj integerValue] * 2);\n        }]\n\n        [array $reduce:^(NSNumber *memo, NSNumber *obj) {\n          return $integer([memo integerValue] + [obj integerValue]);\n        }]\n\n        [array $reduceStartingAt:$integer(1) with:^(NSNumber *memo, NSNumber *obj) {\n          return $integer([memo integerValue] * [obj integerValue]);\n        }]\n\n        [array $select:^BOOL(NSNumber *obj) {\n          return ([obj integerValue] % 2) == 0;\n        }]\n\n        [array $detect:^BOOL(NSNumber *obj) {\n          return ([obj integerValue] % 2) == 1;\n        }]\n\n        [array $join]      =\u003e [self componentsJoinedByString:@\"\"]\n        [array $join:@\",\"] =\u003e [self componentsJoinedByString:@\",\"]\n\n### NSMutableArray\n\n        [array $push:foo]    =\u003e [array addObject:foo]              (+ returns self)\n        [array $pop]         =\u003e [array removeLastObject]           (+ returns lastObject)\n        [array $unshift:foo] =\u003e [array insertObject:foo atIndex:0] (+ returns self)\n        [array $shift]       =\u003e [array removeObjectAtIndex:0]      (+ returns first object)\n\n### NSDictionary\n\n        [dict $for:@\"foo\"] =\u003e [dict objectForKey:@\"foo\"]\n        [dict $keys]       =\u003e [dict allKeys]\n        [dict $values]     =\u003e [dict allValues]\n\n        [dict $each:^(id key, id value) {\n            NSLog(@\"%@ =\u003e %@\", key, value);\n        }\n\n        [dict $eachWithStop:^(id key, id value, BOOL *stop) {\n            NSLog(@\"%@ =\u003e %@\", key, value);\n            if($eql(key, @\"foo\")) {\n                *stop = YES;\n            }\n        }]\n\n        [dict $eachKey:^(id key) {\n            NSLog(@\"%@\", key);\n        }]\n\n        [dict $eachValue:^(id value) {\n            NSLog(@\"%@\", value);\n        }]\n\n### NSMutableDictionary\n\n        [dict $obj:@\"bar\" for:@\"foo\"] =\u003e [dict setObject:@\"bar\" forKey:@\"foo\"] (+ returns self)\n\n### NSString\n\n        [string $append:@\"foo\"]  =\u003e [string stringByAppendString:@\"foo\"]\n        [string $prepend:@\"foo\"] =\u003e [NSString stringWithFormat:@\"%@%@\", @\"foo\", string]\n        [string $split:@\",\"]     =\u003e [string componentsSeparatedByString:@\",\"]\n        [string $split]          =\u003e [string componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]\n\n### NSMutableString\n\n        [string $append_:@\"foo\"]     =\u003e [string appendString:@\"foo\"]           (+ returns self)\n        [string $prepend_:@\"foo\"]    =\u003e [string insertString:@\"foo\" atIndex:0] (+ returns self)\n        [string $insert:@\"foo\" at:1] =\u003e [string insertString:@\"foo\" atIndex:1] (+ returns self)\n        [string $set:@\"foo\"]         =\u003e [string setString:@\"foo\"]              (+ returns self)\n\n## Contributors\n\n* [nolanw](http://github.com/nolanw)\n* [listrophy](https://github.com/listrophy)\n* [gerry3](https://github.com/gerry3) @ [Inigral](https://github.com/inigral)\n\n## License\n\nCopyright (c) 2010-2012 Peter Jihoon Kim and contributors. This code is licensed under the [MIT License](http://github.com/petejkim/ConciseKit/raw/master/LICENSE).\n","funding_links":[],"categories":["etc"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetejkim%2FConciseKit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetejkim%2FConciseKit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetejkim%2FConciseKit/lists"}