Notes on fragmented knowledge points in iOS development Han junqiang's blog

Source: Internet
Author: User

Notes on fragmented knowledge points in iOS development Han junqiang's blog

1. Join

Objc_setAssociatedObject is to associate two objects so that one object is part of another object.

2. beginUpdates and endUpdates of tableView

3. Automatic Layout of codes and storyBoard

4. Internationalization and localization, in order to achieve Globalization

5. Tips

You can set the language in which the app runs by setting Scheme. You do not need to reset the system language.

6. New Features of ios8, loading js

If I want to load something like a webpage, I need to dynamically edit the entire webpage and mix texts and texts. However, doing so will lead to very difficult operations, in fact, the server side can solve this problem very well, and it can be done with a Web page. The server only needs to return an html document, and the client can parse it based on this html document.

New Features of WKWebView:

It greatly improves the performance, stability, and functions (the most intuitive manifestation is that loading webpages occupies the memory. When the simulator loads Baidu and open source Chinese websites, WKWebView occupies 23 MB, UIWebView occupies 85 MB );

Allow the JavaScript Nitro library to be loaded and used (restricted in UIWebView );

Supports more HTML5 features;

Provides a rolling update rate of up to 60 FPS and built-in gestures;

Refactor UIWebViewDelegate and UIWebView into 14 classes and 3 protocols

7. Tips

When writing a function, you must determine the data security. In this way, the probability of errors is very small. In particular, you must determine whether the data type is safe and whether it is empty. Otherwise, the program will crash. Note that when writing a function, you must consider multiple aspects and consider the legitimacy of the Code. The parameter is not correct before use. The reliability of the parameter is determined within the function. In this case, you need to judge the validity of these parameters when using the function. If you put down the function, you only need to judge it once.

8. In-APP purchase

9. sqlite

Using sqlite to create an index is an object in a relational database used to store each record. The index aims to speed up Data Reading and integrity check. An index is a structure that sorts the values of one or more columns in a database table. You can use an index to quickly access specific information in a database table.

10. database version update: when a new table needs to be added to an application data table, a new field needs to be inserted into the data, so the database needs to be updated for a long time.

11. umeng statistics

After the application is launched, you can observe the application log files, crash logs, and page recording logs, collect and classify crash logs, and provide error management and analysis tools to help developers better solve problems, this improves application stability and Application quality.

12. can I obtain the language on my mobile phone? Do you know

13. Use webView when using js

[webView stringByEvaluatingJavaScriptFromString:scriptString];
 

14. The server can be used for common device login policies. The server stores all the devices that have logged on to the server.

15. Put all the options related to system preference settings in a file, which is easier to modify.

16. Use vv1_enter-Xcode

Automatically generate comments, that is, xcode plug-in. Run vv1_enter-Xcode to compile and re-open xcode.

17. How to Build the interface using xib

Use the file's owner for association, such as the segue in the storyBoard.

18. How to use multiple storyboards in a project

19. How to Use code and storyBoard or XIB for Automatic Layout

20. XIB Internationalization

First, you need to add the language you want to use in the project, and then select XIB when creating the view. In this way, xcode will automatically create an xib file for you, then select localized in localization in inspector. You must select base at the beginning and select other languages. In this way, you will find that the XIB file has subdirectories, then you can set different language translations in the subdirectory.

21. Tips for tableView

Different types of cells are retrieved based on different identifier settings. You can set identifier to a class name, which saves a lot of trouble and is convenient.

22. Tips

[[UIApplication sharedApplication] setStatusBarHidden:YES];
 

23. Version Control

GitLab and sourceTree are used together to manage the source code and how to configure the source code.

24. Send voice messages

Third-party library opencore-amr

25. Sqlcipher + FMDB, database file encryption

Https://www.zetetic.net/sqlcipher/ios-tutorial/

26. Tips

Image Browsing XHImageViewer

28. Tips

You can set the button event based on the different states of the button, which is equivalent to sending voice information. Press and hold the recording, release the recording, and send the message,

29. Tips

It is useful to set the block pointer variable to private.

30. Function Description

1
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(overtimeRemind) object:nil];

First read this Code:

- (void)viewDidAppear:(BOOL)animated {    [super viewDidAppear:animated];    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showLeft) object:nil];    [self performSelector:@selector(showLeft)];}
 

Why [self defined mselector: @ selector (showLeft)]; The cancelPreviousPerformRequestsWithTarget: self method needs to be called before?

This is because sometimes the showLeft method is implemented through [self defined mselector: @ selector (showLeft)];, there may be a problem of delayed execution or memory leakage:

[NSObject cancelPreviousPerformRequestsWithTarget: self selector: @ selector (showLeft) object: nil];

You can cancel the execution method and continue the execution, effectively avoiding the above two problems.

31. runLoop

For more information about runloop, runloop is a running pool related to multiple threads. It listens to events. If there are new events, runloop listens, the method to be listened to will be executed.

32. Tips

For questions about user portraits, click to zoom in, and other gesture libraries such as ESImageViewController

33. Tips

1
NSString *pullSuccessIdString = [pullSuccessMsgIds componentsJoinedByString:@","];
 

Concatenates each element in the array with a comma into a string.

34. Data Sharing

Multipeer Connectivity Framework for close-range communication. Both parties can communicate with each other after establishing a connection.

35. Problem

Oc does not support multi-inheritance. That is to say, a class can only inherit to one class and cannot inherit from multiple classes. Multi-inheritance can be implemented using protocols. That is to say, a class can inherit multiple protocols, which is equivalent to multi-inheritance for a long time. I can have many protocols and implement them.

36. multipeerConnectivity implementation for file sharing

37. indexPathForSelectedRow

38. How to debug a real machine on another computer

1. Export p12 files

2. Export the description file

3, double-click on another computer to install

39. Problem

1
[[NSBundle mainBundle] pathForResource:@"quickLookWord" ofType:@"docx”];

The file directory cannot be found. [NSBundle mainBundle] The obtained path is the resource file location in the installation path of your program. When adding a file to in xcode, xcode automatically adds the file to your resource file, these files can be viewed in copy Bundle Resources in build Phases of your project. However, due to xcode problems, adding files to cannot be automatically added to your resource files. In this case, you can use the "+" under copy Bundle Resources, manually add the file to your resource file to solve the problem.

40. function implementation

Implement file operations, including close-range File Communication, MC, AirDrop, and file Preview

41. Uniform Type Identifiers (UTIs) Unified identifier (UTIs)

When you share images with other iOS devices, the receiver automatically opens the photo app and loads images. If you are passing a PDF file, the recipient device may prompt you to select an app to open the file, or open the file directly in iBooks. How does iOS know which app is suitable for what type of data?

In the system, Apple uses UTIs to process data type labels. Simply put, a uti is used to indicate specific types of data or files. For example, com.adobe.htm indicates a file, while public.png indicates a PNG image. You can view the complete UTIs list that has been registered in the system. (Love cc cat) the application can open the UTI that has been registered in iOS. Therefore, iOS will open the file with a specific program no matter whether the file is opened or not.

42. operations on the info. plist File

NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];NSString *name = [infoDictionary objectForKey:@"CFBundleName"];NSString *version = [infoDictionary objectForKey:@"CFBundleVersion"];
 

43. URL Scheme

It is something like http: //, ftp: //, afp: //, and so on. Generally, the transmission protocol is used as the URL Scheme. But in fact, you can register any type of URL Scheme in iOS and Mac. When a user accesses your custom URL Scheme link in a browser, the operating system will open your program and respond to this request.

It is very easy to register a custom URL Scheme in a program. There are two main steps: add the URL Scheme you need to register to the Info. plist program, and then add the code to your application to process such requests.

The first step is the same for iOS and Mac applications. The method is as follows:

In Info. plist, add a field named CFBundleURLTypes (URL Types ). Xcode automatically creates a required key: URL Identifier (CFBundleURLName). The value of this key can be assigned to a unique string. It is usually a Reverse Domain Name structure, such as me. venj. myapp. Add a subitem CFBundleURLSchemes (URL Schemes) under the URL Types key. enter the name of the URL Scheme you want to register, such as cloud. You can add multiple URLs to Scheme.

44. Open other apps in my APP

How to open other applications from one application is actually very simple. Open info. plist, add a URL types, expand URL types, expand Item1, change the URL identifier under Item1 to URL Scheme, and expand URL Scheme, modify the content of Item1 to myapp. Other programs can access this custom URL through myapp. It is similar to the following style.

Https://appsto.re/cn/YSJRZ. I

45. Problem

After a constraint is added, you can obtain the value of the constraint if you want to change the constraint. For example, if I set a high constraint of 20 and want to change the high constraint to 40 in the future, what should I do? I need to modify it according to this constraint. Or I need to obtain the value of the constraint according to a certain constraint, so I also need to obtain its value according to the constraint.

46. Constraints on Automatic Layout Modification

If you add constraints to a view, you can modify the constraints to change the previously added constraints.

ContentHightConstraint. constant = 150; constraint before modification

47. Use the disadvantages of the notification center for code comparison

48. Problem

NSTimer cannot be archived for persistence. Only NScode Protocol can be implemented for persistence. Even archiving is difficult. I wonder if there is any way to serialize NSTimer.

49. Tips

After iOS7, we can use the UIFont preferredFontForTextStyle: Class Method to specify a style and make the font size conform to the user-defined font size. Set the font size of the app on your phone. Currently, you can choose from the following six styles:

50. mac terminal commands

Vi file name

Q! Force exit

I edit mode

Esc commend Mode shift + double click z save and release

Cat file name, View File Content

51. Some useful operations of Debug

Screenshots, debug --- view debugging --> take screenshot of iPhone

View frame debug --> show view frame

52. Do you really understand automatic layout?

The Automatic Layout automatically calculates the view frame according to the constraints. Therefore, the constraints you add must ensure that the view frame can be properly calculated. If not, you need to add constraints, that is, you cannot add more or less constraints. If you do not add a height constraint, UILAbel automatically calculates the height for you. In general, you only need to let the Automatic Layout know the frame of the view. If you do not know, an error is reported.

42. Your view has relatively simple layout changes

When you need to generate an animation or dynamically Add a view, autolayout exposes the culprit I think is maddening-Priority conflicts with layout. Autolayout has constraints on the same orientation. For example, they all describe the distance from the edge of superview. If the two constraints have different values but have the same priority, autolayout will report a layout conflict, A constraint will be discarded based on its calculation (the constraint you want may be discarded, and the layout you don't want to see will be retained ). Therefore, when we change the layout, we cannot directly change it like the absolute location of the frame, and only have the unique location information. So how can we deal with this layout conflict? That is, the two approx. bundles with the same description but different values have different priorities. By default, autolayout uses a priority constraint with a large value .? But when we add a higher-priority constraint to change the view layout, what should we do after some operations are completed? In this case, you must delete the constraint with a higher priority .? Therefore, when a view is dynamically changed, my usual practice is to add a default constraint to the control to be changed, but first reduce the priority of this default constraint, add a new constraint2 with a higher priority when the change occurs, and use a Dictionary to cache the constraint2 object in the Code, so that I can delete or re-Add the new object at any time, so that the view can change back and forth.

53. What does AD-hoc do?

The app is being released to the store for testing. That is to say, I add the device of the other party, and I pack the device to the other party. Then the other party can install the ipa file through itune and perform a real machine test, you do not need to install it through xcode.

54. Enumeration definition method

 
enum {     UITableViewCellStyleDefault,     UITableViewCellStyleValue1,     UITableViewCellStyleValue2,     UITableViewCellStyleSubtitle};typedef enum {     UITableViewCellStyleDefault,     UITableViewCellStyleValue1,     UITableViewCellStyleValue2,     UITableViewCellStyleSubtitle} UITableViewCellStyle;typedef NS_ENUM(NSInteger, UITableViewCellStyle) {     UITableViewCellStyleDefault,     UITableViewCellStyleValue1,     UITableViewCellStyleValue2,     UITableViewCellStyleSubtitle};typedef enum {     UITableViewCellStyleDefault,     UITableViewCellStyleValue1,     UITableViewCellStyleValue2,     UITableViewCellStyleSubtitle};typedef NSInteger UITableViewCellStyle;

55. If the data on the page is on the server, and the server information may change at any time. Therefore, we need to ensure that each request data is the most row of data. However, loading data does not inevitably affect the user experience. Therefore, I need to cache data locally. The page first loads local data and then loads data in network requests. After the network request data is successful, update the UI of the newly loaded data.

56. Database Operations

sqlite> CREATE TABLE testtable (first_col integer DEFAULT 0, second_col varchar DEFAULT 'hello');sqlite> CREATE TABLE testtable (first_col integer UNIQUE);sqlite> CREATE TABLE testtable (first_col integer CHECK (first_col < 5));sqlite> ALTER TABLE testtable ADD COLUMN second_col integer;sqlite> CREATE VIEW testview AS SELECT * FROM testtable WHERE first_col > 100;sqlite> CREATE TEMP VIEW tempview AS SELECT * FROM testtable WHERE first_col > 100;sqlite> DROP VIEW testview;
 

57. uitextView: Obtain the cursor position

 
int location = aTextView.selectedRange.location;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.