Coder Social home page Coder Social logo

shaojiankui / jkcategories Goto Github PK

View Code? Open in Web Editor NEW
3.3K 132.0 937.0 1.9 MB

JKCategories(iOS-Categories,Category), a collection of useful Objective-C Categories extending iOS Frameworks such as Foundation,UIKit,CoreData,QuartzCore,CoreLocation,MapKit Etc.

License: MIT License

Objective-C 99.26% Ruby 0.74%
categories category ios jkcategories ios-categories objective-c extensions

jkcategories's Introduction

JKCategories(iOS-Categories)

License MIT  CocoaPods  CocoaPods  Support  Build Status

JKCategories(iOS-Categories), a collection of useful Objective-C Categories extending iOS Frameworks such as Foundation,UIKit,CoreData,QuartzCore,CoreLocation,MapKit Etc.

Requirements

This library requires iOS 7.0+ and Xcode 8.0+.

Installation

Installation with CocoaPods

when you will use the all Categories:

platform :ios
pod 'JKCategories'

when you will use the some one type framework lib,such as Foundation:

platform :ios
pod 'JKCategories/Foundation'

when you will use a more detailed class type lib, in some one type framework lib,such as Foundation's NSDictionary:

platform :ios
pod 'JKCategories/Foundation/NSDictionary'

you will find all sublib with pod search JKCategories or Podfile or in the project folder hierarchy

Manually

Copy JKCategories or some specific class file to your project

Usage

import the header file into any class where you wish to make use of the functionality such as

#import "NSArray+JKSafeAccess.h" or "<JKCategories/NSArray+JKSafeAccess.h>",

Not recommended for import all the header files of JKCategories into pch or baseclass

onekey import all categories of framework

"JKUIKit.h" or "<JKCategories/JKUIKit.h>",
"JKFoundation.h" or "<JKCategories/JKFoundation.h>",
"JKCoreData.h" or "<JKCategories/JKCoreData.h>",
"JKCoreLocation.h" or "<JKCategories/JKCoreLocation.h>",
"JKMapKit.h"  or "<JKCategories/JKMapKit.h>",
"JKQuartzCore.h"  or "<JKCategories/JKQuartzCore.h>""

onekey import all categories of all frameworks

"JKCategories.h" or <JKCategories/JKCategories.h>,

Content

Foundation

  • NSArray
  • NSBundle
  • NSData
  • NSDate
  • NSDateFormatter
  • NSNotificationCenter
  • NSDictionary
  • NSException
  • NSFileManager
  • NSIndexPath
  • NSNumber
  • NSObject
  • NSSet
  • NSString
  • NSTimer
  • NSURL
  • NSUserDefaults
  • NSHTTPCookieStorage
  • NSFileHandle
  • NSRunLoop
  • NSURLRequest
  • NSOperation
  • NSInvocation
  • NSURLConnection
  • NSURLSession

UIKit

  • UIAlertView
  • UIApplication
  • UIBarButtonItem
  • UIBezierPath
  • UIButton
  • UIColor
  • UIFont
  • UIControl
  • UIDevice
  • UIImage
  • UIImageView
  • UILable
  • UINavigationBar
  • UINavigationController
  • UINavigationItem
  • UIResponder
  • UIScreen
  • UIScrollView
  • UISearchBar
  • UISplitViewController
  • UITableView
  • UITableViewCell
  • UITextField
  • UITextView
  • UIView
  • UIViewController
  • UIWebView
  • UIWindow
  • UIPopoverController
  • UICollectionView

QuartzCore

  • CALayer
  • CAMediaTimingFunction
  • CAAnimation
  • CAShapeLayer
  • CATransaction

CoreData

  • NSManagedObjectContext
  • NSFetchRequest
  • NSManagedObject
  • NSPersistentStoreCoordinator

CoreLocation

  • CLLocationManager
  • CLLocation

MapKit

  • MKMapView

License

JKCategories is available under the MIT license.

jkcategories's People

Contributors

100apps avatar andy0570 avatar chenmu00 avatar coneman avatar dabing1022 avatar kemalbakacak avatar kevinhm avatar lisonfan avatar mlch911 avatar nidom avatar shaojiankui avatar zhongyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jkcategories's Issues

