Skip to content

Commit

Permalink
add frameworks header for onekey import
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakey committed May 30, 2016
1 parent b6416e0 commit 6ec1750
Show file tree
Hide file tree
Showing 17 changed files with 478 additions and 103 deletions.
22 changes: 18 additions & 4 deletions JKCategories-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
A23C10861B3D39AD00FA34AA /* UIViewController+JKBackButtonTouched.m in Sources */ = {isa = PBXBuildFile; fileRef = A23C10851B3D39AD00FA34AA /* UIViewController+JKBackButtonTouched.m */; };
A24377231ACBE9CF00FFFEA1 /* NSObject+JKAutoCoding.m in Sources */ = {isa = PBXBuildFile; fileRef = A24377221ACBE9CF00FFFEA1 /* NSObject+JKAutoCoding.m */; };
A24868781C1FB05B00D3318A /* UIWebView+JKTS_JavaScriptContext.m in Sources */ = {isa = PBXBuildFile; fileRef = A24868771C1FB05B00D3318A /* UIWebView+JKTS_JavaScriptContext.m */; };
A248687B1C1FB08D00D3318A /* UITableViewCell+JKDdelaysContentTouches.m in Sources */ = {isa = PBXBuildFile; fileRef = A248687A1C1FB08D00D3318A /* UITableViewCell+JKDdelaysContentTouches.m */; };
A248687B1C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.m in Sources */ = {isa = PBXBuildFile; fileRef = A248687A1C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.m */; };
A248782D1C55CC5C00AFF958 /* UIImage+JKSuperCompress.m in Sources */ = {isa = PBXBuildFile; fileRef = A248782C1C55CC5C00AFF958 /* UIImage+JKSuperCompress.m */; };
A24EC2DD1B74D49F00CE538B /* NSDictionary+JKURL.m in Sources */ = {isa = PBXBuildFile; fileRef = A24EC2DC1B74D49F00CE538B /* NSDictionary+JKURL.m */; };
A24EC2E31B74D69E00CE538B /* NSRunLoopDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A24EC2E11B74D69E00CE538B /* NSRunLoopDemoViewController.m */; };
Expand Down Expand Up @@ -547,6 +547,13 @@
A22104351CFAE31200CE6547 /* UIWebView+Alert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+Alert.m"; sourceTree = "<group>"; };
A22104371CFAE6F500CE6547 /* CLLocationManager+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CLLocationManager+Blocks.h"; sourceTree = "<group>"; };
A22104381CFAE6F500CE6547 /* CLLocationManager+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CLLocationManager+Blocks.m"; sourceTree = "<group>"; };
A22104621CFAFF0100CE6547 /* JKQuartzCore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKQuartzCore.h; sourceTree = "<group>"; };
A22104631CFAFF1E00CE6547 /* JKCoreData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKCoreData.h; sourceTree = "<group>"; };
A22104641CFAFF2900CE6547 /* JKFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKFoundation.h; sourceTree = "<group>"; };
A22104651CFAFF4300CE6547 /* JKUIKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKUIKit.h; sourceTree = "<group>"; };
A22104661CFAFF4C00CE6547 /* JKMapKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKMapKit.h; sourceTree = "<group>"; };
A22104671CFAFF5400CE6547 /* JKCoreLocation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKCoreLocation.h; sourceTree = "<group>"; };
A22104681CFBE29200CE6547 /* JKCategories.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JKCategories.h; sourceTree = "<group>"; };
A22725CE1A3E72D50061605B /* JKCategories-Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "JKCategories-Demo.app"; sourceTree = BUILT_PRODUCTS_DIR; };
A22845231BE2085C000AD2F6 /* NSDecimalNumber+JKCalculatingByString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDecimalNumber+JKCalculatingByString.h"; sourceTree = "<group>"; };
A22845241BE2085C000AD2F6 /* NSDecimalNumber+JKCalculatingByString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDecimalNumber+JKCalculatingByString.m"; sourceTree = "<group>"; };
Expand All @@ -563,7 +570,7 @@
A24868761C1FB05B00D3318A /* UIWebView+JKTS_JavaScriptContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+JKTS_JavaScriptContext.h"; sourceTree = "<group>"; };
A24868771C1FB05B00D3318A /* UIWebView+JKTS_JavaScriptContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+JKTS_JavaScriptContext.m"; sourceTree = "<group>"; };
A24868791C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableViewCell+JKDelaysContentTouches.h"; sourceTree = "<group>"; };
A248687A1C1FB08D00D3318A /* UITableViewCell+JKDdelaysContentTouches.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableViewCell+JKDdelaysContentTouches.m"; sourceTree = "<group>"; };
A248687A1C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableViewCell+JKDelaysContentTouches.m"; sourceTree = "<group>"; };
A248782B1C55CC5C00AFF958 /* UIImage+JKSuperCompress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+JKSuperCompress.h"; sourceTree = "<group>"; };
A248782C1C55CC5C00AFF958 /* UIImage+JKSuperCompress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+JKSuperCompress.m"; sourceTree = "<group>"; };
A24EC2DB1B74D49F00CE538B /* NSDictionary+JKURL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+JKURL.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1494,6 +1501,13 @@
A22725F21A3E736D0061605B /* UIKit */,
A202D9821B0F7D1400EAB199 /* MapKit */,
A202D9761B0F7BE100EAB199 /* CoreLocation */,
A22104621CFAFF0100CE6547 /* JKQuartzCore.h */,
A22104631CFAFF1E00CE6547 /* JKCoreData.h */,
A22104641CFAFF2900CE6547 /* JKFoundation.h */,
A22104651CFAFF4300CE6547 /* JKUIKit.h */,
A22104661CFAFF4C00CE6547 /* JKMapKit.h */,
A22104671CFAFF5400CE6547 /* JKCoreLocation.h */,
A22104681CFBE29200CE6547 /* JKCategories.h */,
);
path = JKCategories;
sourceTree = "<group>";
Expand Down Expand Up @@ -2394,7 +2408,7 @@
isa = PBXGroup;
children = (
A24868791C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.h */,
A248687A1C1FB08D00D3318A /* UITableViewCell+JKDdelaysContentTouches.m */,
A248687A1C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.m */,
A28BE3121A3E9FDC005C4AC6 /* UITableViewCell+JKNIB.h */,
A28BE3131A3E9FDC005C4AC6 /* UITableViewCell+JKNIB.m */,
);
Expand Down Expand Up @@ -3240,7 +3254,7 @@
A202D9C01B1038DB00EAB199 /* UIBarButtonItemDemoViewController.m in Sources */,
A22104361CFAE31200CE6547 /* UIWebView+Alert.m in Sources */,
A2EF56EA1B21CD620005F730 /* UIView+JKShake.m in Sources */,
A248687B1C1FB08D00D3318A /* UITableViewCell+JKDdelaysContentTouches.m in Sources */,
A248687B1C1FB08D00D3318A /* UITableViewCell+JKDelaysContentTouches.m in Sources */,
A28BE3551A3EAA21005C4AC6 /* NSObject+JKBlocks.m in Sources */,
A2C12BA21B1C282C00EAD198 /* UITableView+JKiOS7Style.m in Sources */,
A2681A441A75C7C8009BA7EE /* NSString+JKEncrypt.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion JKCategories-Demo/Controller/RootViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "RootViewController.h"

#import "JKCategories.h"
@interface RootViewController ()

@end
Expand Down
2 changes: 1 addition & 1 deletion JKCategories-Demo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
5 changes: 3 additions & 2 deletions JKCategories.podspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.0";
version = "1.1";

Pod::Spec.new do |s|
s.name = "JKCategories"
Expand All @@ -14,7 +14,8 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "6.0"
s.requires_arc = true
s.frameworks = 'Foundation', 'UIKit', 'CoreData', 'QuartzCore', 'CoreLocation', 'MapKit'
s.libraries = "z"
s.source = { :git => "https://github.com/shaojiankui/JKCategories.git", :tag => "#{version}" }
s.source_files = "JKCategories", "JKCategories/**/*.{h,m}"
s.source_files = "JKCategories", "JKCategories/*.{h}","JKCategories/**/*.{h,m}"
#s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
end
37 changes: 30 additions & 7 deletions JKCategories/Foundation/NSData/NSData+JKGzip.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
//
// NSData+JKGzip.h
// JKCategories (https://github.com/shaojiankui/JKCategories)
// GZIP.h
//
// Created by Jakey on 14/12/30.
// Copyright (c) 2014年 www.skyfox.org. All rights reserved.
// Version 1.1.1
//
// Created by Nick Lockwood on 03/06/2012.
// Copyright (C) 2012 Charcoal Design
//
// Distributed under the permissive zlib License
// Get the latest version from here:
//
// https://github.com/nicklockwood/GZIP
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//


