Skip to content

Commit

Permalink
Consider the form of Class<ChildClass *> *
Browse files Browse the repository at this point in the history
  • Loading branch information
ame authored and ame committed Sep 18, 2017
1 parent 72ffcec commit f350241
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 16 deletions.
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
10 changes: 5 additions & 5 deletions AMEGetterMaker/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12121"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down Expand Up @@ -683,7 +683,7 @@
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
<autoresizingMask key="autoresizingMask"/>
Expand Down Expand Up @@ -739,9 +739,9 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Icon-128" id="O1f-Xm-sGY"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Pik-Kp-jnI">
<rect key="frame" x="174" y="171" width="131" height="17"/>
<rect key="frame" x="170" y="171" width="140" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="ver1.1 build20170831" id="Y82-95-dRP">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="ver1.1.1 build20170918" id="Y82-95-dRP">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
Expand Down
2 changes: 1 addition & 1 deletion AMEGetterMaker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.0</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
Expand Down
15 changes: 12 additions & 3 deletions GetterMaker/AMEGetterMakerTools/AMEGetterMaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,23 @@ - (void)make{
//输出的字符串_objc
- (NSString*)objc_formatGetter:(NSString*)sourceStr{
NSString *myResult;
//@property (nonatomic, strong) NSArray<TJSDestinationModel *> * dataArray
//类名
NSString * className = [sourceStr getStringWithOutSpaceBetweenString1:@")" string2:@"*"];
NSString * className = [sourceStr getStringWithOutSpaceBetweenString1:@")" options1:0 string2:@"*" options2:NSBackwardsSearch];
NSLog(@"className--->%@",className);
if ([className isEqualToString:@""]) {
return @"";
}
NSString * childClass = @"";
if ([className hasSubString:@"<"] && [className hasSubString:@">"]) {
childClass = [NSString stringWithFormat:@"<%@>",[className getStringWithOutSpaceBetweenString1:@"<" options1:0 string2:@">" options2:NSBackwardsSearch]];
className = [className stringByReplacingOccurrencesOfString:childClass withString:@""];
childClass = [childClass stringByReplacingOccurrencesOfString:@"*" withString:@" *"];
}
NSLog(@"childClass---->%@",childClass);
NSLog(@"resetClassName--->%@",className);
//属性名
NSString * uName = [sourceStr getStringWithOutSpaceBetweenString1:@"*" string2:@";"];
NSString * uName = [sourceStr getStringWithOutSpaceBetweenString1:@"*" options1:NSBackwardsSearch string2:@";" options2:NSBackwardsSearch];
if ([uName isEqualToString:@""]) {
return @"";
}
Expand All @@ -122,7 +131,7 @@ - (NSString*)objc_formatGetter:(NSString*)sourceStr{
NSString *underLineName=[NSString stringWithFormat:@"_%@",uName];


NSString *line1 = [NSString stringWithFormat:@"\n- (%@ *)%@{",className,uName];
NSString *line1 = [NSString stringWithFormat:@"\n- (%@%@ *)%@{",className,childClass,uName];
NSString *line2 = [NSString stringWithFormat:@"\n if(!%@){",underLineName];
NSString *line3 = [NSString stringWithFormat:@"\n %@ = ({",underLineName];
NSString *line4 = [NSString stringWithFormat:@"\n %@ * object = [[%@ alloc]init];",className,className];
Expand Down
20 changes: 16 additions & 4 deletions GetterMaker/AMEGetterMakerTools/NSString+AMEGetterMaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@

@interface NSString (AMEGetterMaker)


/**
取两个字符串中间的字符串
获取字符串(首尾)
@param string1 字符串左
@param string2 字符串右
@return 返回中间的字符串
@param string1 字符串1
@param string2 字符串2
@return 返回获取到的字符串
*/
- (NSString *)getStringWithOutSpaceBetweenString1:(NSString *)string1 string2:(NSString *)string2;

/**
获取字符串
@param string1 字符串1
@param options1 字符串1设置
@param string2 字符串2
@param options2 字符串2设置
@return 返回获取到的字符串
*/
- (NSString *)getStringWithOutSpaceBetweenString1:(NSString *)string1 options1:(NSStringCompareOptions)options1 string2:(NSString *)string2 options2:(NSStringCompareOptions)options2;

/**
判断字符串是否有某个字符串
Expand Down
20 changes: 18 additions & 2 deletions GetterMaker/AMEGetterMakerTools/NSString+AMEGetterMaker.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,31 @@
#import "NSString+AMEGetterMaker.h"

@implementation NSString (AMEGetterMaker)

- (NSString *)getStringWithOutSpaceBetweenString1:(NSString *)string1 string2:(NSString *)string2{
NSRange range=[self rangeOfString:string1];
if(range.location==NSNotFound){
NSLog(@"错误的格式或者对象");
return @"";
}
NSString * tempString = [self substringFromIndex:(range.location + range.length)];
range = [tempString rangeOfString:string2];
range = [tempString rangeOfString:string2 options:NSBackwardsSearch];
if(range.location==NSNotFound){
NSLog(@"错误的格式或者对象");
return @"";
}
tempString = [tempString substringToIndex:range.location];
NSString * typeName = [tempString stringByReplacingOccurrencesOfString:@" " withString:@""];
return typeName;
}

- (NSString *)getStringWithOutSpaceBetweenString1:(NSString *)string1 options1:(NSStringCompareOptions)options1 string2:(NSString *)string2 options2:(NSStringCompareOptions)options2{
NSRange range=[self rangeOfString:string1 options:options1];
if(range.location==NSNotFound){
NSLog(@"错误的格式或者对象");
return @"";
}
NSString * tempString = [self substringFromIndex:(range.location + range.length)];
range = [tempString rangeOfString:string2 options:options2];
if(range.location==NSNotFound){
NSLog(@"错误的格式或者对象");
return @"";
Expand Down
2 changes: 1 addition & 1 deletion GetterMaker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit f350241

Please sign in to comment.