UIViewController+DDPopUpViewController.m ARC下编译错误

感谢作者,categories很全面,节省了很多精力.
小问题,就不pull了.
+(vo�id)load
原:
Method original = class_getInstanceMethod([UIViewController class], @selector(dealloc));
修改为
Method original = class_getInstanceMethod([UIViewController class], NSSelectorFromString(@"dealloc"));

关于使用<Masonry>添加约束时,使用扩展绘制圆角的问题

我的项目使用了进行布局,添加完约束,在调用 [UIView jk_setRoundedCorners:radius] 方法为视图添加圆角的时,无法正常添加,建议将该扩展下的方法实现改为:

[self layoutIfNeeded];//增加这一行代码,其他维持不变

CGRect rect = self.bounds;

// Create the path
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:rect
                                               byRoundingCorners:corners
                                                     cornerRadii:CGSizeMake(radius, radius)];

// Create the shape layer and set its path
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.frame = rect;
maskLayer.path = maskPath.CGPath;

// Set the newly created shape layer as the mask for the view's layer
self.layer.mask = maskLayer;

其他类似的地方都应该添加这个代码

UIWebView能否移除

webview已经被deprecated并被要求强制移除,之后的版本能否移除相关分类

JKCategories 影响到导航栏相关设置

UINavigationController (JKNavigationItemBackBtnTile)
这个分类的代码,影响到我修改导航栏BackBarButtonItem,目前我只能先注释掉如下代码

- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item {
    
    UIViewController * viewController = self.viewControllers.count > 1 ? \
                    [self.viewControllers objectAtIndex:self.viewControllers.count - 2] : nil;
    
    if (!viewController) {
        return YES;
    }
    
    NSString *backButtonTitle = nil;
    if ([viewController respondsToSelector:@selector(jk_navigationItemBackBarButtonTitle)]) {
        backButtonTitle = [viewController jk_navigationItemBackBarButtonTitle];
    }
    
    if (!backButtonTitle) {
        backButtonTitle = viewController.title;
    }
    
    UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithTitle:backButtonTitle
                                                                       style:UIBarButtonItemStylePlain
                                                                      target:nil action:nil];
    viewController.navigationItem.backBarButtonItem = backButtonItem;
    
    return YES;
}

下面是我的代码:

- (void)customePushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated {
    NSLog(@"UINavigationBar ====== item: %@, topItem: %@, backItem: %@", item, self.topItem, self.backItem);
    if (self.topItem) {
        UIBarButtonItem *item = self.ty_globalBackBarButtonItem;
        [self.topItem setBackBarButtonItem:item];  //我在这里对BackBarButtonItem做了替换
    }
    [self customePushNavigationItem:item animated:animated];
}

由于该库的代码导致我替换了BackBarButtonItem后,又被该库的代码替换成了带Title的BackBarButtonItem,我认为这块代码不应该出现在这个库里面,直接重写了系统的方法,在用户无察觉的情况下做这件事情似乎不是很好吧!

热更新

您的源码中存在热更新代码 dlopen(), dlsym() ,建议修复一下

UINavigationBar致命问题

@shaojiankui 使用pod安装后,不添加任何一行分类代码,对UINavigationController的UINavigationBar有�致命的UI影响。测试环境:xcode 7.3.1 iOS9.3。

辛苦了,但有点不知所措

感谢作者,but,分类太强大,太庞大了,不知道如何去使用,仅仅只看一个方法名并不知道有什么用,有有些注释,但仅仅看一点注释也不太明白,这该如何解决呢

使用CocoaPods导入报错

Podfile:
platform :ios, '7.0'
target 'BKCustom' do
pod 'JKCategories'
end
error:
[!] Unable to find a specification for JKCategories
导入别的第三方框架不会报这个错!

NSData+Encrypt.h

I use this category to encrypt my nsdata and set the IV param to nil,why the result is nil.If i have post the wrong param?Hope your response,thanks!

CommonCrypto 是不是有冲突啊

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/usr/include/CommonCrypto/module.modulemap:1:8: Redefinition of module 'CommonCrypto'

直接下载的项目和pod最新的不一致

