Commit 036f80dc authored by hl's avatar hl

update

parent b9e40046
//
// CheckView.h
// PhotoEdit3
//
// Created by 甘瑞文 on 2019/9/19.
// Copyright © 2019 甘瑞文. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CheckView : UIView
@property (nonatomic, strong) NSMutableArray<NSMutableDictionary *> *data;
- (instancetype)initWithFrame:(CGRect)frame data:(NSMutableArray<NSMutableDictionary *> *)data;
@end
NS_ASSUME_NONNULL_END
//
// CheckView.m
// PhotoEdit3
//
// Created by 甘瑞文 on 2019/9/19.
// Copyright © 2019 甘瑞文. All rights reserved.
//
#import "CheckView.h"
#import "Utils.h"
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define RGB(r,g,b,a) [UIColor colorWithRed:(double)r/255.0f green:(double)g/255.0f blue:(double)b/255.0f alpha:a]
@interface CheckView ()
{
NSInteger _index;
}
@property (nonatomic, strong) UIView *correctView;
@property (nonatomic, strong) UIScrollView *questionView;
@property (nonatomic, strong) NSMutableArray<UIButton *> *correctButtons;
@property (nonatomic, strong) NSMutableArray<UIButton *> *questionButtons;
@end
@implementation CheckView
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame data:(NSMutableArray<NSMutableDictionary *> *)data
{
self = [super initWithFrame:frame];
if (self) {
_data = data;
// self.data = [Utils dictionaryWithJsonString:@"{\"images\":[{\"origImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\",\"editedImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\"},{\"origImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\",\"editedImage\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1568953445781&di=f58fdbbabd748ddafbdbdcbd58167b36&imgtype=0&src=http%3A%2F%2Foss.aliyuncs.com%2Fmsimage%2FUpload%2Fwww.kashangwl.com%2FCooperationLink%2F9ccc1233-d045-4fb1-9892-5f70a6a48abf.png\"}],\"questions\":[{\"name\":\"1\",\"status\":0},{\"name\":\"2\",\"status\":0},{\"name\":\"3\",\"status\":0},{\"name\":\"4\",\"status\":0},{\"name\":\"5\",\"status\":0}]}"][@"questions"];
self.backgroundColor = [UIColor blackColor];
self.alpha = 0.7;
[self configUI];
}
return self;
}
- (void)configUI
{
[self setupCorrectView];
[self setupQuestionView];
}
- (void)setupCorrectView
{
self.correctView.frame = CGRectMake(0, 20, self.frame.size.width, 60);
NSArray *normalImages = @[@"正确-未选中.png", @"半对-未选中.png", @"错误-未选中.png"];
NSArray *selectImages = @[@"正确-选中.png", @"半对-选中.png", @"错误-选中.png"];
for (int i = 0; i < normalImages.count; i ++) {
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.bounds = CGRectMake(0, 0, 40, 40);
[btn setImage:[UIImage imageNamed:normalImages[i]] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:selectImages[i]] forState:UIControlStateSelected];
btn.center = CGPointMake((SCREEN_WIDTH / 3) / 2 + (SCREEN_WIDTH / 3) * i, 30);
// int status = [self.data[i][@"status"] intValue];
// btn.tag = 10 + status;
if (i == 0) {
btn.tag = 100 + 10;
}
if (i == 1) {
btn.tag = 60 + 10;
}
if (i == 2) {
btn.tag = -1 + 10;
}
[btn addTarget:self action:@selector(check:) forControlEvents:UIControlEventTouchUpInside];
// [self chooseCorrect:status];
[self.correctView addSubview:btn];
[self.correctButtons addObject:btn];
}
[self addSubview:self.correctView];
}
- (void)setupQuestionView
{
self.questionView.frame = CGRectMake(0, 150 - 40, SCREEN_WIDTH, 40);
for (int i = 0; i < self.data.count; i ++) {
NSMutableDictionary *dic = self.data[i];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:dic[@"name"] forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont systemFontOfSize:11];
if (i == 0) {
btn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
}
btn.tag = 20 + i;
btn.bounds = CGRectMake(0, 0, 60, 40);
btn.center = CGPointMake(i * 60 + 30, 20);
[btn addTarget:self action:@selector(chooseQuestion:) forControlEvents:UIControlEventTouchUpInside];
[self chooseCorrectBtn:btn status:[dic[@"status"] intValue]];
if (i < self.data.count - 1) {
UIView *line = [[UIView alloc] init];
line.backgroundColor = [UIColor whiteColor];
line.bounds = CGRectMake(0, 0, 1, 15);
line.center = CGPointMake(i * 60 + 60, 20);
[self.questionView addSubview:line];
}
[self.questionView addSubview:btn];
[self.questionButtons addObject:btn];
}
self.questionView.contentSize = CGSizeMake(60 * self.data.count, 40);
[self addSubview:self.questionView];
}
- (void)chooseCorrectBtn:(UIButton *)btn status:(NSInteger )status
{
switch (status) {
case 100:
//全对
[btn setTitleColor:RGB(142, 195, 31, 1) forState:UIControlStateNormal];
break;
case 60:
//半对
[btn setTitleColor:RGB(171, 115, 37, 1) forState:UIControlStateNormal];
break;
case -1:
//错误
[btn setTitleColor:RGB(169, 88, 89, 1) forState:UIControlStateNormal];
break;
case 0:
//未编辑
break;
default:
break;
}
}
- (void)selectQuestion:(NSInteger)status
{
for (UIButton *btn in self.correctButtons) {
[btn setSelected:NO];
}
switch (status) {
case 100:
//全对
[self.correctButtons[0] setSelected:YES];
break;
case 60:
//半对
[self.correctButtons[1] setSelected:YES];
break;
case -1:
//错误
[self.correctButtons[2] setSelected:YES];
break;
case 0:
//未编辑
break;
default:
break;
}
}
#pragma mark - action
- (void)check:(UIButton *)sender
{
for (UIButton *btn in self.correctButtons) {
[btn setSelected:NO];
}
[self.data[_index] setObject:@(sender.tag - 10) forKey:@"status"];
[self chooseCorrectBtn:self.questionButtons[_index] status:sender.tag - 10];
[sender setSelected:YES];
//选择后要跳到下一题
if (_index == self.questionButtons.count - 1) {
return;
}
[self chooseQuestion:self.questionButtons[_index + 1]];
}
- (void)chooseQuestion:(UIButton *)sender
{
_index = sender.tag - 20;
for (UIButton *btn in self.questionButtons) {
[UIView animateWithDuration:0.5 animations:^{
btn.titleLabel.font = [UIFont systemFontOfSize:11];
}];
}
sender.titleLabel.font = [UIFont boldSystemFontOfSize:15];
[self selectQuestion:[self.data[_index][@"status"] integerValue]];
}
#pragma mark - setter
- (void)setData:(NSMutableDictionary *)data
{
_data = data;
}
#pragma mark - getter
- (UIView *)correctView
{
if (!_correctView) {
_correctView = [[UIView alloc] init];
}
return _correctView;
}
- (UIScrollView *)questionView
{
if (!_questionView) {
_questionView = [[UIScrollView alloc] init];
_questionView.showsVerticalScrollIndicator = NO;
_questionView.showsHorizontalScrollIndicator = NO;
}
return _questionView;
}
- (NSMutableArray *)correctButtons
{
if (!_correctButtons) {
_correctButtons = [[NSMutableArray alloc] init];
}
return _correctButtons;
}
- (NSMutableArray *)questionButtons
{
if (!_questionButtons) {
_questionButtons = [[NSMutableArray alloc] init];
}
return _questionButtons;
}
@end
......@@ -18,11 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly , copy) ImageEditedCallBack callback;
// 设置父视图,如果不设置,就在window 上
@property (nonatomic , strong) UIView *parentView;
+ (ImageEditorManger *) shardInstance;
- (void) showImages:(NSDictionary *)params cb:(ImageEditedCallBack)cb;
@end
......
......@@ -23,11 +23,6 @@
@implementation ImageEditorManger
+ (ImageEditorManger *) shardInstance {
ImageEditorManger *imageEditorManager = [[ImageEditorManger alloc] init];
return imageEditorManager;
}
- (void) showImages:(NSDictionary *)params cb:(ImageEditedCallBack)cb {
ImageEditorModel *model = [ImageEditorModel yy_modelWithJSON:params];
self.editModel = model;
......@@ -70,7 +65,7 @@
lfPhotoEditVC.index = self.browser.currentPage;
lfPhotoEditVC.delegate = self;
lfPhotoEditVC.data = [model yy_modelToJSONObject];
[lfPhotoEditVC setEditImage:[UIImage imageWithData:[Utils imageData:imgData.image()]]];
[lfPhotoEditVC setEditImage:imgData.image()];
[self toEditVC:lfPhotoEditVC];
[self.browser.defaultToolViewHandler.sheetView hideWithAnimation:YES];
} else {
......
......@@ -22,7 +22,7 @@
#define kClipZoom_margin 20.f
CGFloat const lf_editingView_drawLineWidth = 4.f;
CGFloat const lf_editingView_drawLineWidth = 2.f;
CGFloat const lf_editingView_splashWidth = 15.f;
CGFloat const lf_editingView_paintWidth = 50.f;
CGFloat const lf_editingView_stickMinScale = .2f;
......
......@@ -65,7 +65,7 @@ NSString *const kLFDrawViewData = @"LFDrawViewData";
- (void)customInit
{
_lineWidth = 4.f;
_lineWidth = 5.f;
_lineColor = [UIColor redColor];
_slayerArray = [@[] mutableCopy];
_lineArray = [@[] mutableCopy];
......
......@@ -18,7 +18,7 @@ NSString *const LFMediaEditingStrings = @"LFMediaEditingController";
static NSBundle *lfMediaEditingBundle = nil;
if (lfMediaEditingBundle == nil) {
// 这里不使用mainBundle是为了适配pod 1.x和0.x
lfMediaEditingBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LFBaseEditingController class]] pathForResource:@"LFMediaEditingController.bundle/LFMediaEditingController" ofType:@"bundle"]];
lfMediaEditingBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[LFBaseEditingController class]] pathForResource:@"LFMediaEditingController" ofType:@"bundle"]];
}
return lfMediaEditingBundle;
}
......
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
target 'RNGeekImageEditor' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for RNGeekImageEditor
pod 'YYModel'
end
PODS:
- YYModel (1.0.4)
DEPENDENCIES:
- YYModel
SPEC REPOS:
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git:
- YYModel
SPEC CHECKSUMS:
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
PODFILE CHECKSUM: a478606e47509cdbb8ea81bc18fe5abbb9a04752
COCOAPODS: 1.9.1
PODS:
- YYModel (1.0.4)
DEPENDENCIES:
- YYModel
SPEC REPOS:
https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git:
- YYModel
SPEC CHECKSUMS:
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
PODFILE CHECKSUM: a478606e47509cdbb8ea81bc18fe5abbb9a04752
COCOAPODS: 1.9.1
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
# Acknowledgements
This application makes use of the following third party libraries:
## YYModel
The MIT License (MIT)
Copyright (c) 2015 ibireme <ibireme@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated by CocoaPods - https://cocoapods.org
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>The MIT License (MIT)
Copyright (c) 2015 ibireme &lt;ibireme@gmail.com&gt;
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>YYModel</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - https://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>
#import <Foundation/Foundation.h>
@interface PodsDummy_Pods_RNGeekImageEditor : NSObject
@end
@implementation PodsDummy_Pods_RNGeekImageEditor
@end
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
FOUNDATION_EXPORT double Pods_RNGeekImageEditorVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_RNGeekImageEditorVersionString[];
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YYModel"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YYModel/YYModel.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks'
OTHER_LDFLAGS = $(inherited) -framework "CoreFoundation" -framework "Foundation" -framework "YYModel"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module Pods_RNGeekImageEditor {
umbrella header "Pods-RNGeekImageEditor-umbrella.h"
export *
module * { export * }
}
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YYModel"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/YYModel/YYModel.framework/Headers"
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' '@executable_path/../../Frameworks'
OTHER_LDFLAGS = $(inherited) -framework "CoreFoundation" -framework "Foundation" -framework "YYModel"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
PODS_ROOT = ${SRCROOT}/Pods
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
#import <Foundation/Foundation.h>
@interface PodsDummy_YYModel : NSObject
@end
@implementation PodsDummy_YYModel
@end
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "NSObject+YYModel.h"
#import "YYClassInfo.h"
#import "YYModel.h"
FOUNDATION_EXPORT double YYModelVersionNumber;
FOUNDATION_EXPORT const unsigned char YYModelVersionString[];
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YYModel
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "CoreFoundation" -framework "Foundation"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/YYModel
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
framework module YYModel {
umbrella header "YYModel-umbrella.h"
export *
module * { export * }
}
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/YYModel
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
OTHER_LDFLAGS = $(inherited) -framework "CoreFoundation" -framework "Foundation"
PODS_BUILD_DIR = ${BUILD_DIR}
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
PODS_ROOT = ${SRCROOT}
PODS_TARGET_SRCROOT = ${PODS_ROOT}/YYModel
PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
SKIP_INSTALL = YES
USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//
// YYClassInfo.h
// YYModel <https://github.com/ibireme/YYModel>
//
// Created by ibireme on 15/5/9.
// Copyright (c) 2015 ibireme.
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
NS_ASSUME_NONNULL_BEGIN
/**
Type encoding's type.
*/
typedef NS_OPTIONS(NSUInteger, YYEncodingType) {
YYEncodingTypeMask = 0xFF, ///< mask of type value
YYEncodingTypeUnknown = 0, ///< unknown
YYEncodingTypeVoid = 1, ///< void
YYEncodingTypeBool = 2, ///< bool
YYEncodingTypeInt8 = 3, ///< char / BOOL
YYEncodingTypeUInt8 = 4, ///< unsigned char
YYEncodingTypeInt16 = 5, ///< short
YYEncodingTypeUInt16 = 6, ///< unsigned short
YYEncodingTypeInt32 = 7, ///< int
YYEncodingTypeUInt32 = 8, ///< unsigned int
YYEncodingTypeInt64 = 9, ///< long long
YYEncodingTypeUInt64 = 10, ///< unsigned long long
YYEncodingTypeFloat = 11, ///< float
YYEncodingTypeDouble = 12, ///< double
YYEncodingTypeLongDouble = 13, ///< long double
YYEncodingTypeObject = 14, ///< id
YYEncodingTypeClass = 15, ///< Class
YYEncodingTypeSEL = 16, ///< SEL
YYEncodingTypeBlock = 17, ///< block
YYEncodingTypePointer = 18, ///< void*
YYEncodingTypeStruct = 19, ///< struct
YYEncodingTypeUnion = 20, ///< union
YYEncodingTypeCString = 21, ///< char*
YYEncodingTypeCArray = 22, ///< char[10] (for example)
YYEncodingTypeQualifierMask = 0xFF00, ///< mask of qualifier
YYEncodingTypeQualifierConst = 1 << 8, ///< const
YYEncodingTypeQualifierIn = 1 << 9, ///< in
YYEncodingTypeQualifierInout = 1 << 10, ///< inout
YYEncodingTypeQualifierOut = 1 << 11, ///< out
YYEncodingTypeQualifierBycopy = 1 << 12, ///< bycopy
YYEncodingTypeQualifierByref = 1 << 13, ///< byref
YYEncodingTypeQualifierOneway = 1 << 14, ///< oneway
YYEncodingTypePropertyMask = 0xFF0000, ///< mask of property
YYEncodingTypePropertyReadonly = 1 << 16, ///< readonly
YYEncodingTypePropertyCopy = 1 << 17, ///< copy
YYEncodingTypePropertyRetain = 1 << 18, ///< retain
YYEncodingTypePropertyNonatomic = 1 << 19, ///< nonatomic
YYEncodingTypePropertyWeak = 1 << 20, ///< weak
YYEncodingTypePropertyCustomGetter = 1 << 21, ///< getter=
YYEncodingTypePropertyCustomSetter = 1 << 22, ///< setter=
YYEncodingTypePropertyDynamic = 1 << 23, ///< @dynamic
};
/**
Get the type from a Type-Encoding string.
@discussion See also:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html
@param typeEncoding A Type-Encoding string.
@return The encoding type.
*/
YYEncodingType YYEncodingGetType(const char *typeEncoding);
/**
Instance variable information.
*/
@interface YYClassIvarInfo : NSObject
@property (nonatomic, assign, readonly) Ivar ivar; ///< ivar opaque struct
@property (nonatomic, strong, readonly) NSString *name; ///< Ivar's name
@property (nonatomic, assign, readonly) ptrdiff_t offset; ///< Ivar's offset
@property (nonatomic, strong, readonly) NSString *typeEncoding; ///< Ivar's type encoding
@property (nonatomic, assign, readonly) YYEncodingType type; ///< Ivar's type
/**
Creates and returns an ivar info object.
@param ivar ivar opaque struct
@return A new object, or nil if an error occurs.
*/
- (instancetype)initWithIvar:(Ivar)ivar;
@end
/**
Method information.
*/
@interface YYClassMethodInfo : NSObject
@property (nonatomic, assign, readonly) Method method; ///< method opaque struct
@property (nonatomic, strong, readonly) NSString *name; ///< method name
@property (nonatomic, assign, readonly) SEL sel; ///< method's selector
@property (nonatomic, assign, readonly) IMP imp; ///< method's implementation
@property (nonatomic, strong, readonly) NSString *typeEncoding; ///< method's parameter and return types
@property (nonatomic, strong, readonly) NSString *returnTypeEncoding; ///< return value's type
@property (nullable, nonatomic, strong, readonly) NSArray<NSString *> *argumentTypeEncodings; ///< array of arguments' type
/**
Creates and returns a method info object.
@param method method opaque struct
@return A new object, or nil if an error occurs.
*/
- (instancetype)initWithMethod:(Method)method;
@end
/**
Property information.
*/
@interface YYClassPropertyInfo : NSObject
@property (nonatomic, assign, readonly) objc_property_t property; ///< property's opaque struct
@property (nonatomic, strong, readonly) NSString *name; ///< property's name
@property (nonatomic, assign, readonly) YYEncodingType type; ///< property's type
@property (nonatomic, strong, readonly) NSString *typeEncoding; ///< property's encoding value
@property (nonatomic, strong, readonly) NSString *ivarName; ///< property's ivar name
@property (nullable, nonatomic, assign, readonly) Class cls; ///< may be nil
@property (nullable, nonatomic, strong, readonly) NSArray<NSString *> *protocols; ///< may nil
@property (nonatomic, assign, readonly) SEL getter; ///< getter (nonnull)
@property (nonatomic, assign, readonly) SEL setter; ///< setter (nonnull)
/**
Creates and returns a property info object.
@param property property opaque struct
@return A new object, or nil if an error occurs.
*/
- (instancetype)initWithProperty:(objc_property_t)property;
@end
/**
Class information for a class.
*/
@interface YYClassInfo : NSObject
@property (nonatomic, assign, readonly) Class cls; ///< class object
@property (nullable, nonatomic, assign, readonly) Class superCls; ///< super class object
@property (nullable, nonatomic, assign, readonly) Class metaCls; ///< class's meta class object
@property (nonatomic, readonly) BOOL isMeta; ///< whether this class is meta class
@property (nonatomic, strong, readonly) NSString *name; ///< class name
@property (nullable, nonatomic, strong, readonly) YYClassInfo *superClassInfo; ///< super class's class info
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, YYClassIvarInfo *> *ivarInfos; ///< ivars
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, YYClassMethodInfo *> *methodInfos; ///< methods
@property (nullable, nonatomic, strong, readonly) NSDictionary<NSString *, YYClassPropertyInfo *> *propertyInfos; ///< properties
/**
If the class is changed (for example: you add a method to this class with
'class_addMethod()'), you should call this method to refresh the class info cache.
After called this method, `needUpdate` will returns `YES`, and you should call
'classInfoWithClass' or 'classInfoWithClassName' to get the updated class info.
*/
- (void)setNeedUpdate;
/**
If this method returns `YES`, you should stop using this instance and call
`classInfoWithClass` or `classInfoWithClassName` to get the updated class info.
@return Whether this class info need update.
*/
- (BOOL)needUpdate;
/**
Get the class info of a specified Class.
@discussion This method will cache the class info and super-class info
at the first access to the Class. This method is thread-safe.
@param cls A class.
@return A class info, or nil if an error occurs.
*/
+ (nullable instancetype)classInfoWithClass:(Class)cls;
/**
Get the class info of a specified Class.
@discussion This method will cache the class info and super-class info
at the first access to the Class. This method is thread-safe.
@param className A class name.
@return A class info, or nil if an error occurs.
*/
+ (nullable instancetype)classInfoWithClassName:(NSString *)className;
@end
NS_ASSUME_NONNULL_END
This diff is collapsed.
//
// YYModel.h
// YYModel <https://github.com/ibireme/YYModel>
//
// Created by ibireme on 15/5/10.
// Copyright (c) 2015 ibireme.
//
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
//
#import <Foundation/Foundation.h>
#if __has_include(<YYModel/YYModel.h>)
FOUNDATION_EXPORT double YYModelVersionNumber;
FOUNDATION_EXPORT const unsigned char YYModelVersionString[];
#import <YYModel/NSObject+YYModel.h>
#import <YYModel/YYClassInfo.h>
#else
#import "NSObject+YYModel.h"
#import "YYClassInfo.h"
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment