IOS Fish weekly, mainly share the experience and lessons encountered in the development process, high-quality blog, high-quality learning materials, practical development tools, etc. The weekly warehouse is here: github.com/zhangferry/… If you have a good content recommendation, you can submit it through the way of issue. You can also apply to be our resident editor to maintain the weekly. Also can pay attention to the public number: iOS growth road, backstage click into the group communication, contact us, get more content.

The development of Tips

Several useful SQL functions

zhangferry

SQL provides a number of built-in functions for counting and calculating, called Aggregate functions, which return a single value:

The function name The functionality
AVG() Return average
COUNT() Returns the number of rows
SUM() Returns the sum of the corresponding values
MAX() Return maximum value
MIN() Return minimum value
FIRST() Return the first
LAST() Back to the last item

Let’s look at a few examples using SUM as an example.

Calculate the sum of a column of values:

SELECT SUM(score) AS total_score FROM students_table;
Copy the code

For example, in a match, win and loss are used in result respectively to represent win and loss. Win plus one point, loss minus one point. We need to calculate the total score:

SELECT SUM(case when result = 'win' then 1 else - 1 end) as result_score FROM game_table;
Copy the code

If (result = ‘win’, 1, -1)

Remove iOS navigation bar to return button text two schemes

Content: FBY Zhanfei

Plan a

  1. The customUINavigationController
  2. Comply with the<UINavigationBarDelegate>agreement
  3. Implement the following methods:
#pragma mark --------- UINavigationBarDelegate
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPushItem:(UINavigationItem *)item {
    // Set the navigation bar to return button text, Title not nil
    UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:@ "" style:UIBarButtonItemStylePlain target:nil action:nil];
    item.backBarButtonItem = back;
    return YES;
}
Copy the code

Scheme 2

Set the global UIBarButtonItem style to make the text of the return button transparent and invisible.

// Set the text of the navigation back button to transparent, which may cause the problem that the navigation title is not in the center
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateHighlighted];
Copy the code

Plan 3

Add a category to the UIViewController, and then in the load Method swap the ViewDidAppear Method with our Hook Method using Method Swzilling. The code is as follows:

#import "UIViewController+HideNavBackTitle.h"
#import <objc/runtime.h>


@implementation UIViewController (HideNavBackTitle)+ (void)load {
    swizzleMethod([self class].@selector(viewDidAppear:), @selector(ac_viewDidAppear));
}
 
// Set navigation bar to return button text
- (void)ac_viewDidAppear{
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
                                              initWithTitle:@ ""
                                              style:UIBarButtonItemStylePlain
                                              target:self
                                              action:nil];
    [self ac_viewDidAppear];
}

void swizzleMethod(Class class, SEL originalSelector, SEL swizzledSelector)
{
    // the method might not exist in the class, but in its superclass
    Method originalMethod = class_getInstanceMethod(class, originalSelector);
    Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
     
    // class_addMethod will fail if original method already exists
    BOOL didAddMethod = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
     
    // the method doesn’t exist and we just added one
    if (didAddMethod) {
        class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
    }
    else{ method_exchangeImplementations(originalMethod, swizzledMethod); }}@end
Copy the code

Reference: remove iOS navigation bar to return button text three schemes – Exhibition fei

The Bug

Edited by FBY Zhan Fei

Check iOS internationalized text format errors

The problem background

Read failed: Couldn’t parse property list because the input data was in an invalid format

The error message tells us that there is a data format problem. Specific problem appears over there analysis below

Problem analysis

Data format errors generally occur in the following situations:

  • The semicolon at the end is missing
  • Characters use full-corner characters (Chinese characters)
  • I lost theta in the middle
  • Missing double quotes or quotes that don’t come in pairs
  • Unnecessary special characters appear in the text

This is a small problem, mainly to see how to quickly find out the problem, the following two methods:

1. Use the plutil command line tool delivered with the system

Plutil is used for checksum modification of plist files. Plutil is also used for checksum modification of strings files in multiple languages.

$ plutil -lint path/Localizable.strings
Copy the code

Because it is a scripting tool, it can be very convenient for batch processing.

2, with GUI tool: Localizable

Localizable is a desktop tool for Mac. You can search for Localizable in the store and use it in a simple way. You just need to drag the Localizable. It’s very convenient.

Reference: iOS international text format error – exhibition fei

Programming concepts

BootStrap

zhangferry

At present, Web applications are widely used on multiple platforms such as PC, Pad, and mobile terminal, but the layout styles of each terminal differ greatly. It is necessary to describe the layout in a unified way, which is one of the main functions of BootStrap.

BootStrap was originally developed by Twitter and later open-source on Github. In addition to solving the problem of unified layout of different ends, it also encapsulates many reusable components, such as drop-down menus, popboxes, etc., which can be directly called. It also provides an elegant SET of HTML + CSS specifications that unify the code style.

