Programmatically control iPhone OS versions to enable functions for both OS 3.x and 4 - MFMessageComposeViewController problem

后端 未结 6 645
轮回少年
轮回少年 2021-02-06 12:33

In order to support iPhone OS 3.x and 4.0 I programmatically control MFMessageComposeViewController functionality like this (use it only if the OS version is 4.0 or above):

6条回答
  •  不知归路
    2021-02-06 12:58

    Class theClass = NSClassFromString(@"MFMessageComposeViewController");
    MFMessageComposeViewController *controller = theClass ? [[theClass alloc] init] : nil;
    

    You can use the type MFMessageComposeViewController as in:

    MFMessageComposeViewController *controller;
    

    But you cannot use the global object MFMessageComposeViewController as in:

    [MFMessageComposeViewController alloc];
    

    Instead use the class lookup so you are not dependent on the linker:

    [NSClassFromString(@"MFMessageComposeViewController") alloc];
    

提交回复
热议问题