All Projects → youknowone → Foundationextension

youknowone / Foundationextension

Licence: other
Foundation/Cocoa/UIKit extension kit. Reference document:

Projects that are alternatives of or similar to Foundationextension

Vscode Matlab
MATLAB support for Visual Studio Code
Stars: ✭ 114 (-0.87%)
Mutual labels:  snippets, extension
Coffeescript Sublime Plugin
Syntax highlighting and checking, commands, shortcuts, snippets, compilation and more.
Stars: ✭ 296 (+157.39%)
Mutual labels:  shortcuts, snippets
vscode-odoo-snippets
Develop Odoo modules faster and with no Typing Errors.
Stars: ✭ 20 (-82.61%)
Mutual labels:  snippets, extension
Vscode Vlang
V Language extension for Visual Studio Code.
Stars: ✭ 190 (+65.22%)
Mutual labels:  snippets, extension
Snipsnap
The ultimate snippets collection for VS Code
Stars: ✭ 840 (+630.43%)
Mutual labels:  snippets, extension
vscode-react-javascript-snippets
Extension for React/Javascript snippets with search supporting ES7+ and babel features
Stars: ✭ 782 (+580%)
Mutual labels:  snippets, extension
Faceaware
An extension that gives UIImageView the ability to focus on faces within an image.
Stars: ✭ 3,004 (+2512.17%)
Mutual labels:  extension, cocoapods
VscOdooSnippets
Odoo Snippets for Visual Studio Code
Stars: ✭ 29 (-74.78%)
Mutual labels:  snippets, extension
Vs Freemarker
FreeMarker language colorization extension for Visual Studio Code
Stars: ✭ 17 (-85.22%)
Mutual labels:  snippets, extension
Gata
Bookmarks made better
Stars: ✭ 17 (-85.22%)
Mutual labels:  shortcuts, extension
Ezswiftextensions
😏 How Swift standard types and classes were supposed to work.
Stars: ✭ 2,911 (+2431.3%)
Mutual labels:  extension, cocoapods
Css3colorsswift
A UIColor extension with CSS3 Color names.
Stars: ✭ 62 (-46.09%)
Mutual labels:  snippets, cocoapods
Vscode Es7 Javascript React Snippets
Extension for Javascript/React snippets with search supporting ES7 and babel features
Stars: ✭ 435 (+278.26%)
Mutual labels:  snippets, extension
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-73.04%)
Mutual labels:  extension, cocoapods
Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (+958.26%)
Mutual labels:  shortcuts, snippets
Shari
Shari is the alternative to the library of UIPickerView(drum roll) in Swift. You can select a item using UITableView.
Stars: ✭ 111 (-3.48%)
Mutual labels:  cocoapods
Uilabel Copyable
A simple category to add copy functionality to UILabel.
Stars: ✭ 113 (-1.74%)
Mutual labels:  cocoapods
Rose
Simple PHP search engine that supports Russian and English morphology
Stars: ✭ 111 (-3.48%)
Mutual labels:  snippets
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (+1206.96%)
Mutual labels:  cocoapods
Custom Calendar View
The CustomCalendarView provides an easy and customizable calendar to create a Calendar. It dispaly the days of a month in a grid layout and allows to navigate between months
Stars: ✭ 113 (-1.74%)
Mutual labels:  snippets

@mainpage FoundationExtension

Build Status

This library includes small Cocoa/UIKit extensions. This library does not includes high-level data structure, algorithm or frameworks, but collection of code snippets.

  • Many common snippets in a method call.
  • Looks like native foundation methods - It follows Apple Coding Guideline and Foundation naming convention.

See document on [Github] (http://youknowone.github.com/FoundationExtension)

How to use

  • Compiled library
    1. Build project
    2. Add FoundationExtension or UIKitExtension target as dependency
  • Directy source
    1. Add files what you need to your project
  • CocoaPod ~> 1.7.5
    1. Visit and follow http://cocoapods.org/

If your compiler is gcc or old clang, add '-force_load' to static library.

Download for editing

git clone git://github.com/youknowone/FoundationExtension.git
cd FoundationExtension
git submodule update --init

Why useful

Make your code short! Do not allow evil objc to make your code verbose. This library includes many shortcuts for common work.

NSData from URL

Foundation

NSString *URLString = [NSSring stringWithFormat:@"http://"HOST_URL"/api/%@", key];
NSURL *URL = [NSURL URLWithString:URLString];

FoundationExtension

NSURL *URL = [[@"http://"HOST_URL"/api/%@" format:key] URL];

@see @ref NSString(Shortcuts) @see @ref NSString(NSURL)

iPhone MAC Address

Foundation

  • No way.

FoundationExtension

[[UIDevice currentDevice] MACAddress]

@see @ref UIDevice(Shortcuts)

performSelector, with 3 object

Foundation

  • No way. You should use <objc/runtime.h>

FoundationExtension

[obj performSelector:sel withObject:o1 withObject:o2 withObject:o3];

@see @ref NSObject(ObjCRuntime)

Get NSData from post request

Foundation

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:@"field1=value1"];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL];

FoundationExtension

NSData *data = [NSData dataWithContentsOfURL:URL postBody:@{@"field1":@"value1"} encoding:NSUTF8StringEncoding];

@see @ref NSData(NSURLRequest)

Get NSData from Multipart Form POST

Foundation

  • No way.

FoundationExtension

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setHTTPMultiPartFormPostBody:@{@"filename":data} encoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithContentOfURLRequest:request];

@see NSURLRequestAdditions.h

Truncate strings in array

Foundation

NSMutableArray *newArray = [NSMutableArray array];
for (NSString *s in array) {
    [newArray addObject:[s substringToIndex:20]];
}

FoundationExtension NSArray

NSArray *newArray = [array arrayByMappingOperation:^(NSString *obj){ [obj substringToIndex:20]; }];

FoundationExtension NSMutableArray

[array map::^(NSString *obj){ [obj substringToIndex:20]; }];

@see @ref Map/Filter/Reduce @see NSAFunctional.h

Get a class name

Foundation

NSString *className = [NSString stringWithUTF8String:class_getName(obj.class)];

FoundationExtension

NSString *className = obj.class.name;

@see @ref NSObject(ObjCRuntime) @see @ref NSObject(ObjCRuntimeClass)

Get hexadecimal value from base 16 string

Foundation

int value;
sscanf(string.UTF8String, "%x", &value);

FoundationExtension

NSInteger value = [string hexadecimalValue];

@see @ref NSData(Serialization)

How about base 12 string?

Foundation

  • Why should foundation has this?

FoundationExtension

NSInteger value = [string integerValueBase:12];

@see @ref NSString(Evaluation)

md5 hash

Foundation

unsigned char hashedChars[CC_MD5_DIGEST_LENGTH];
CC_MD5([data bytes], (CC_LONG)[self length], hashedChars);
NSMutableString *result = [[NSMutableString alloc] init];
for ( int i = 0; i<CC_MD5_DIGEST_LENGTH; i++ ) {
    [result appendFormat:@"%02x", *(hashedChars+i)];
}

FoundationExtension

NSString *result = [data digestStringByMD5];

@see @ref NSData(CommonCrypto)

plist dictionary decode from HTTP post request

Foundation

  • Get data from NSURLRequest. Ehh.. so what can I do now? (Use NSPropertyListSerialization)

FoundationExtension

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setHTTPPostBody:@{@"key1":@"value1"} encoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithContentOfURLRequest:request];
NSDictionary *dictionary = [NSDictionary dictionaryWithData:data];

@see @ref NSMutableURLRequest(HTTPMethod) @see @ref NSData(NSURLRequest) @see @ref NSDictionary(NSData)

UIColor from HTML color code

UIKitExtension

UIColor *color = [UIColor colorWithHTMLExpression:@"#f0f0f0"];

@see @ref UIColor(HTMLColor)

Change implementation to new one

FoundationExtension

[class methodObjectForSelector:@selector(method1)].implementation
  = [class methodObjectForSelector:@selector(method2)].implementation;
// now [obj method1] equals [obj method2]

@see NSAMethod

Retrieve accessibility for private variable.

FoundationExtension

@interface Secret: NSObject { @private id _attr; } @end // #1 remember the '_attr'
// Hack the Secret!
@interface Secret (Accessor)
@property
    (nonatomic, retain) id attr; // #2 remember the 'attr'
@end
@implementation Secret (Accessor)
NSAPropertyGetter(attr, "_attr") // #2, #1 to create getter
NSAPropertyRetainSetter(setAttr, "_attr") // #2, #1 to create getter
@end

@see NSObject(ObjCRuntime)

For more

See the document! [http://youknowone.github.com/FoundationExtension] (http://youknowone.github.com/FoundationExtension)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].