There are a lot of front-end frameworks, but they all revolve around HTML + CSS + JavaScript. React and Vue mentioned in the previous article work at the JavaScript layer, while BootStrap mainly works at the HTML and CSS layer.

This site is a collection of bootstrap-based sites: www.youzhan.org/

What is a Webpack

Content sorting: division size haiteng

Web applications have become more complex and large in recent years, with complex JavaScript code and a host of dependency packages. A number of good practices have emerged from the front-end community to simplify development:

  • Modularity allows us to break down complex programs into smaller files.
  • Development languages like TypeScript, which extend JavaScript, allow us to implement features that are not directly available in current versions of JavaScript, and then convert them to JavaScript files that browsers can recognize.
  • CSS preprocessors such as SCSS and LESS;

These improvements have made development much more efficient, but they often require additional processing to be recognized by the browser, and manual processing can be tedious, which is why tools like Webpack are needed.

The front page of its official website vividly illustrates what Webpack is, as follows:

It is a static module packaging tool for modern JavaScript applications. When Webpack works with an application, it internally builds a dependency graph that maps to each module required for the project and generates one or more bundles.

Reference: Gwuhaolin/dive-into-Webpack, what is the Webpack packaging tool and its advantages

What is a Flutter

I am xiong Da

Flutter is currently the preferred cross-platform development framework for developers. Launched at Google I/O 2021, Flutter 2.2 extends from mobile devices to the Web, desktop, and embedded devices, achieving full coverage.

The core principle of Flutter is that everything is a widget. Unlike other frameworks that separate views, controllers, layouts, and other properties, Flutter has a consistent unified object model: widgets.

The current iOS UI elements are a combination of UIView + UIViewController + AutoLayout. When it comes to SwiftUI, they are all described by View, similar to the widget of Flutter.

It uses declarative syntax, such as a simple widget padding:

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text("Sample App"),
    ),
    body: Center(
      child: CupertinoButton(
        onPressed: () {
          setState(() { _pressedCount += 1; });
        },
        child: Text('Hello'),
        padding: EdgeInsets.only(left: 10.0, right: 10.0),),),); }Copy the code

The main reason for Flutter’s better performance is that it uses its own rendering engine, which is structured as follows:

Flutter still has some disadvantages, namely that it causes the package body to become larger. Since iOS was introduced, the package size has increased by around 10MB.

Recommended article: Practical Tutorial on Flutter

Good blog

Edit: King Pilaf is here

The theme of this week’s issue is “Principles of Reverse”

Iosre — from the website: iosre.com

An active reverse forum.

IOS reverse (11)- shell breaking principle analysis, active load all framework – from nuggets: a wisp of wind Yang Thousands of miles

Shell smashing this shit – from: not taste salted fishmonger

Talking about reverse first need to understand the shell smashing. What is the “shell” in the end, what is smashing the shell?

How iOS App signatures work — from: Bang’s Blog

I often take this article out to read, every time when it comes to the signature process need to check.

Code Signing — Analysis of the verification mechanism for iOS Code snippets — from the public account: Advanced page

This article on the signature verification is very detailed, using Xnuspy can hook the system page break function, which may be helpful for our future performance analysis.

IOS LLDB reverse debugging analysis and implementation — from the public account: Watch snow College

The __TEXT section is read-only. Can it be changed at run time? Check out this article.

Learning materials

Mimosa

SwiftLee

Link: www.avanderlee.com/

A weekly blog that shares tips and tricks on Swift, iOS and Xcode. The posts are clearly written and easy to understand, with good typography, graphics and animation. It’s worth keeping an eye on. The author is one of the co-authors of Swift for Good. Swift for Good is a new book written by 20 top writers and speakers, with 100% of the proceeds going to charity. You can check it out at 😺.

WWDC21 inside

The annual WWDC is here again! More than 100 developers have signed up to participate in the WWDC 21 internal consultation led by The veteran Driver Weekly, including several editors of The Weekly. We’ll pick the right content based on necessity and situation for in-depth reading and give you a quick look at the sessions that are of interest in WWDC21.

Tools recommended

Brave723

Diffchecker

Address: www.diffchecker.com/

Software status: Free on the Web

introduce

Diffchecker difference comparison tool is a simple to use, use can help users to quickly compare your PDF, text files, documents, photos, graphics, and scanning etc., and simple and intuitive interface, input the contents of two files, then click on the “find difference”, and have absolute security, to ensure the security of your file, With unified differences, character level differences, folder differences, export to PDF, syntax highlighting, file import, no advertising and other advantages.

Contact us

The eleventh issue of Fishing Weekly

The 12th issue of Fishing Weekly

Fishing Weekly Issue 13

Fishing Weekly Issue 14