//Add libz.dylib to your project.
#import <Foundation/Foundation.h>
extern NSString* const JKGzipErrorDomain;
@interface NSData (JKGzip)
/**
* @brief GZIP压缩
Expand All @@ -33,4 +54,6 @@ extern NSString* const JKGzipErrorDomain;
* @return 解压后数据
*/
- (NSData *)jk_gunzippedData;

- (BOOL)jk_isGzippedData;
@end
162 changes: 92 additions & 70 deletions JKCategories/Foundation/NSData/NSData+JKGzip.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,102 +8,124 @@

#import "NSData+JKGzip.h"
#import <zlib.h>
#import <dlfcn.h>

@implementation NSData (JKGzip)
#define SCFW_CHUNK_SIZE 16384
/**
* @brief GZIP压缩
*
* @param level 压缩级别
*
* @return 压缩后的数据
*/

static void *jk_libzOpen()
{
static void *libz;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
libz = dlopen("/usr/lib/libz.dylib", RTLD_LAZY);
});
return libz;
}

- (NSData *)jk_gzippedDataWithCompressionLevel:(float)level
{
if ([self length])
if (self.length == 0 || [self jk_isGzippedData])
{
return self;
}

void *libz = jk_libzOpen();
int (*deflateInit2_)(z_streamp, int, int, int, int, int, const char *, int) =
(int (*)(z_streamp, int, int, int, int, int, const char *, int))dlsym(libz, "deflateInit2_");
int (*deflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "deflate");
int (*deflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "deflateEnd");

z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
stream.avail_in = (uint)self.length;
stream.next_in = (Bytef *)(void *)self.bytes;
stream.total_out = 0;
stream.avail_out = 0;

static const NSUInteger ChunkSize = 16384;

NSMutableData *output = nil;
int compression = (level < 0.0f)? Z_DEFAULT_COMPRESSION: (int)(roundf(level * 9));
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK)
{
z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
stream.avail_in = (uint)[self length];
stream.next_in = (Bytef *)[self bytes];
stream.total_out = 0;
stream.avail_out = 0;

int compression = (level < 0.0f) ? Z_DEFAULT_COMPRESSION : (int)roundf(level * 9);
if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK)
output = [NSMutableData dataWithLength:ChunkSize];
while (stream.avail_out == 0)
{
NSMutableData *data = [NSMutableData dataWithLength:SCFW_CHUNK_SIZE];
while (stream.avail_out == 0)
if (stream.total_out >= output.length)
{
if (stream.total_out >= [data length])
{
data.length += SCFW_CHUNK_SIZE;
}
stream.next_out = [data mutableBytes] + stream.total_out;
stream.avail_out = (uint)([data length] - stream.total_out);
deflate(&stream, Z_FINISH);
output.length += ChunkSize;
}
deflateEnd(&stream);
data.length = stream.total_out;
return data;
stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out;
stream.avail_out = (uInt)(output.length - stream.total_out);
deflate(&stream, Z_FINISH);
}
deflateEnd(&stream);
output.length = stream.total_out;
}
return nil;

return output;
}

/**
* @brief GZIP压缩 压缩级别
*
* @return 压缩后的数据
*/
- (NSData *)jk_gzippedData
{
return [self jk_gzippedDataWithCompressionLevel:-1.0f];
}

/**
* @brief GZIP解压
*
* @return 解压后数据
*/
- (NSData *)jk_gunzippedData
{
if ([self length])
if (self.length == 0 || ![self jk_isGzippedData])
{
z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.avail_in = (uint)[self length];
stream.next_in = (Bytef *)[self bytes];
stream.total_out = 0;
stream.avail_out = 0;

NSMutableData *data = [NSMutableData dataWithLength: [self length] * 1.5];
if (inflateInit2(&stream, 47) == Z_OK)
return self;
}

void *libz = jk_libzOpen();
int (*inflateInit2_)(z_streamp, int, const char *, int) =
(int (*)(z_streamp, int, const char *, int))dlsym(libz, "inflateInit2_");
int (*inflate)(z_streamp, int) = (int (*)(z_streamp, int))dlsym(libz, "inflate");
int (*inflateEnd)(z_streamp) = (int (*)(z_streamp))dlsym(libz, "inflateEnd");

z_stream stream;
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.avail_in = (uint)self.length;
stream.next_in = (Bytef *)self.bytes;
stream.total_out = 0;
stream.avail_out = 0;

NSMutableData *output = nil;
if (inflateInit2(&stream, 47) == Z_OK)
{
int status = Z_OK;
output = [NSMutableData dataWithCapacity:self.length * 2];
while (status == Z_OK)
{
int status = Z_OK;
while (status == Z_OK)
if (stream.total_out >= output.length)
{
if (stream.total_out >= [data length])
{
data.length += [self length] * 0.5;
}
stream.next_out = [data mutableBytes] + stream.total_out;
stream.avail_out = (uint)([data length] - stream.total_out);
status = inflate (&stream, Z_SYNC_FLUSH);
output.length += self.length / 2;
}
if (inflateEnd(&stream) == Z_OK)
stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out;
stream.avail_out = (uInt)(output.length - stream.total_out);
status = inflate (&stream, Z_SYNC_FLUSH);
}
if (inflateEnd(&stream) == Z_OK)
{
if (status == Z_STREAM_END)
{
if (status == Z_STREAM_END)
{
data.length = stream.total_out;
return data;
}
output.length = stream.total_out;
}
}
}
return nil;

return output;
}

