zoukankan      html  css  js  c++  java
  • core foundation type property

    class  have a property CGPathRef

    define:

    @property(asign)CGPathRef test;

    need custom setTest method  and check NULL

    https://developer.apple.com/library/mac/documentation/corefoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFRelease

    CFRelease

    Releases a Core Foundation object.

    void CFRelease (
       CFTypeRef cf
    );
    
    Parameters
    cf A CFType object to release. This value must not be NULL

                          

    CFRetain

    Retains a Core Foundation object.

    CFTypeRef CFRetain (
       CFTypeRef cf
    );
    
    Parameters
    cf

    The CFType object to retain. This value must not be NULL

    CFGetRetainCount

    Returns the reference count of a Core Foundation object.

    CFIndex CFGetRetainCount (
       CFTypeRef cf
    );
    
    Parameters
    cf

    The CFType object to examine.

    Return Value

    A number representing the reference count of cf.

    Discussion

    You increment the reference count using the CFRetain function, and decrement the reference count using the CFRelease function.

    This function may useful for debugging memory leaks. You normally do not use this function, otherwise.

    demo CPTColor.h CPTColor.m

    http://core-plot.googlecode.com/hg/documentation/html/iOS/_c_p_t_color_8h_source.html

    https://github.com/core-plot/core-plot/blob/master/framework/Source/CPTColor.m

    core foudation类型的变量一般都为只读,比如cgcolorRef,cgimageRef不是,在core plot中

    CGImageRetain(null);会做NULL校验,而不是CFretain;

    https://github.com/core-plot/core-plot/blob/master/framework/Source/CPTImage.m

    http://core-plot.googlecode.com/hg/documentation/html/iOS/_c_p_t_image_8h_source.html

    -(void)setImage:(CGImageRef)newImage
    {
        if ( newImage != image ) {
            CGImageRetain(newImage);
            CGImageRelease(image);
            image = newImage;
        }
    }
     
    @property (nonatomic, readwrite, assign) CGImageRef image;
     
     

    CGColorRetain

    Increments the retain count of a Quartz color.

    CGColorRef CGColorRetain (
       CGColorRef color
    );
    
    Parameters
    color

    The Quartz color to retain.

    Return Value

    The same color you passed in as the color parameter.

    Discussion

    This function is equivalent to CFRetain, except that it does not cause an error if the color parameter is NULL.

    Availability
    • Available in OS X version 10.3 and later.
    Related Sample Code
    Declared In
    CGColor.h

    CGImageRetain

    Increments the retain count of a bitmap image.

    CGImageRef CGImageRetain (
       CGImageRef image
    );
    
    Parameters
    image

    The image to retain.

    Return Value

    The same image you passed in as the image parameter.

    Discussion

    This function is equivalent to CFRetain, except that it does not cause an error if the image parameter is NULL.

    Availability
    • Available in iOS 2.0 and later.
    Related Sample Code
    Declared In
    CGImage.h

     


  • 相关阅读:
    nginx+keepalived实现负载均衡nginx的高可用
    php7 安装swoole4.0.4
    Cannot find config.m4. Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module的 解决方法
    简析小黑是如何盗取cookie登录用户账号
    一个'&'引起md5签名不一致问题
    linux学习:curl与netcat用法整理
    swoole+websocket+redis实现一对一聊天
    使用COOKIE实现登录 VS 使用SESSION实现登录
    巧用PHP中__get()魔术方法
    用户表分表原理
  • 原文地址:https://www.cnblogs.com/zhangjl/p/3789228.html
Copyright © 2011-2022 走看看