iOS Development Package Custom structure object, Cgrect,cgsize common structure basic use

Source: Internet
Author: User

How can I use OC to encapsulate a struct into nsvalue in iOS?

Here's how:

typedef  struct{  //Custom a struct    int age;    int number;} Student; Nsvalue *stu=[nsvalue valuewithbytes:&stu objctype: @encode (Student)];//encapsulate the structure as an object Student  value2;// Define a struct variable to accept the structure obtained from Nsvalue [Stu getvalue:&value2];//the structure in the Stu object to take out int a=value2.age;  Get the fields in the structure other, the system comes with Cgpoint P=[value  Cgpointvalue];
The system comes with the method of creating nsvalue and acquiring CG structure body values
    Nsvalue *v=[nsvalue valuewithcgrect:cgrectmake (0, 0, 0, 0)];    CGRect rect=[v Cgrectvalue];    Nsvalue *v2=[nsvalue Valuewithcgsize:cgsizezero];    Cgsize size=[v2 Cgsizevalue];    Nsvalue *v3=[nsvalue valuewithcgpoint:cgpointmake (0, 0)];    Cgpoint P=[v3 Cgpointvalue];
Original address:http://blog.csdn.net/yangbingbinga/article/details/43114469

iOS Development Package Custom structure object, Cgrect,cgsize common structure basic use

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.