Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-07-2011, 09:18 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 20
Gustavo Rocha is on a distinguished road
Default 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];
}
Gustavo Rocha is offline   Reply With Quote
Old 09-07-2011, 09:23 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 09-07-2011, 09:53 PM   #3 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 20
Gustavo Rocha is on a distinguished road
Default

Quote:
Originally Posted by Domele View Post
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
Gustavo Rocha is offline   Reply With Quote
Old 09-07-2011, 09:58 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 09-07-2011, 10:55 PM   #5 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 20
Gustavo Rocha is on a distinguished road
Default Class Contas

Quote:
Originally Posted by Domele View Post
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
Gustavo Rocha is offline   Reply With Quote
Old 09-08-2011, 01:59 PM   #6 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 20
Gustavo Rocha is on a distinguished road
Default UiTableview in blank

Quote:
Originally Posted by Domele View Post
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;


}
Gustavo Rocha is offline   Reply With Quote
Old 09-08-2011, 04:58 PM   #7 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 383
8 members and 375 guests
apatsufas, JackReidy, jeroenkeij, Sami Gh, tim0504, UMAD, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:55 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0