下载最新的1.8.1版本和pod不一致,比如UIDevice+Hardware这个分类中的+ (NSString *)jk_platformString 方法,下载的有iPhone 11、iPhone 11 Pro和iPhone 11 Pro Max,而pod却没有还停留iPhone XR,希望跟新一下。

9.3.5系统上调用 textView.jk_maxLength 方法会发生崩溃问题

iOS 9.3.5系统真机 iPad mini中,运行程序,调用JKCategories分类文件UITextView+JKInputLimit.h中的jk_maxLength属性(此属性用于限制 UITextView 输入的文本字符串长度)会直接崩溃,崩溃信息如下

Signal 11 was raised. SIGSEGV (_mh_execute_header + 1193343)

在其他系统环境中调用此属性用于限制用户输入的文本字符串长度则无此异常,期待你的解决!!!

某些方法定义为内联函数比 Category 更合适

感谢作者的分享这么丰富的 Category ,666

比如 NSObject+JKGCD.m 类中的 GCD 相关函数
正常使用是

[someObject jk_performAsynchronous{
    ...
}];

感觉不太合适,下面这样定义为内联函数会不会更好些 ?

NS_INLINE void ExecuteAsyncInGlobalQueue(void (^block)()){
    dispatch_async(getGlobalQueue(), block);
};

"NSDate+JKExtension 类中 - (NSString *)jk_formatYMD; 返回值有误

原代码:

  • (NSUInteger)jk_weekOfYear:(NSDate *)date {
    NSUInteger i;
    NSUInteger year = [date jk_year];

    NSDate *lastdate = [date jk_lastdayOfMonth];

    for (i = 1;[[lastdate jk_dateAfterDay:-7 * i] jk_year] == year; i++) {

    }

    return i;
    }

应把 [lastdate jk_dateAfterDay:-7 * i] 改成 [date jk_dateAfterDay:-7 * i]

0分钟前

文件 NSDate+JKExtension 对应 433 行,如果当时间小于1分钟时(比如retTime为0.5),使用该方法会表示为 0分钟前 ,建议对改行代码进行修正。修正前

    retTime = retTime <= 0.0 ? 1.0 : retTime;
    return [NSString stringWithFormat:@"%.0f分钟前", retTime];

修正后

    return retTime < 1.0 ? @"刚刚" : [NSString stringWithFormat:@"%.0f分钟前", retTime];

NSDictionary+JKSafeAccess have a bug

NSDictionary+JKSafeAccess have a bug

- (NSDate *)jk_dateForKey:(id)key dateFormat:(NSString *)dateFormat{
    NSDateFormatter *formater = [[NSDateFormatter alloc]init];
    formater.dateFormat = dateFormat;
    id value = [self objectForKey:key];
    
    if (value == nil || value == [NSNull null])
    {
        return nil;
    }
    
    if ([value isKindOfClass:[NSString class]] && ![value isEqualToString:@""] && !dateFormat) {
        return [formater dateFromString:value];
    }
    return nil; 
}

!dateFormat

NSObject+JKKVOBlocks

jk_observeValueForKeyPath 这个方法会被系统调用么?
不会。。会因为没有handled KVO 的 message 而 crash。

UIAlertView

UIAlertView遭弃用,看着⚠️心烦,求更新

UIButton+JKCountDown

// int minutes = timeout / 60;
int seconds = timeOut % 60;
NSString *strTime = [NSString stringWithFormat:@"%.2d", seconds];
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
NSLog(@"____%@",strTime);
[self setTitle:[NSString stringWithFormat:@"%@%@",strTime,waitTittle] forState:UIControlStateNormal];
self.userInteractionEnabled = NO;
});
timeOut--;

起始时间为60的时候,按钮因为%60为0而显示不了“60”的状态
(还有命名为“tittle”的问题)

Demo或者注释

非常感谢有这么多的分类可以使用.希望能补上Demo和注释.有很多没有注释,有的是英文的,有的是中文.

下载之后直接报错

Use of '@import' when modules are disabled
这个错误我上网上查了一下,说是把enabled modules改成YES就行了,但是我本身就是YES。
然后stackoverflow说是因为我用了ObjectiveC++,所以modules被禁用了,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.