這是我的NSObject代碼;發送郵件TableView NSArray
Task.h
#import <Foundation/Foundation.h>
@interface Task : NSObject
@property (nonatomic,strong) NSString *name;
@property (nonatomic,assign) BOOL done;
-(id)initWithName:(NSString *)name done:(BOOL)done;
@end
Task.m
#import "Task.h"
@implementation Task
@synthesize name = _name;
@synthesize done = _done;
-(id)initWithName:(NSString *)name done:(BOOL)done {
self = [super init];
if (self) {
self.name = name;
self.done = done;
}
return self;
}
這是我的發送郵件代碼
Task *task = [[Task alloc]init];
MFMailComposeViewController *sendmail = [[MFMailComposeViewController alloc]init];
[sendmail setMailComposeDelegate:self];
NSString *message = [_tasks addObject:task]; // Error is here.
[sendmail setMessageBody:message isHTML:NO];
[sendmail setSubject:@"Test"];
[self presentViewController:sendmail animated:YES completion:nil];
我不知道如何去做。我只想發送郵件列表。我的錯誤在哪裏?我該如何解決這個問題?
Tasklistviewcontroller.m
@synthesize tasks = _tasks;
我從任務表視圖轉移。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *NotDoneCellIdentifier = @"NotDoneTaskCell";
static NSString *DoneCellIdentifier = @"DoneTaskCell";
Task *currentTask = [self.tasks objectAtIndex:indexPath.row];
NSString *cellIdentifier = currentTask.done ? DoneCellIdentifier : NotDoneCellIdentifier;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Configure the cell...
cell.textLabel.text = currentTask.name;
return cell;
}
您的源代碼不完整。什麼是'_tasks'? –
這與桌面視圖有什麼關係? – rmaddy
我更改了代碼。 – Salieh