JYungSiu / Sagit

IOS Develop Framework(Sagittarius 射手座:IOS下的一套基础快速开发框架)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sagit

IOS Develop Framework(Sagittarius 射手座:IOS下的一套基础快速开发框架)

入门教程:http://www.cnblogs.com/cyq1162/category/1130357.html

IOS Sagit框架 :QQ群:702724292


One: The cause of creating the Sagit development framework:

I remember that when IT started the business, I recruited an IOS girl to do development, and then:

----------The accident of the girl started here -----------

1: Interview: There are works, attitude is good, I feel that I should be able to do something.

2: Just recruited: I found the article reading every day, but I didn't see something late.

3: Process Q&A: What are you doing now? The answer is in the framework.

4: Found the crisis: accidentally saw her knocking the keyboard with a single finger, I feel bad.

5: Dealing with the crisis: IOS, after a week, after reading her code, talk Over!

---------- The girl’s accident ended here -----------

In the fast learning IOS, I quickly scanned a lot of training video tutorials and found that the routines are very primitive.

These primitive routines can be understood, but if these come to the project, it will endless harm.

According to the cost of starting a business at the time, the people who came with a high probability were the following three types:

1: Just got out of the training class;

2: Just finished watching the training video;

3: Just skipped after a project with a training video.

In order to be bound by the next developer:

Let a friend with 3-4 years of development experience help the whole frame.

After reading his entire framework, I found that it was just a regular tool class folder.

Give him a request to repackage one of the network requests.

Looking back, although there are improvements, it is still not my intention.

Maybe you can guide to continue to improve, but not with me, not with him.

So I did it myself: when the framework was roughly 60% complete, I recruited a male developer.

----------The boy’s accident started here-----------

In order to catch up with the project, the newcomers started on the basis of the framework.

Given that newcomers can get something, plus the help of a frame, they will be handed.

Due to the imperfection of the frame and the incomprehension of the frame, a small pit is encountered.

There are more spit, and I can only agree that he is mixing the other frames together.

Later, there were countless pits and flashback accidents.

Early attention to IT and the use of IT even the App's children's learning, it is clear.

Or it should be sensible in my previous IT series of entrepreneurial articles.

Now, he is over!

----------The boy’s accident ended here-----------

After re-taking back to IOS, I found that the code logic is also a squad. Fortunately, some of the previous ones still follow the framework.

It took me more than a week to understand and start refactoring the code for the entire project.

At the same time, the existing dependencies of the framework were also removed, and the framework was re-reconstructed.

At present, the reconstruction of the framework has been carried out 70%-80%, and some functions have not been added.

But the whole does not affect the basic functions, so it is time to share the Sagit framework with everyone!

Two: Name the frame:

Since the name of the CYQ.Data framework has been squandered by everyone, the subsequent framework naming has become particularly painstaking.

After studying the English names of planets, constellations, fruits, plants, animals, colors, shapes, etc.

Finally: Aries (DreFrame. For DotNet),

There is again: Taurus.MVC For DotNet

After that: Gemini.workflow For DotNet workflow engine is currently difficult to produce (written at the beginning, and later no time to toss).

Therefore, getting together the Golden Zodiac and calling Athena will become the most mysterious task for me to come to Earth!

This leapfrog was selected: Sagittarius (shooter)

The first is the prefix of ST's prefix just right for the name of the current startup company: with the sky.

Second, take the first half to make the name of the frame, shorthand: Sagit (pronounced: shooting the sun, very harmonious found that there is wood)

Three: The applicable scenario of the framework:

1: Research study:

A: After a few years of work, development is no longer a problem and requires a bit of new thinking to break through the limited bottleneck.

It is not difficult to understand the framework code, mainly to learn thinking, think more, and train yourself how to write.

B: For teachers in the training industry, you can use the framework of thinking to guide new people before the end of training, and then let them out.

2: Project development:

A: Developers don't have the concept of a framework.

B: There are currently no other alternative frameworks.

In general, in addition to games, other regular projects are suitable. 

 

The following is a brief introduction to the framework, which can only be briefly introduced:

Sagit Innovation One: Simple Relative Layout Syntax

1: Unified standard parameters, self-adapting to the phone screen, and implementing AutoLayout.

A: The frame defaults to the IPhone6 ​​pixel as the standard reference system: 750*1334.

B: When developing, the standard pixel unit is used as a parameter.

C: When running, it will automatically adapt to the corresponding proportion of parameters.

(PS: If you need to modify the standard, you can modify the definition in the STDefineUI.h file)

Look at the parameter annotations given by the UI, and easily layout:

2: Concise relative layout syntax, one line

Take the above picture as an example, do layout

A: Relative to the layout of the parent element Logo:

[[[[self addImageView: @" login_logo " ] width: 170 height: 170 ] relate:Top v: 288 ] toCenter:X];

B: Relative to the layout of fixed elements, the following line of code refers to other places:

[[[[self addImageView: @" icon_verify " ] width: 48 height: 48 ] onBottom:pwdIcon y:26] toCenter:X];

3: Partially refreshable layout

The following line of code re-predicts the relative layout of the subview of the approved view.

