내가 가지고 해상도라는 클래스는 내가 사용자가있는 UITableViewCell 내부 그래서 코드 아래에 추가 된 UITextField에 값을 입력하려면, 내가 jQuery과가 내보기에해제 사용자 정의 클래스는 객체
@interface Res : NSObject {
int _id;
NSString *_name;
NSString *_comments;
// ... and to many other objects.
}@property (nonatomic) int id;
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *comments;
에 따라
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//code for creating cell
switch (indexPath.row) {
case 0:
// Label
[[cell textLabel] setText:@"Name :"];
// Textbox
UITextField *_txtName = [[UITextField alloc] initWithFrame:CGRectMake(100, 0, 180, 44)];
[_txtName setDelegate:self];
[_txtName setTag:0];
[cell.contentView addSubview:_txtName];
[_txtName release], _txtName = nil;
break;
case 1:
// ......
}
사용자가 텍스트 상자에 값을 입력 할 때
지금 내가 선언
- (void)textFieldDidEndEditing:(UITextField *)textField
{
switch ([textField tag]) {
case 0:
[_resTemp setName:[textField text]];
break;
default:
break;
}
}
방법을 다음을 통해 그것을 얻을 내 .H 파일에서 인스턴스 변수로 _resTemp
변수는
방법 ViewDidLoad
에 나는 _resTemp = [[Res alloc] init];
작성하고 ViewDidUnload
방법에 나는 [_resTemp release];
처럼 분리 한 나는 또한 그것의 dealloc 방법에서 같은 방법으로 놓습니다.
여전히이 변수와 관련된 메모리 누수가 발생합니다.
나는이 객체를 어디에서 놓을 지 모르거나 내 논리를 바꿀 필요가있다. 누구든지 내게 UITableView 데이터 입력 코드를 참조하는 몇 가지 링크를 줄 수 있습니까?
게시하기 전에 미리보기를 참조하십시오. 코드 서식이 올바르지 않습니다. – Krishnabhadra