We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,259 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to reference objects defined in another class?

I had my iPhone app working, developed with Storyboard. I decided to take all of the methods that belonged in a SQLite method and move them to a new SQLite class (.h and .m).

Now I have errors that I can't seem to get rid of. The basic problem is the textfields on the "scene" are now unreachable from the SQLite class (they are in another class, where they belong). The properties are defined in EDVController.m... I am trying to reach them from SQLite.m.

I have read the docs, but can't find anything that fits my problem.

How do I do this?

2
Contributors
1
Reply
13 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
Question
Answered
SpokaneDude
Newbie Poster
3 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Simple, when you call method to interact with database provide parameters with it instead of trying to get direct access.
Example, this is very simplified JAVA!!!
Before change

public boolean login(){
PreparedStatement preparedStatement = null;
	try{
		String strQuery = 
		"SELECT * FROM user WHERE uid=? AND password=? AND";
				
		preparedStatement = conn.prepareStatement(strQuery);
		preparedStatement.setString(1,usernameTextField.getText());
		preparedStatement.setString(2,passwordTextField.getText());

would become

public boolean login(String username, String password){
PreparedStatement preparedStatement = null;
	try{
		String strQuery = 
		"SELECT * FROM user WHERE uid=? AND password=? AND";
				
		preparedStatement = conn.prepareStatement(strQuery);
		preparedStatement.setString(1,username);
		preparedStatement.setString(2,password);

and you will call it from your user interface presumable on button click as

public void actionPerformed(){
    DataManager manager = new DataManager(); //Your database class
    manager.login(usernameTextField.getText(), passwordTextField.getText());
peter_budo
Code tags enforcer
Moderator
15,791 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 50
Question Answered as of 1 Year Ago by peter_budo

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0863 seconds using 2.74MB