- (BOOL)jk_isGzippedData
{
const UInt8 *bytes = (const UInt8 *)self.bytes;
return (self.length >= 2 && bytes[0] == 0x1f && bytes[1] == 0x8b);
}


@end
19 changes: 19 additions & 0 deletions JKCategories/JKCategories.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// JKCategories.h
// JKCategories
//
// Created by Jakey on 16/5/30.
// Copyright © 2016年 www.skyfox.org. All rights reserved.
//

#ifndef JKCategories_h
#define JKCategories_h

#import "JKUIKit.h"
#import "JKQuartzCore.h"
#import "JKCoreData.h"
#import "JKFoundation.h"
#import "JKMapKit.h"
#import "JKCoreLocation.h"

#endif /* JKCategories_h */
20 changes: 20 additions & 0 deletions JKCategories/JKCoreData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// JKCoreData.h
// JKCategories
//
// Created by Jakey on 16/5/29.
// Copyright © 2016年 www.skyfox.org. All rights reserved.
//

#ifndef JKCoreData_h
#define JKCoreData_h

#import "NSFetchRequest+JKExtensions.h"
#import "NSManagedObject+JKDictionary.h"
#import "NSManagedObject+JKExtensions.h"
#import "NSManagedObjectContext+JKExtensions.h"
#import "NSManagedObjectContext+JKFetching.h"
#import "NSManagedObjectContext+JKFetchRequestsConstructors.h"
#import "NSManagedObjectContext+JKObjectClear.h"

#endif /* JKCoreData_h */
Loading

0 comments on commit 6ec1750

Please sign in to comment.