iPhone Programming Daily Tips

[2009-10-26]

1. tableview cell's content could not be filled

-->cellForRowAtIndexPathdelegate has never been called

-->reason: UITableViewDataSource delegate must be declared in the viewcontroller to handle these messages

2. NSMutableArray could not add new objects

-->be careful of the type conversion when usingcomponentsSeparatedByString method, it returns a NSArray object, you should never assign that object to a NSMutableArray, instead we should use setArray(NSArray*) method.

3. crashes when release views...

1) if you declared a subview as retained and then the superview was closed, you don't need to release it again in dealloc override method, or else it will cause a crash

2) refer to the following link for more ideas: http://www.cocoabuilder.com/archive/message/cocoa/2004/11/7/120999

3) in my case, i removed one subview, when i press one button of this subview, it will present a modal view to user bypresentModalViewController, then when i calldismissModalViewControllerAnimated, my app hang up. the solution is not to remove the subview before the dismissModalViewControllerAnimated, because i guess it was somewhere been used by the modal view. we must respect the view stack. take actions in order.

4. wrong checkmarks in my own multi-selection people picker view(table view)

the reason is that cell identifier is wrongly reused by another cell displayed by scrolling to another page.

solution is to set the proper reuse ID, as following:

UITableViewCellStyle style = UITableViewCellStyleDefault;

NSString *reuseID = [NSString stringWithFormat:@"%@", [[ALPHA substringFromIndex:indexPath.section] substringToIndex:1]];

UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:reuseID];

if (!cell) cell = [[[UITableViewCell alloc] initWithStyle:style reuseIdentifier:reuseID] autorelease];

then it will display the accessory type of all table cells in different sections properly.

5. if we want to reuse a subview, keep in mind to retain it before remove it from superview and release it after everything is done. or else it may lead to a crash.

[2009-11-07]

1. use setArray/setString for convert a NSArray to NSMutableArray and NSString to NSMutableString

2. do not release a autorelease object

3. be careful of using int/NSInteger to represent a phone No. as it may exceed it's range. for safe, use float value instead.

4. use the following codes to get a XML element value(say 5566778899):

<response>

<sender:errorCode=0>5566778899</sender>

...

</response>

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {

[self.yaroundSMSParsedCharacterData appendString:string];

}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

// We reset the current property, for the next nodes

[self.yaroundSMSParsedCharacterData setString:@""];

}

5. use following codes to get XML element key value (say errorCode value 0)

if( [elementName isEqualToString:@"sender"] ) {

errCode = [attributeDict valueForKey:@"errorcode"];

}

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值