Spit Groove: objective-c anti-human

Source: Internet
Author: User

These days to move a logic from the server to the client, basically is to translate JS into OC. Direct contrast, obviously feel OC is too rotten (for the language itself, iOS app framework does not do)

For example, the following line of JS code:

var Monthtag = bill_year + "-" + bill_month;

After being written as OC, it is very obscure. Of course, with nsmutablestring can have a append method, but the degree of nausea is similar:

NSString *monthtag = [NSString stringwithformat:@ "%@-%@", [NSString stringwithformat:@ "%d", billyear], [NSString stringwithformat:@ "%d", Billmonth]];

Another example is the following line:

Data[tag].total + = Bill.amount;

More unbearable to look directly at:

Nsmutabledictionary *content = [data objectforkey:tag];float total = [[content objectforkey:@ ' total '] floatvalue];float Amount = [[Bill objectforkey:@ "Amount"] floatvalue];total + = amount; [Content Setobject:[nsnumber Numberwithint:total] forkey:@ "Total";

Simply think, OC is difficult to use mainly for several reasons:

1, strong type, and implicit type conversion is not developed, need the programmer to handle

2, a variety of API design is not convenient. Array is still passable, when handling dictionary, very painful. In fact, the programming experience is poor every time we process Nsstring,nsdate,nscalendar.

3, does not support closures (except block), so if you want to split the function, either to pass the parameter, or to define the variable staging, and JS's scope chain is very convenient

Including iOS framework, I feel there are some very poor design, such as: Before IOS8, uialertviewdelegate need to be based on the tag to distinguish multiple alertview, but also through the index to distinguish the button click. By the IOS8, Uialertcontroller was a little better.

To tell the truth, I feel that OC should have left the stage of history if it hadn't been for the Apple hood. Perhaps Apple itself is aware of the problem, and Swift may have improved

Tween: objective-c anti-human

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.