Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
BB9z committed Jun 10, 2018
2 parents cd97598 + da2d57b commit 8f4d40c
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ matrix:
env: RFCI_TASK="Xcode8"
before_install:
- pod repo update master --silent
script: ./.travis.sh MAIN
script: travis_wait ./.travis.sh MAIN
after_success: ./.travis.sh SUCCESS
after_failure: ./.travis.sh FAILURE
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# RFKit Changelog

## 2.2.0

* API Enhancements:
* RFFoundation, add guard define for `NS_STRING_ENUM` and `NS_EXTENSIBLE_STRING_ENUM`.
* dout, add `RFDebugger()` as an alternative to Debugger().
* New UIPickerView+RFKit, with `rf_selectRow:inComponent:animated:`.

## 2.1.0

* **Breaking Changes:**
Expand Down
46 changes: 39 additions & 7 deletions RFFoundation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@

#pragma mark Xcode 9

// Memo:
// Xcode 9.3
// SE-0075: #if canImport()
// SE-0190: #if targetEnvironment()

// Xcode 9.0
// SE–0168: multiline string literals """
// SE–0161: type-safe key path literals \BaseType.propertyName
// 7184689: @available in Objective-C
// 21359084: #pragma pack

#pragma mark Xcode 8
// Xcode 8, with macOS 10.12 and iOS 10 SDK
// https://developer.apple.com/library/content/releasenotes/Miscellaneous/RN-Foundation-OSX10.12/index.html

#ifndef NS_NOESCAPE
# if __has_attribute(noescape)
Expand All @@ -36,6 +41,14 @@
# endif
#endif

#ifndef NS_STRING_ENUM
# define NS_STRING_ENUM
#endif

#ifndef NS_EXTENSIBLE_STRING_ENUM
# define NS_EXTENSIBLE_STRING_ENUM
#endif

// API available
#ifndef API_AVAILABLE
# define API_AVAILABLE(...)
Expand All @@ -61,21 +74,40 @@
# define TARGET_OS_TV 0
#endif

// Memo:
// 23891898: class properties
// 26921435: __swift__ macro
// Xcode 8, with macOS 10.12 and iOS 10 SDK
// https://developer.apple.com/library/content/releasenotes/Miscellaneous/RN-Foundation-OSX10.12/index.html

// Xcode 8.3
// SE-0141, SR-2709: @available

// Xcode 8.1
// 28694859: __weak in MRC
// 26921435: __swift__ macro

// Xcode 8.0
// 23891898: class properties
// SE-0064: property getter or setter in #selector
// SE-0062: #keyPath
// SE-0034: #sourceLocation

#pragma mark Xcode 7

// Xcode 7: 19240897
// Xcode 7.0: 19240897
#ifndef NS_SWIFT_NAME
# define NS_SWIFT_NAME(...)
#endif

// Xcode release note
// https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html

// Xcode 7.3
// SE-0020: #if swift
// SE-0028: #file, #line, #column, #function
// SE-0022: #selector

// Xcode 7.0
// 19589424: __kindof

#pragma mark Unknow
// Introduction version Unknow

Expand Down
2 changes: 1 addition & 1 deletion RFKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

#ifndef RFKit_h
#define RFKit_h 2.1
#define RFKit_h 2.2

#import "RFRuntime.h"
#import "RFGeometry.h"
Expand Down
9 changes: 8 additions & 1 deletion RFKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RFKit'
s.version = '2.1.0'
s.version = '2.2.0'
s.summary = 'Tool kit for daily cocoa development.'
s.homepage = 'https://github.com/BB9z/RFKit'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down Expand Up @@ -124,6 +124,7 @@ Pod::Spec.new do |s|
ssp.ios.dependency 'RFKit/Category/UIAlertView'
ssp.ios .dependency 'RFKit/Category/NSLayoutConstraint'
ssp.tvos.dependency 'RFKit/Category/NSLayoutConstraint'
ssp.ios .dependency 'RFKit/Category/UIPickerView'
ssp.ios .dependency 'RFKit/Category/UIScrollView+RFScrolling'
ssp.tvos.dependency 'RFKit/Category/UIScrollView+RFScrolling'
ssp.ios .dependency 'RFKit/Category/UISearchBar'
Expand Down Expand Up @@ -256,6 +257,12 @@ Pod::Spec.new do |s|
ssp.dependency 'RFKit/Category/NSArray'
ssp.source_files = 'category/UIKit/UINavigationController+*'
end

ss.subspec 'UIPickerView' do |ssp|
ssp.ios.deployment_target = '6.0'
ssp.dependency 'RFKit/Foundation'
ssp.source_files = 'category/UIKit/UIPickerView+*'
end

ss.subspec 'UIResponder' do |ssp|
ssp.ios.deployment_target = '6.0'
Expand Down
1 change: 1 addition & 0 deletions RFKitDefaultCategories.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#import "UIDevice+RFKit.h"
#import "UIImage+RFKit.h"
#import "UINavigationController+RFKit.h"
//#import "UIPickerView+RFKit.h"
#import "UIResponder+RFKit.h"
//#import "UIScrollView+RFScrolling.h"
//#import "UISearchBar+RFKit.h"
Expand Down
4 changes: 4 additions & 0 deletions Test/RFKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
D5CE8EC5203FADC6000F1C0E /* NSBundle+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CE8EC4203FADC6000F1C0E /* NSBundle+RFKitTests.m */; };
D5CE8EC6203FADC6000F1C0E /* NSBundle+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CE8EC4203FADC6000F1C0E /* NSBundle+RFKitTests.m */; };
D5CE8EC7203FADC6000F1C0E /* NSBundle+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5CE8EC4203FADC6000F1C0E /* NSBundle+RFKitTests.m */; };
D5D6630020B40A4200E55EEB /* UIPickerView+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5D662FF20B40A4200E55EEB /* UIPickerView+RFKitTests.m */; };
D5F50AC22035E3BA0054518C /* NSDateFormatter+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5F50AC12035E3BA0054518C /* NSDateFormatter+RFKitTests.m */; };
D5F50AC32035E3BA0054518C /* NSDateFormatter+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5F50AC12035E3BA0054518C /* NSDateFormatter+RFKitTests.m */; };
D5F50AC42035E3BA0054518C /* NSDateFormatter+RFKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5F50AC12035E3BA0054518C /* NSDateFormatter+RFKitTests.m */; };
Expand Down Expand Up @@ -117,6 +118,7 @@
D5C6F59D20328F7000D1E8DF /* Target_watchOS.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Target_watchOS.m; sourceTree = "<group>"; };
D5C6F5A72032D39500D1E8DF /* NSArray+RFKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+RFKitTests.m"; sourceTree = "<group>"; };
D5CE8EC4203FADC6000F1C0E /* NSBundle+RFKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSBundle+RFKitTests.m"; sourceTree = "<group>"; };
D5D662FF20B40A4200E55EEB /* UIPickerView+RFKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIPickerView+RFKitTests.m"; sourceTree = "<group>"; };
D5F50AC12035E3BA0054518C /* NSDateFormatter+RFKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSDateFormatter+RFKitTests.m"; sourceTree = "<group>"; };
FB69B17BD7CB0E4ADC9CB6BD /* Pods-Test-tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Test-tvOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Test-tvOS/Pods-Test-tvOS.release.xcconfig"; sourceTree = "<group>"; };
FEAF0D436A19807484DA91EC /* libPods-Target-watchOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Target-watchOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -169,6 +171,7 @@
D513B0E62031917C00C62520 /* iOS */ = {
isa = PBXGroup;
children = (
D5D662FF20B40A4200E55EEB /* UIPickerView+RFKitTests.m */,
D513B0E92031917C00C62520 /* Info.plist */,
D57E75D3203EFCB6001BB427 /* UIView+RFKitTests.m */,
);
Expand Down Expand Up @@ -606,6 +609,7 @@
D5722FB1203DAC4800C610E2 /* NSError+RFKitTests.m in Sources */,
D513B0FF2031D0BB00C62520 /* NSFileManager+RFKitTests.m in Sources */,
D57E75C6203E49CF001BB427 /* NSJSONSerialization+RFKitTests.m in Sources */,
D5D6630020B40A4200E55EEB /* UIPickerView+RFKitTests.m in Sources */,
D594688220327D8F00A1AE3D /* NSObject+RFKitTests.m in Sources */,
D57E75CC203E9C0A001BB427 /* NSString+RFKitTests.m in Sources */,
D57E75D0203EB350001BB427 /* NSURL+RFKitTests.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Test/Supporting Files/OCBridgingHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import <RFKit/NSNumberFormatter+RFKit.h>
#import <RFKit/NSString+RFKit.h>
#import <RFKit/NSURL+RFKit.h>
#import <RFKit/UIPickerView+RFKit.h>
#import <RFKit/UIScrollView+RFScrolling.h>
#import <RFKit/UISearchBar+RFKit.h>
#import <RFKit/UIStoryboard+RFKit.h>
Expand Down
5 changes: 5 additions & 0 deletions Test/Test/Swift/SwiftNameTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ class SwiftNameTest: XCTestCase {
nav.setTopView(nil, animated: false)
}

func testUIPickerView() {
let v = UIPickerView()
v.rf_selectRow(0, inComponent: 0, animated: false)
}

func testUIResponder() {
let v = UIView()
let _ = v.viewController
Expand Down
35 changes: 35 additions & 0 deletions Test/Test/iOS/UIPickerView+RFKitTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// UIPickerView+RFKitTests.m
// RFKit
//
// Created by BB9z on 2018/5/22.
// Copyright © 2018 RFUI. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "UIPickerView+RFKit.h"

@interface RTUIPickerView : XCTestCase <
UIPickerViewDataSource
>

@end

@implementation RTUIPickerView

- (void)testSelectRow {
UIPickerView *p = UIPickerView.alloc.init;
p.dataSource = self;
XCTAssertThrows([p selectRow:-1 inComponent:NSNotFound animated:YES]);
XCTAssertNoThrow([p rf_selectRow:5 inComponent:5 animated:YES]);
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
return 2;
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}

@end
29 changes: 29 additions & 0 deletions category/UIKit/UIPickerView+RFKit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*!
UIPickerView extension
RFKit
Copyright (c) 2018 BB9z
https://github.com/BB9z/RFKit
The MIT License (MIT)
http://www.opensource.org/licenses/mit-license.php
*/
#import "RFFoundation.h"
#import <UIKit/UIKit.h>

@interface UIPickerView (RFKit)

/**
Safely selects a row in a specified component of the picker view.
If any index is not in the legal range, this method do nothing.
@param row A zero-indexed number identifying a row of component.
@param component A zero-indexed number identifying a component of the picker view.
@param animated `YES` to animate the selection by spinning the wheel (component) to the new value; if you specify `NO`, the new selection is shown immediately.
*/
- (void)rf_selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated API_AVAILABLE(ios(2.0));

@end
12 changes: 12 additions & 0 deletions category/UIKit/UIPickerView+RFKit.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#import "UIPickerView+RFKit.h"

@implementation UIPickerView (RFKit)

- (void)rf_selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated {
if (component < 0 || component >= self.numberOfComponents) return;
if (row <0 || row >= [self numberOfRowsInComponent:component]) return;
[self selectRow:row inComponent:component animated:animated];
}

@end
14 changes: 11 additions & 3 deletions dout.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

#ifndef DOUT_H
#define DOUT_H 2.10
#define DOUT_H 2.11

#import "RFRuntime.h"

Expand Down Expand Up @@ -193,8 +193,16 @@
#define _dout_warning(...)
#define _dout_error(...)

void DoutLogString(NSString *string);
NSString * DoutCurrentThreadOrQueueName(void);
/**
Debugger() for all platform.
This methiod simulate Debugger() behavior by throwing objective-c exception.
So you should set an exception breakpoint to use it.
*/
FOUNDATION_EXPORT void RFDebugger(NSString *__nullable format, ...) NS_FORMAT_FUNCTION(1, 2);

void DoutLogString(NSString *__nullable string);
NSString *__nonnull DoutCurrentThreadOrQueueName(void);
void _dout_log_config(void);

#endif
13 changes: 13 additions & 0 deletions dout.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
#import "dout.h"
#import <sys/sysctl.h>

void RFDebugger(NSString *format, ...) {
if (format) {
va_list args;
va_start(args, format);
NSLogv(format, args);
va_end(args);
}
@try {
@throw [NSException exceptionWithName:@"pause" reason:@"debug" userInfo:nil];
}
@catch (__unused NSException *exception) { }
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"

Expand Down

0 comments on commit 8f4d40c

Please sign in to comment.