[self refleshLayout];

 

Sagit Innovation 2: Completely separated View and Controller

I remember a long time ago, I wrote an article: Objective-C iOS pure code layout a bunch of code can be put here!

At that time, it was only a prelude to the study, and did not achieve complete separation. Of course, it is solved now.

For example: a text box with a button, click the button to pop up the contents of the text box.

In the previous practice, you would write a bunch of UI-related creation methods in the Controller, or you need to define some UI as global variables, so as to get the UI values ​​later.

Worst is the end of the hand that I left before I finished: (The red one below, you need to define a specific LoginView variable in the Controller)

Ok, now this problem has been completely solved by me, 0 invasion has become a fact, look at the sample code below:

LoginView's code: created a text box and a click button

@interface LoginView : STView // This is LoginView.h

@end

@implementation LoginView // This is LoginView.m -( void )initUI { [[self addTextField: @" userName " placeholder: @" Enter the phone number " ] x: 0 y: 0 width: 100 height: 100 ]; [[self addButton: @" btnLogin " title: @"login" ] onRight:self.lastSubView.PreView x: 10 ]; } @end

LoginController code: There is a button event, get the phone number username and pop up to prompt

@interface LoginController : STController // This is LoginController.h

@end

@implementation LoginController //This is LoginController.m

-(void)btnLoginClick
{
    NSString* userName=[self uiValue:@"userName"];
    [self.box prompt:userName];
}

transfer:

self.window.rootViewController = [LoginController new ];

Effect: (For the screenshot, deliberately created a new demo...)

Analysis:

There are no references to each other in the two file codes of LoginView and LoginController.

But the UI and events are magically related. How did this happen?

The secret is in the source code of the STView and STController files.

Sagit Innovation 3: Automated submission and echo of forms

If you need to submit data for a form, you only need to do this:

-( void )btnLoginClick
{
//     NSString* userName=[self uiValue:@"userName"];
 //     [self.box prompt:userName]; 
    
    [self.http post: @" /Login " paras:self.formData success:^(STModel * result ) {
         if (result.success) // If: Submitted successfully 
        {
            [self.stView loadData:result.msg]; // Return the returned data to the control 
        }
    }];
}

Analysis:

self.formData can automatically collect the contents of the UI form.

self.stView loadData can automatically write the dictionary data back to the UI.

Everything is like Easy. In this regular submission, batches are sent in batches, and there is no need to have a Model.

The Demo is not available for the time being, and follow-up articles will follow up.

Sagit Other Features One: Unlimited property syntax under the moon:

    UITextField *userName= [[[self addTextField: @" UserName " placeholder: @" 手机号码" ] width: 372 height: 68 ] onRight:mobileIcon x: 30 y:- 10 ];
    [[userName maxLength: 11 ] keyboardType:UIKeyboardTypeNumberPad];

 No need to write this smashed:

mobileTF.keyboardType = UIKeyboardTypeNumberPad; // UIKeyboardTypeNamePhonePad; 
 mobileTF.MaxLength= 11 ; //                     = (id)self.Controller;

Sagit Other Features 2: Encapsulates a simple syntax for C# players

The OC name is always very long. To be a C# god, it is obligatory to bring C#'s simple syntax.

E.g:

@interface NSString(ST)

-(NSString* )reverse; - (BOOL)isInt; - (BOOL)isFloat; -(NSString*)append:(NSString*) string ; -(NSString*)replace:(NSString*)a with:(NSString* ) b; -(NSString )replace:(NSString )a with:(NSString * )b isCase:(BOOL)isCase; -(NSArray<NSString>)split:(NSString* )separator; -(NSString* ) toUpper; -(NSString* )toLower; -(BOOL)startWith:(NSString* )value; -(BOOL)endWith:(NSString* )value; -(BOOL)contains:(NSString* )value; -(BOOL)contains :(NSString* )value isCase:(BOOL)isCase; - (BOOL)isEmpty; +(BOOL)isNilOrEmpty:(NSString* )value; +(NSString*)toString:( id )value; -(NSString*)trim;

Sagit other features...

1: There are only three requests for the network:

[self.http get ...]
[self.http post ...]
[self.http upload ...]

2: Message prompt box:

[self.box prompt...]
[self.box alert..]
[self.box confirm...]

Others, etc. . . It is not introduced here, and the follow-up will slowly write an introduction.

Sagit open source address:

GitHub: https://github.com/cyq1162/Sagit

Currently available in source code, not packaged into a class library.

New: IOS Sagit Framework  : QQ Group: 702724292

to sum up:

1 : The framework is just open source, indicating that in the future, upgrades and changes are indispensable.

2: The framework is just a foundation, a complete project architecture, and it is necessary to match different third-party libraries according to different services.

3: Follow-up will be the IT source and IT love two App source code, as a sample tutorial, and share with everyone.

4: Finally, I am still grateful to everyone for paying attention to my ongoing IT startup project!

About

IOS Develop Framework(Sagittarius 射手座:IOS下的一套基础快速开发框架)

License:GNU Lesser General Public License v3.0


Languages

Language:Objective-C 99.6%Language:C 0.4%