How do I load a method thats in a class from a uiviewcontroller

I am trying to pass a uitextfield string from a view controller over to a method in a nsobject class... if you could please explain how I do this that would be great.

So far I have done the following however still getting lots of errors.

NSObject Class dbAccess.h - (void)passCode:(NSString *)passedCode; NSObject Class.m - (void)passCode:(NSString *passedCode { myString = passedCodeVaraibel; //myString declared in .h }

//... other code to initialize the database. with myString or something to that effect even though this is probably wrong this is why im asking the question

viewController.m //pass myCode textfield string when uitableviewcell is selected. [dbAccess.passCode myCode.text];

I know this is not right because its not working :) but I hope it adds more detail as to what I am trying to do.

-------------Problems Reply------------

Standard objective-c convention would request that you change the method name to setPassCode:, however passCode: works perfectly fine.

i assume this code isn't compiling, to correctly invoke a method, you use the following syntax (several examples):

[target action:argument];
[target action:arg1 anotherParameter:arg2];
[target action]

if you want to set a value, obviously you want to pass in that value as a parameter

// DBAccess.m
- (void)setPassCode:(NSString *)newPassCode {
myString = newPassCode; // myString defined as ivar in .h

dbAccess = [[DBAccess alloc] init];
// …
[dbAccess setPassCode:textField.text];

Category:iphone Views:0 Time:2011-06-12

Related post

  • phusion_passenger/plugin.r b:37:in `load': undefined method `dir' for nil:NilClass (NoMethodError) 2011-02-22

    gem install passenger # version 3.0.2 run the command 'passenger start' then I got the error: c:/Ruby187/lib/ruby/gems/1.8/gems/passenger-3.0.2/lib/phusion_passenger/plugin.r b:37:in `load': undefined method `dir' for nil:NilClass (NoMethodError) fro

  • Dynamically loading instance method during object instantiation 2011-09-14

    I want to be able to dynamically load instance methods during object instantiation. According to my design, the default behaviour is coded in the base class. However, if certain conditions are met during object instatination, I dynamically change thi

  • best practice: general asmx data loading web-method or multi web-methods 2011-04-03

    I'm wondering which is better approach from performance point of view, is it better to use one web-service method to load data by passing Database Table name and keys or is it better to use separate method for each database table! knowing that i'm us

  • How to load a method on startup in webservice 2011-05-08

    I have a java webservice using AXIS2 and running on tomcat server. I need to load a file when the server starts and I do not know how to do it. I have tried adding a main method but it just won't work. Is there any specific stuff that I need to do to

  • Lazy loading class methods in PHP 2011-06-22

    I have a class with a few rather large methods. In it's basic and most common state most of the functionality is not required though, so I was wondering if there is a way of lazy loading just parts of the class. The methods need to be able to access

  • c# Runtime Assembly Load, ByRef Method Invoke 2012-01-11

    I am loading assemblies at runtime and calling methods on a particular class. I have a List (on hosting application) that I want to access from the runtime loaded assembly and the only way I can think of doing so is to pass the list in as a paramter,

  • OpenGL only displays textures loaded within method? 2012-01-27

    I've got a method called showMainMenu() in my Render class. In Render I've defined my textures as bitmaps Bitmap* bBall; Bitmap* bWall; Bitmap* bStart; Bitmap* bEnd; Bitmap* bHighscores; Bitmap* bHelp; Bitmap* bStar; In my ctor of Render I do: this-

  • Easy Rotator issue with .load jQuery method 2012-01-31

    I am having some issues with Easy Rotator(loads images and display them inside a slide show). The script works perfectly if I don't use the jquery .load method to load a .html file that contains the code to be loaded.The code for the html file is as

  • Why is my Rails mountable engine not loading helper methods correctly? 2012-03-21

    I've built a rails gem that mounts as an engine. The engine is scoped to it's own namespace. In the engine, there's an MyEngine::ApplicationHelper module which adds a bunch of view helper methods. In my application layout, I refer to some of these me

  • Context of class loader inside method 2012-04-18

    I wrote custom class loader which loads jar file from the file system. the customClassLoader override the load and the find method and its working by How can I make all the code after the definition of the class loader to work with the customClassLoa

  • How to use jQuery's load(fn) method so it actually works 2009-07-30

    JQuery documentation has this to say about .load(fn) ( ): Note: load will work only if you set it before the element has completely loaded, if you set it after that nothing will happen. So when one is supposed to

  • Rails: load helper_method methods inside Rack application? 2011-07-25

    I have some helper methods defined in my ApplicationController. For performance issues, I have a Rack app for a /search route, and I need to use some of these methods in this Rack. I can't move them to a library or something right now. A short exampl

  • Subsonic - all load data methods fail on mysql table 2012-02-09

    Ok. I am having c# code breaking on SingleOrDefault, Find etc. with very little info. Example: IList<messageex> msgs = messageex.Find(x => x.msg_id == Id); Where Id is int with value 15910. Code that stops execution is: public static IList

  • iOS Dev, How can I call a method in the super class of my UIViewController? 2011-06-19

    i have two UIViewControllers for example A and B. On A there is a button when pushed loads view B as a sub view. Using the standard initWithNibName. On B there is a button which dismisses View B and should call a method in view A (its Parent View). I

  • TDD test data loading methods 2010-03-08

    I am a TDD newb and I would like to figure out how to test the following code. I am trying to write my tests first, but I am having trouble for creating a test that touches my DataAccessor. I can't figure out how to fake it. I've done the extend the

  • Why do we so many kinds of assembly loading methods? 2010-09-25

    AFAIK, there're 3 methods to load an assembly into a AppDomain: Assembly.Load() Assembly.LoadFrom() Assembly.LoadFile() The LoadFrom() method takes the assembly filepath as its argument, but the filepath is merely providing the assembly identity info

  • XmlDocument.Load() method fails to decode € (euro) 2010-12-09

    I have an XML document file.xml which is encoded in Iso-latin-15 (aka Iso-Latin-9) <?xml version="1.0" encoding="iso-8859-15"?> <root xmlns=""> <f>€.txt</f> </root> From my favorite text edit

  • Load methods and classes from build bath in Java 2012-02-23

    I am using Eclipse and I have got two libraries included in my project, foo.jar and bar.jar. In both JARs there is a class that includes the method getFoobar(Object xy). Now I would like to load the method getFoobar(Object xy) either from

  • Laravel: Load method in another controller without changing the url 2013-06-10

    I have this route: Route::controller('/', 'PearsController'); Is it possible in Laravel to get the PearsController to load a method from another controller so the URL doesn't change? For example: // route: Route::controller('/', 'PearsController'); /

Copyright (C), All Rights Reserved.

processed in 0.223 (s). 11 q(s)