Hey all,
i need some help, i hope this is the right place to ask,
I need help creating a small app that has an interface which allows you to choose one variable, and then displays a table view using a function of that variable
all code is explained in the the // and should hopefully explain what im trying to do
I am unsure as how to enter the angleBtheta and bellInequailty in a 2 column Tableview in the XIB
and then my class
Could someone please point me in the right direction
I have searched my entire uni for someone to teach me cocoa and failed so this is my last place to turn.
Thanks in advance,
Ash
i need some help, i hope this is the right place to ask,
I need help creating a small app that has an interface which allows you to choose one variable, and then displays a table view using a function of that variable
all code is explained in the the // and should hopefully explain what im trying to do
I am unsure as how to enter the angleBtheta and bellInequailty in a 2 column Tableview in the XIB
Code:
// bellgraph.m
//Imagine 3 polarisers A, fixed at angle 0, then B, C at angles to A, where the angle of C is a multiple of the angle B
#import "bellgraph.h"
#import "math.h"
#define PI 3.14159265
@implementation bellgraph
- (IBAction)calculateBellInequalities:(id)sender
{
NSNumber *multiplier=[NSNumber numberWithFloat:[multiplierField floatValue]]; //Grab the multiplier from XIB
int i;
for(i=0;i<181;i++){ //start a loop
float angleBtheta; //Angle of B
angleBtheta=i; //Give angle B values increasing 0,1,2,3,4,...,180)
NSNumber *angleCtheta=[NSNumber numberWithFloat:angleBtheta*[multiplier floatValue]]; //Angle C = multiplier * angleB
NSNumber *angleBrad=[NSNumber numberWithFloat:angleBtheta*PI/180]; //Convert Angles to rads from degrees
NSNumber *angleCrad=[NSNumber numberWithFloat:[angleCtheta floatValue]*PI/180];
NSNumber *cosAB,*cosAC,*cosBC; // defined by cosAB=cos(angle between A and B),
cosAB=[NSNumber numberWithFloat:cos([angleBrad floatValue])]; //cos(B)
cosAC=[NSNumber numberWithFloat:cos([angleCrad floatValue])]; //cos(C)
cosBC=[NSNumber numberWithFloat:cos(([angleCrad floatValue])-([angleBrad floatValue]))]; //cos(C-B)
NSNumber *absoluteValue,*bellInequality;
absoluteValue=[NSNumber numberWithFloat:([cosAB floatValue]-[cosAC floatValue])];
//the absolute value is for the absolute value of cosAB-CosAC (should be unsigned but cant figure out how
bellInequality=[NSNumber numberWithFloat:([absoluteValue floatValue]-[cosBC floatValue]-1)];
//bellInequality = |cosAB−cosAC| + (cosBC) −1
NSArray *bellArray=[NSArray arrayWithObjects:bellInequality,nil];
//Add each value of bellInequality and angleBtheta to tableview with B a function of angleBtheta
}
}
-(int)numberOfRowsInTableView:(NSTableView *) tableView {
return [bellArray count];
}
@end
Code:
// bellgraph.h
#import
@interface bellgraph : NSObject {
IBOutlet id multiplierField;
IBOutlet id tableView;
NSArray *bellArray;
}
- (IBAction)calculateBellInequalities:(id)sender;
@end
I have searched my entire uni for someone to teach me cocoa and failed so this is my last place to turn.
Thanks in advance,
Ash