Top Related Projects
A delightful networking framework for iOS, macOS, watchOS, and tvOS.
Asynchronous image downloader with cache support as a UIImageView category
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
Model framework for Cocoa and Cocoa Touch
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.
Quick Overview
YYKit is a comprehensive collection of iOS components and utility classes designed to simplify and accelerate iOS development. It provides a wide range of features, including model-to-JSON conversion, image and web image loading, caching mechanisms, and various UI components.
Pros
- Extensive feature set covering many common iOS development needs
- High performance and optimized implementations
- Well-documented and actively maintained
- Modular design allowing developers to use only the components they need
Cons
- Large codebase may increase app size if not carefully managed
- Some components may overlap with native iOS APIs or other popular libraries
- Learning curve can be steep due to the wide range of features
- Dependency on a third-party library may complicate long-term maintenance
Code Examples
- JSON to Model conversion:
// Define a model
@interface User : NSObject
@property NSString *name;
@property NSInteger age;
@end
// Convert JSON to model
NSDictionary *json = @{@"name": @"John", @"age": @25};
User *user = [User yy_modelWithJSON:json];
- Asynchronous image loading:
UIImageView *imageView = [[UIImageView alloc] init];
[imageView yy_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholder:[UIImage imageNamed:@"placeholder"]];
- Key-value observing:
[object yy_addObserverBlockForKeyPath:@"someProperty" block:^(id _Nonnull obj, id _Nullable oldVal, id _Nullable newVal) {
NSLog(@"Property changed from %@ to %@", oldVal, newVal);
}];
Getting Started
- Add YYKit to your project using CocoaPods:
pod 'YYKit'
- Import YYKit in your source files:
#import <YYKit/YYKit.h>
- Start using YYKit components in your code:
// Example: Using YYCache
YYCache *cache = [YYCache cacheWithName:@"MyCache"];
[cache setObject:@"value" forKey:@"key"];
id object = [cache objectForKey:@"key"];
Competitor Comparisons
A delightful networking framework for iOS, macOS, watchOS, and tvOS.
Pros of AFNetworking
- Focused specifically on networking tasks, providing a comprehensive set of tools for HTTP/HTTPS requests
- Well-established and widely adopted in the iOS development community
- Extensive documentation and community support
Cons of AFNetworking
- Limited to networking functionality, unlike YYKit's broader scope
- May require additional libraries for non-networking tasks
- Less frequent updates compared to YYKit
Code Comparison
AFNetworking:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"https://api.example.com/data" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"Error: %@", error);
}];
YYKit:
YYURLRequest *request = [YYURLRequest requestWithURL:[NSURL URLWithString:@"https://api.example.com/data"]];
[request startWithCompletionBlockWithSuccess:^(YYURLRequest *request) {
id responseObject = request.responseJSONObject;
NSLog(@"JSON: %@", responseObject);
} failure:^(YYURLRequest *request) {
NSLog(@"Error: %@", request.error);
}];
Both examples demonstrate a simple GET request, showcasing the similar approach but different syntax and method names used by each library.
Asynchronous image downloader with cache support as a UIImageView category
Pros of SDWebImage
- More focused and specialized for image loading and caching
- Extensive documentation and community support
- Regular updates and maintenance
Cons of SDWebImage
- Limited to image-related functionality
- May require additional libraries for other tasks
Code Comparison
SDWebImage:
[imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
YYKit:
[imageView yy_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
Additional Notes
YYKit is a comprehensive iOS development framework that includes image loading and caching along with many other features. SDWebImage, on the other hand, focuses solely on image loading, caching, and management.
YYKit provides a wider range of functionality, including text rendering, JSON model, cache, and animations. This makes it a more all-in-one solution for iOS development.
SDWebImage's specialized focus on image handling makes it a lighter-weight option for projects that only need image-related features. It also benefits from a larger community and more frequent updates specifically tailored to image management.
Both libraries offer similar syntax for basic image loading, making it easy to switch between them if needed.
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
Pros of ReactiveCocoa
- Provides a comprehensive reactive programming framework
- Supports functional reactive programming (FRP) paradigm
- Offers powerful stream processing and event handling capabilities
Cons of ReactiveCocoa
- Steeper learning curve for developers new to reactive programming
- Can lead to more complex code for simple tasks
- Potential performance overhead for heavy signal processing
Code Comparison
ReactiveCocoa:
RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
[subscriber sendNext:@"Hello, Reactive World!"];
[subscriber sendCompleted];
return nil;
}];
[signal subscribeNext:^(id x) {
NSLog(@"%@", x);
}];
YYKit:
YYCache *cache = [YYCache cacheWithName:@"myCache"];
[cache setObject:@"Hello, YYKit World!" forKey:@"greeting"];
NSString *greeting = [cache objectForKey:@"greeting"];
NSLog(@"%@", greeting);
While ReactiveCocoa focuses on reactive programming and signal processing, YYKit provides a more traditional approach with a collection of utilities for iOS development. ReactiveCocoa is better suited for complex, event-driven applications, while YYKit offers a broader range of utilities for general iOS development tasks.
Model framework for Cocoa and Cocoa Touch
Pros of Mantle
- More focused on model object serialization and data transformation
- Better documentation and community support
- Lightweight and easy to integrate into existing projects
Cons of Mantle
- Less comprehensive feature set compared to YYKit
- May require additional libraries for certain functionalities
- Slightly steeper learning curve for beginners
Code Comparison
Mantle:
@interface Person : MTLModel <MTLJSONSerializing>
@property (nonatomic, copy) NSString *name;
@property (nonatomic, strong) NSNumber *age;
@end
@implementation Person
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
return @{@"name": @"full_name", @"age": @"years_old"};
}
@end
YYKit:
@interface Person : NSObject
@property NSString *name;
@property NSNumber *age;
@end
@implementation Person
+ (NSDictionary *)modelCustomPropertyMapper {
return @{@"name": @"full_name", @"age": @"years_old"};
}
@end
Both libraries provide similar functionality for JSON mapping, but Mantle requires conforming to a protocol and subclassing MTLModel, while YYKit uses a category on NSObject for more flexibility. YYKit's implementation is slightly more concise, but Mantle offers more built-in features for model object handling.
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.
Pros of MJExtension
- Lightweight and focused specifically on JSON/model conversion
- Simple API with easy-to-use methods for common tasks
- Extensive documentation and examples in Chinese
Cons of MJExtension
- Less comprehensive feature set compared to YYKit
- Limited to JSON/model conversion, lacking other utility functions
- May have slower performance for complex nested structures
Code Comparison
MJExtension:
@interface User : NSObject
@property (copy, nonatomic) NSString *name;
@property (strong, nonatomic) NSNumber *age;
@end
NSDictionary *dict = @{@"name": @"Jack", @"age": @20};
User *user = [User mj_objectWithKeyValues:dict];
YYKit:
@interface User : NSObject
@property NSString *name;
@property NSInteger age;
@end
NSDictionary *dict = @{@"name": @"Jack", @"age": @20};
User *user = [User yy_modelWithDictionary:dict];
MJExtension focuses solely on JSON/model conversion, making it a good choice for projects that only need this functionality. It offers a straightforward API and extensive Chinese documentation. However, YYKit provides a more comprehensive set of utilities and may offer better performance for complex data structures. YYKit's code is slightly more concise, but both libraries offer similar ease of use for basic JSON/model conversion tasks.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
YYKit
YYKit is a collection of iOS components.
It's so huge that I split it into several independent components:
- YYModel â High performance model framework for iOS.
- YYCache â High performance cache framework for iOS.
- YYImage â Image framework for iOS to display/encode/decode animated WebP, APNG, GIF.
- YYWebImage â Asynchronous image loading framework.
- YYText â Powerful rich text component for iOS.
- YYKeyboardManager â Access keyboard view and track keyboard animation.
- YYDispatchQueuePool â iOS utility class to manage global dispatch queue.
- YYAsyncLayer â iOS utility classes for asynchronous rendering and display.
- YYCategories â A set of useful categories for Foundation and UIKit.
Demo Project
See Demo/YYKitDemo.xcodeproj
Installation
CocoaPods
- Add
pod 'YYKit'
to your Podfile. - Run
pod install
orpod update
. - Import <YYKit/YYKit.h>.
Carthage
- Add
github "ibireme/YYKit"
to your Cartfile. - Run
carthage update --platform ios
and add the framework to your project. - Import <YYKit/YYKit.h>.
- Notice: carthage framework doesn't include webp component, if you want to support webp, use CocoaPods or install manually.
Manually
- Download all the files in the
YYKit
subdirectory. - Add the source files to your Xcode project.
- Add
-fno-objc-arc
compiler flag toNSObject+YYAddForARC.m
andNSThread+YYAdd.m
. - Link with required frameworks:
- UIKit
- CoreFoundation
- CoreText
- CoreGraphics
- CoreImage
- QuartzCore
- ImageIO
- AssetsLibrary
- Accelerate
- MobileCoreServices
- SystemConfiguration
- sqlite3
- libz
- Add
Vendor/WebP.framework
(static library) to your Xcode project if you want to support WebP. - Import
YYKit.h
.
Documentation
Full API documentation is available on CocoaDocs.
You can also install documentation locally using appledoc.
Requirements
This library requires iOS 6.0+
and Xcode 8.0+
.
Notice
I want to use the APIs as if it was provided by system, and I don't add prefix in
these categories. I do not recommend using the YYKit
directly, you should try the separated components first.
License
YYKit is provided under the MIT license. See LICENSE file for details.
ä¸æä»ç»
YYKit æ¯ä¸ç»åè½ä¸°å¯ç iOS ç»ä»¶ã
为äºå°½éå¤ç¨ä»£ç ï¼è¿ä¸ªé¡¹ç®ä¸çæäºç»ä»¶ä¹é´ææ¯è¾å¼ºçä¾èµå ³ç³»ã为äºæ¹ä¾¿å ¶ä»å¼åè 使ç¨ï¼æä»ä¸æååºä»¥ä¸ç¬ç«ç»ä»¶ï¼
- YYModel â é«æ§è½ç iOS JSON 模åæ¡æ¶ã
- YYCache â é«æ§è½ç iOS ç¼åæ¡æ¶ã
- YYImage â åè½å¼ºå¤§ç iOS å¾åæ¡æ¶ã
- YYWebImage â é«æ§è½ç iOS å¼æ¥å¾åå è½½æ¡æ¶ã
- YYText â åè½å¼ºå¤§ç iOS å¯ææ¬æ¡æ¶ã
- YYKeyboardManager â iOS é®ççå¬ç®¡çå·¥å ·ã
- YYDispatchQueuePool â iOS å ¨å±å¹¶åéå管çå·¥å ·ã
- YYAsyncLayer â iOS å¼æ¥ç»å¶ä¸æ¾ç¤ºçå·¥å ·ã
- YYCategories â åè½ä¸°å¯ç Category ç±»åå·¥å ·åºã
æ¼ç¤ºé¡¹ç®
æ¥ç并è¿è¡ Demo/YYKitDemo.xcodeproj
å®è£
CocoaPods
- å¨ Podfile ä¸æ·»å
pod 'YYKit'
ã - æ§è¡
pod install
æpod update
ã - å¯¼å ¥ <YYKit/YYKit.h>ã
Carthage
- å¨ Cartfile ä¸æ·»å
github "ibireme/YYKit"
ã - æ§è¡
carthage update --platform ios
并å°çæç framework æ·»å å°ä½ çå·¥ç¨ã - å¯¼å ¥ <YYKit/YYKit.h>ã
- 注æ: carthage framework 并没æå å« webp ç»ä»¶ãå¦æä½ éè¦æ¯æ webpï¼å¯ä»¥ç¨ CocoaPods å®è£ ï¼æè æå¨å®è£ ã
æå¨å®è£
- ä¸è½½ YYKit æ件夹å çææå 容ã
- å° YYKit å çæºæ件添å (ææ¾)å°ä½ çå·¥ç¨ã
- 为
NSObject+YYAddForARC.m
åNSThread+YYAdd.m
æ·»å ç¼è¯åæ°-fno-objc-arc
ã - é¾æ¥ä»¥ä¸ frameworks:
- UIKit
- CoreFoundation
- CoreText
- CoreGraphics
- CoreImage
- QuartzCore
- ImageIO
- AssetsLibrary
- Accelerate
- MobileCoreServices
- SystemConfiguration
- sqlite3
- libz
- å¦æä½ éè¦æ¯æ WebPï¼å¯ä»¥å°
Vendor/WebP.framework
(éæåº) å å ¥ä½ çå·¥ç¨ã - 导å
¥
YYKit.h
ã
ææ¡£
ä½ å¯ä»¥å¨ CocoaDocs æ¥çå¨çº¿ API ææ¡£ï¼ä¹å¯ä»¥ç¨ appledoc æ¬å°çæææ¡£ã
ç³»ç»è¦æ±
该项ç®æä½æ¯æ iOS 6.0
å Xcode 8.0
ã
注æ
æå¸æè°ç¨ API æ¶ï¼æçåè°ç¨ç³»ç»èªå¸¦ API ä¸æ ·çä½éªï¼æ以æ并没æ为 Category æ¹æ³æ·»å åç¼ãæå·²ç»ç¨å·¥å
·æ«æè¿è¿ä¸ªé¡¹ç®ä¸ç APIï¼ç¡®ä¿æ²¡æå¯¹ç³»ç» API 产çå½±åï¼ä½å³ä½¿è¿æ ·æ²¡æåç¼ç Category ä¹å¯è½ä¼å¸¦æ¥å
¶ä»éº»ç¦ãå æ¤æä¸å¤ªæ¨èç´æ¥ä½¿ç¨ YYKit
è¿ä¸ªåºï¼ä½ åºè¯¥å
å°è¯ä¸ä¸ä¸é¢é£äºæååºæ¥çç¬ç«ç»ä»¶ã
许å¯è¯
YYKit ä½¿ç¨ MIT 许å¯è¯ï¼è¯¦æ è§ LICENSE æ件ã
ç¸å ³æç«
Top Related Projects
A delightful networking framework for iOS, macOS, watchOS, and tvOS.
Asynchronous image downloader with cache support as a UIImageView category
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift.
Model framework for Cocoa and Cocoa Touch
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot