小编ada*_*eve的帖子

如何在Objective-C的特殊日期获得一周的星期一?

例如01.10.2010是星期五=> 27.09.2010是星期一.

我不知道如何管理这个.顺便说一句:我如何计算日期?

cocoa cocoa-touch objective-c ios

2
推荐指数
1
解决办法
1263
查看次数

实例变量在同一个控制器中是未知的

我的代码非常简单.一个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)

iphone objective-c

1
推荐指数
1
解决办法
106
查看次数

标签 统计

objective-c ×2

cocoa ×1

cocoa-touch ×1

ios ×1

iphone ×1