iOS 规范设置指针的一种方法

-(void)setState:(PeriodState *)newState{

      [selfgetRecordState];

      //    int i = 0;

    AppDelegate_iPhone * appDelegate = (AppDelegate_iPhone *)         [[UIApplicationsharedApplication]
delegate];

    // Setting *settinfo= appDelegate.settingObj;

    if(newState !=state){

         [staterelease];

         state = [newStateretain];

    }

}

 

IOS 函数内 autorelease release


在一个有reurn 返回值的函数里 如果申请了一段内存的话(alloc 或者copy) 这个时候不能够release  只能够使用autorelease

在返回到那个被接受到的指针里,由它去进行释放!!

如果是self.obj(或者某些类对应的   SomeClass.obj)这种类型的,就需要把self.去掉(因为这样子的申请出来的内存引用计数会被retain+1了)

如果必须要有类名 SomeClass.   则需要用autorelease!


The kalView analyze


首先搞清楚view的层级关系,怎么样子可以加载在一个view中,kalview又有多少种subview。

首先这里KalView可以知道kalview直接复制到self.view上了。。

KalView *kalView = [[KalViewalloc]
initWithFrame:[[UIScreenmainScreen]
applicationFrame] delegate:self
logic:logic];

self.view = kalView;


再分析, kalview里有subview种类:headerview、grid view、tableview

这里的内容就比较复杂,headerview直接加在self里、gridview、tableview 被加载在self.contentview中,当然contentview

是被加在self里的。。

这里的逻辑清晰了之后,就是gridview的了。

Gridview的subview里有MonthView,MonthView的subview里有KalTitleView …

大致梳理下就是这样的层级关系!

再看下logic:

kalView中定义了两个logic相关的对象,delegate与logic。

KalGridView中定义了两个logic相关的对象,delegate与logic

说明了什么? 有什么作用?

分析了代码后发现,原来这两处的logic相关的对象是相同的,在kalview init 、gridview init中被赋值

首先看下delegate 这个能够做什么呢? 可以考虑成一个存在的“第三方”,第三方内存在了一些方法,方法Ⅰ,方法2,方法3.。。

kalview ,gridview里的对象的执行的delegate,就找到了这些函数了。

但是实际的执行点是在那里的呢? 就是谁代理,谁调用,被calendarviewcongroller的self真正执行了。。

so,this is delegate。。

等等,CalendarViewController好像被说的太少了,它这里做了什么操作的呢? 我们到h、m里看下,与KalViewDelegate相关的在.h里只有这样

@class KalLogic,KalDate;

@interface CalendarViewController :
UIViewController

<

KalViewDelegate,

KalDataSourceCallbacks,

UITableViewDelegate

so,在calendarviewcontroller.m里init时候with delegate self就不难理解了,真正执行的是calendarviewcontroller,而那两个都是发发号令,做做指挥,喝喝茶,看看报纸,浏览浏览网页,看看妹纸。。。抱歉,我扯淡扯多了!

还得说下logic:

吃饭先,未完待续。。。

上回说到了delegate,现在讲下logic,我搜索了下logic,发现其在4个类内有用到,calendarviewcontroller,kalview,gridview,当然还有他自己kalogic。

大致看了下,其就是一个控制的属性,想一张网一样连接其他的类的关系,并处理各种关系引起的各种问题,这个就是logic处理的内容。


Record In 2013


猪投上海,沙逼北京。反腐风暴,雾霾十省。石化爆炸,大V冰冷。爸爸哪儿?情圣汪峰。鹏菲分手,快乐男声。累感不爱,不约而同。我伙惊呆,曼德拉崩。不要姑父,钓鱼岛晴。恒大夺冠,立军偷情。梦鸽护子,伏法峻峰。私人订制,小时代猛。棱镜窥私,土豪登顶。黄鸭巡游,中国织梦。



The ThreeWays about Radio , the multiple choice ……


First come to the three gif image!

link form  baidu pan

first :main code 

{

    UIButton * tempBt = sender;    

    if (tempBt.backgroundColor == [UIColorblackColor]) {

        tempBt.backgroundColor = [UIColorredColor];

        return;

    }else{

        tempBt.backgroundColor = [UIColorblackColor];

        return;

    }


}

second:

{

    UIButton *tempBtn = sender;

    UIButton *temBt2 ;

    NSArray *array = [NSArrayarrayWithObjects:Bt1,Bt2,Bt3,nil];

    for (int i =0; i<array.count; i++) {

        temBt2 = [array objectAtIndex:i];

        temBt2.backgroundColor = [UIColorblackColor];

    }

    if (Flag1 ==0) {

        tempBtn.backgroundColor = [UIColorredColor];

        intAddTag++;

        tempBtn.tag = intAddTag;

        Flag1 = 1;

        return;

    }

    if (Flag1) {

        if (intAddTag == tempBtn.tag) {

            tempBtn.backgroundColor = [UIColorblackColor];

            Flag1 = 0;

        }else{

            tempBtn.backgroundColor = [UIColorredColor];

            intAddTag++;

            tempBtn.tag =
intAddTag
;

            Flag1 = 1;

        }

    }


}

Third main code:

{

    UIButton *tempBtn = sender;

    UIButton *temBt2 ;

    NSArray *array = [NSArrayarrayWithObjects:Bt1,Bt2,Bt3,nil];

    for (int i =0; i<array.count; i++) {

        temBt2 = [array objectAtIndex:i];

        temBt2.backgroundColor = [UIColorblackColor];

    }

    tempBtn.backgroundColor = [UIColorredColor];


}