What's more about IOs: the trivial aspects of development

Source: Internet
Author: User

I sorted out some minor issues during development over a month. Of course, there must be more problems,

For example, some of the skills used by the category, some special characters in the Protocol format,

Synchronous to Asynchronous Network processing, data storage, and class design.

In fact, the technical content of most IOS Internet applications is not very profound, and later I found that some applications that require perfect UI controls, network programming and logic processing,

There is more experience and accumulation.

There are several early problems here, that is, some problems in the first week of a development project. I still keep a record, and the progress in the next month will be too busy to record.

1. Automatically wrap the line when multiple rows are displayed in uilabel.

label.numberOfLines =0; label.lineBreakMode = UILineBreakModeWordWrap;

The premise is that the frame set by the label is large enough. Scroll is not supported.

This is not supported theoretically, because the textview control is relatively better.

2. Differences between nil and release

Nil and release:
Nil sets the pointer of an object to null, but disconnects the pointer from the object in memory;
The release actually notifies the memory to release this object.

Therefore, nil does not release the memory. Only release can actually release the memory.
Analyze the order of use of the two:
If there is no release, nil will be used directly, so although there will be no errors, it is equivalent to self-built Memory leakage, because the release will no longer work after nil.

On the contrary, if only release is used when the interface object is used, self. myoutlet = is not set.
Nil, then the program may not report errors, but it will be very unstable, not robust, it is easy to crash.

Because after an interface object is release, the memory allocated to it has been released. if the object is used by the system after it is released, the program will crash.

If the pointer is set to null after the object is released, the system will not crash even if the subsequent program uses the object.

3. Get the current time and format

NSString *postTime;    NSDateFormatter *formatter = [[NSDateFormatteralloc] init];    [formatter setDateFormat:@"YYYYMMddhhmmss"];    postTime = [formatter stringFromDate:[NSDatedate]];

4. Clever Use of macros and efficient preprocessing

5. An error occurs when filemerger cannot find the path on version control tool versions: versions.

The application will remind you to reinstall it, saying that this tool is not installed, but we can find that the application has been installed in xcode.
Finally, I checked it online and said it was an xcode version upgrade problem, which caused the Application Path to be the same. At that time, versions did not change the filemerge path by default.
Zookeeper upgrades xcode to 4.3.2 and finds that the versions file cannot be used in comparison. Because xcode is packaged into an app after version 4.3 and placed under/applications, the entire developer/APP has been removed.
Versions cannot find filemerge. app according to the original path. Processing is simple, and the command line is used.
Sudo/usr/bin/xcode-select-switch/applications/xcode. APP/contents/Developer

6. A common format error occurs during project compilation.

Undefined symbols for architecture i386:
"_ Objc_class _ $ _ asihttprequest", referenced from:
Objc-class-ref in asiinputstream. o
_ Objc_class _ $ _ asiformdatarequest in asiformdatarequest. o
Objc-class-ref in asiformdatarequest. o
Objc-class-ref in asinetworkqueue. o
Objc-class-ref in asidownloadcache. o
Objc-class-ref in nlnethelper. o
"_ Objc_metaclass _ $ _ asihttprequest", referenced from:
_ Objc_metaclass _ $ _ asiformdatarequest in asiformdatarequest. o
"_ Networkrequesterrordomain", referenced from:
-[Asiformdatarequest AddFile: withfilename: andcontenttype: forkey:] In
This is an error after building when we introduce a third-party class library file. For example, when _ asihttprequest and sbjson are introduced.
If the above error occurs, the simple method is. Click project, -- build phase s --, compile sources, and click Add. We can see the source files under the project. At this time, we recommend that you see the suffix. M files are all added ~~.
Later I found that my colleagues didn't have any problems when introducing the file. I was reminded to find a problem that was always ignored by me. When I dragged the file in, we usually chose to copy it instead of introducing it, this is okay, but the following sea is a beneficiation, addtarget. This is why I guess it is related to some project configurations.

7. Question about null in IOS client interaction on Java Server

When parsing JSON in IOS network operations, there is sometimes such a situation: "mything": NULL;
However, mything is divided into: 1, which is a dictionary when returned; 2. If no content exists, null is returned.
Then, when processing on the client, we need to determine whether the Buddha is null to perform the corresponding resolution (if null is still resolved to this custom, an error will be reported), but only one sentence, if (DIC) not trial.
Required [DIC isequal: [nsnull null]

This is actually a difference between NULL pointer and empty content. In general, we are determining that nil is used for pointer null, while nsnull is used for content null.

8. Determine whether a contains B.

Currently, the inclusion function in Java is not found.
OC provides a rangeofstring. Then let's look at the length.

9. Interaction between viewcontrollers and Data Transmission

In Android, we know that two activities can be transmitted using bundle. In iOS, many solutions are provided.

However, we found that the simplest one is to declare such an attribute in the second viewcontroller,

After initializing the second VC in the first viewcontroller, set the data to be passed ~

Of course, it is appropriate to store a global or Singleton class in some cases.

10. Wonderful use and tips of nsnotificationcenter

[[Nsicationcenter center defacenter center] addobserver: Self selector: @ selector (refeshlogin) Name: @ "login" Object: Nil];

Message registration and listening, as well as sending a notification to call post to send and then listen for processing.

I think it is wonderful to make good use of this class.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.