Re: [iPhone-AppDev-Auditors] Assignment 3 - How to pass info from VIEW to View Controller?

36 views
Skip to first unread message

Asad Khan

unread,
Oct 4, 2012, 7:41:47 AM10/4/12
to iphone-appd...@googlegroups.com
Can you post link to your SO post its very hard to read all text here.


On 04/10/2012 8:04 AM, "zallanx" <zal...@gmail.com> wrote:

(copypasta from my SO post.. where no one has answered so far :*( )

I am having a terrible time trying to pass a bit of information from my
GraphingCalcView to myGraphingCalcViewController -_-

Basically, I can know about the width of my screen from my
GraphingCalcView using the functionviewSize = self.bounds.size.width / scale .. pretty simple stuff. I'd like to pass viewSizefrom the View to my Controller (GraphingCalcViewController), so that it can do a simple transformation (for example, do viewSize + 1), and pass it back to to the View.

I have (and believe) that I set up the whole protocal/datSource/delegation thing correct (I really just followed the example of "Happiness" presented in the lecture), so I won't paste the details.

I have two equations in my protocol listed in the View's header file..maybe something is wrong here:
-(float) calcResult: (GraphingView *) sender;
@optional
-(void) passingVariable: (float) variable;

Basically, in my View, I call the @optional to pass viewSize:
[self.dataSource passingVariable:viewSize] , then in my Controller, I set viewSize to a Model property calledself.result so that: self.result = viewSize, and then return the model property:
-(float)calcResult:(GraphingView *)sender
{
    return self.result;
}

Now, in my View, when I assign a float to
[self.dataSource calcResult:self], I always get a 0, instead of any value that I passed to it.. X_X.. I was wondering if my whole concept about passing stuff from View to the Controller is correct, and what I am doing wrong.. Thanks for reading!


Reply all
Reply to author
Forward
0 new messages