例如01.10.2010是星期五=> 27.09.2010是星期一.
我不知道如何管理这个.顺便说一句:我如何计算日期?
我的代码非常简单.一个TableViewController带有一个实例变量"dataArray",该表在视图出现时填充.
问题:当我点击其中一个条目(didSelectRowAtIndexPath)时,我的应用程序崩溃了.在调试这个例子后我发现,"dataArray"目前没有对象,但为什么呢?如何显示单击的行?
头文件:
#import <UIKit/UIKit.h>
@interface DownloadTableViewController : UITableViewController {
NSMutableArray *dataArray;
}
@property (nonatomic, retain) NSMutableArray *dataArray;
@end
Run Code Online (Sandbox Code Playgroud)
.m文件:
#import "DownloadTableViewController.h"
@implementation DownloadTableViewController
@synthesize dataArray;
- (void)viewWillAppear:(BOOL)animated{
dataArray = [NSMutableArray arrayWithObjects:@"Mac OS X", @"Windows XP", @"Ubuntu 10.04", @"iOS 4.2", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [dataArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) { …Run Code Online (Sandbox Code Playgroud)