09-07-2011, 09:18 PM
#1 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 20
problem load tableView with data the database
I have problem in show table mode correct..
i think code correct :
Code:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
return[listaConta count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
Conta *conta = (Conta *)[listaConta objectAtIndex:indexPath.row];
cell.textLabel.text = [conta nomeUser];
cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@", nomeUser];
// cell.text =[listaConta objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
ControlConta *controlConta = [[ControlConta alloc] init];
[controlConta release];
}
09-07-2011, 09:23 PM
#2 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
I'm going to guess that nomeUser is a UITextField. UITextField's have a NSString property called "text". So instead of using initWithFormat, just assign it directly like so:
Code:
cell.textLabel.text = conta.nomeUser.text;
//Broken down
UITextField *textField = conta.nomeUser;
NSString *textInsideTextField = textField.text;
cell.textLabel.text = textInsideTextField;
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
09-07-2011, 09:53 PM
#3 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 20
Quote:
Originally Posted by
Domele
I'm going to guess that nomeUser is a UITextField. UITextField's have a NSString property called "text". So instead of using initWithFormat, just assign it directly like so:
Code:
cell.textLabel.text = conta.nomeUser.text;
//Broken down
UITextField *textField = conta.nomeUser;
NSString *textInsideTextField = textField.text;
cell.textLabel.text = textInsideTextField;
this don't work...
Code:
Conta *conta = (Conta *)[listaConta objectAtIndex:indexPath.row];
UITextField *textField = conta.nomeUser;
NSString *textInsideTextField = textField.text; //error
cell.textLabel.text = textInsideTextField;
console:
Code:
GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:52:12 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 6776.
2011-09-07 23:46:20.467 Teste[6776:207] -[NSCFString text]: unrecognized selector sent to instance 0x5a46b50
2011-09-07 23:46:20.514 Teste[6776:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString text]: unrecognized selector sent to instance 0x5a46b50'
*** Call stack at first throw:
(
0 CoreFoundation 0x010655a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x011b9313 objc_exception_throw + 44
2 CoreFoundation 0x010670bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00fd6966 ___forwarding___ + 966
4 CoreFoundation 0x00fd6522 _CF_forwarding_prep_0 + 50
5 Teste 0x000030db -[ContaViewController tableView:cellForRowAtIndexPath:] + 379
6 UIKit 0x0032cb98 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
7 UIKit 0x003224cc -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
8 UIKit 0x003378cc -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
9 UIKit 0x0032f90c -[UITableView layoutSubviews] + 242
10 QuartzCore 0x021fca5a -[CALayer layoutSublayers] + 181
11 QuartzCore 0x021feddc CALayerLayoutIfNeeded + 220
12 QuartzCore 0x021a40b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
13 QuartzCore 0x021a5294 _ZN2CA11Transaction6commitEv + 292
14 UIKit 0x002b99c9 -[UIApplication _reportAppLaunchFinished] + 39
15 UIKit 0x002b9e83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
16 UIKit 0x002c4617 -[UIApplication handleEvent:withNewEvent:] + 1533
17 UIKit 0x002bcabf -[UIApplication sendEvent:] + 71
18 UIKit 0x002c1f2e _UIApplicationHandleEvent + 7576
19 GraphicsServices 0x01f09992 PurpleEventCallback + 1550
20 CoreFoundation 0x01046944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
21 CoreFoundation 0x00fa6cf7 __CFRunLoopDoSource1 + 215
22 CoreFoundation 0x00fa3f83 __CFRunLoopRun + 979
23 CoreFoundation 0x00fa3840 CFRunLoopRunSpecific + 208
24 CoreFoundation 0x00fa3761 CFRunLoopRunInMode + 97
25 UIKit 0x002b97d2 -[UIApplication _run] + 623
26 UIKit 0x002c5c93 UIApplicationMain + 1160
27 Teste 0x000021a9 main + 121
28 Teste 0x00002125 start + 53
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
09-07-2011, 09:58 PM
#4 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
Okay so it is a NSString object. Your first code should should work, try setting the detailTextLabel.text to nil.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
09-07-2011, 10:55 PM
#5 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 20
Class Contas
Quote:
Originally Posted by
Domele
Okay so it is a NSString object. Your first code should should work, try setting the detailTextLabel.text to nil.
my class conta
conta.h
Code:
//
// Contas.h
// Teste
//
// Created by Gus Rocha on 31/08/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface Conta : NSObject {
NSString *_id;
NSString *nomeUser;
NSString *nrCarteira;
}
//property to make get and set automatic
@property (nonatomic, retain) NSString *_id;
@property (nonatomic, retain) NSString *nomeUser;
@property (nonatomic, retain) NSString *nrCarteira;
-(id)initWithID:(NSString *)pk andNome:(NSString *)user andCarteira:(NSString *)Regcarteira;
@end
conta.m
Code:
//
// Contas.m
// Teste
//
// Created by Gus Rocha on 31/08/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
/*class responsability with database*/
#import "Conta.h"
@implementation Conta
/*create gets and sets*/
@synthesize _id,nomeUser,nrCarteira;
-(id)initWithID:(NSString *)pk andNome:(NSString *)user andCarteira:(NSString *)Regcarteira
{
if((self = [super init]))
{
_id = pk;
nomeUser = user;
nrCarteira = Regcarteira;
}
return self;
}
-(void)dealloc
{
[_id release];
[nomeUser release];
[nrCarteira release];
[super dealloc];
}
@end
09-08-2011, 01:59 PM
#6 (permalink )
Registered Member
Join Date: Aug 2011
Posts: 20
UiTableview in blank
Quote:
Originally Posted by
Domele
Okay so it is a NSString object. Your first code should should work, try setting the detailTextLabel.text to nil.
now information in blank
[/url]
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
Conta *conta = (Conta *)[listaConta objectAtIndex:indexPath.row];
cell.textLabel.text = [conta nomeUser];
UITextField *textField = nomeUser;
NSString *textInsideTextField = textField.text;
cell.textLabel.text = textInsideTextField;
cell.textLabel.text = nomeUser.text;
// cell.textLabel.text = [[NSString alloc] initWithFormat:@"%@", textInsideTextField];
return cell;
}
09-08-2011, 04:58 PM
#7 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
You are probably setting the textLabel to nil. Set the detailTextLabel to nil. Like I said before though, revert back to your old code except don't create a new string object, just assign it directly with nomeUser.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy