Search Results

Search found 6 results on 1 pages for 'cosizzle'.

Page 1/1 | 1 

  • UIViewController not loading a UIView

    - by Cosizzle
    Hey, I'm playing around with a script my teacher provided for a table based application. However I can't seem to get my own view to load. Files: SubViewOneController (which is a sub view, also has a nib) TapViewController (Custom UIView I created and want to add to a cell) RootViewController (Main controller which loads in the views) SimpleNavAppDelegate How it works: Within the RootViewController, there's an NSArray that holds NSDictionary objects which is declared in the -(void)awakeFromNib {} method - (void)awakeFromNib { // we'll keep track of our views controllers in this array views = [[NSMutableArray alloc] init]; // when using alloc you are responsible for it, and you will have to release it. // ==================================================================================================== // ==================================================================================================== // LOADING IN CUSTOM VIEW HERE: // allocate a set of views and add to our view array as a dictionary item TapViewController *tapBoardView = [[TapViewController alloc] init]; //push onto array [views addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"Tab Gestures", @"title", tapBoardView, @"controller", nil]]; [tapBoardView release]; //release the memory // ==================================================================================================== // ==================================================================================================== SubViewOneController *subViewOneController = [[SubViewOneController alloc] init]; // This will set the 2nd level title subViewOneController.title = @"Swipe Gestures"; //set it's title //push it onto the array [views addObject:[NSDictionary dictionaryWithObjectsAndKeys: @"Swipe Gestures", @"title", subViewOneController, @"controller", nil]]; [subViewOneController release]; //release the memory } Later on I set the table view: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // OUTPUT -- see console NSLog(@"indexPath %i", indexPath.row); // OUTPUT: tapController: <TapViewController: 0x3b2b360> NSLog(@"view object: %@", [views objectAtIndex:indexPath.row]); // OUTPUT: view object: controller = <TapViewController: 0x3b0e290>; title = "Tab Gestures"; // ----- Hardcoding the controller and nib file in does work, so it's not a linkage issue ------ // UNCOMMENT TO SEE WORKING -- comment below section. //TapViewController *tapContoller = [[TapViewController alloc] initWithNibName:@"TapBoardView" bundle:nil]; //NSLog(@"tapController: %@", tapContoller); //[self.navigationController pushViewController:tapContoller animated:YES]; // ----- Random Tests ----- //UIViewController *targetViewController = [[views objectAtIndex: 0] objectForKey:@"controller"]; // DOES NOT WORK // LOADS THE SECOND CELL (SubViewOneController) however will not load (TapViewController) UIViewController *targetViewController = [[views objectAtIndex: indexPath.row] objectForKey:@"controller"]; NSLog(@"target: %@", targetViewController); // OUTPUT: target: <TapViewController: 0x3b0e290> [self.navigationController pushViewController:targetViewController animated:YES]; } Reading the comments you should be able to see that hardcoding the view in, works - however trying to load it from the View NSArray does not work. It does however contain the object in memory, seeing that NSLog proves that. Everything is linked up and working within the TapViewController nib file. So ya, im kinda stuck on this one, any help would be great! Thanks guys

    Read the article

  • array retain question

    - by Cosizzle
    Hello, im fairly new to objective-c, most of it is clear however when it comes to memory managment I fall a little short. Currently what my application does is during a NSURLConnection when the method -(void)connectionDidFinishLoading:(NSURLConnection *)connection is called upon I enter a method to parse some data, put it into an array, and return that array. However I'm not sure if this is the best way to do so since I don't release the array from memory within the custom method (method1, see the attached code) Below is a small script to better show what im doing .h file #import <UIKit/UIKit.h> @interface memoryRetainTestViewController : UIViewController { NSArray *mainArray; } @property (nonatomic, retain) NSArray *mainArray; @end .m file #import "memoryRetainTestViewController.h" @implementation memoryRetainTestViewController @synthesize mainArray; // this would be the parsing method -(NSArray*)method1 { // ???: by not release this, is that bad. Or does it get released with mainArray NSArray *newArray = [[NSArray alloc] init]; newArray = [NSArray arrayWithObjects:@"apple",@"orange", @"grapes", "peach", nil]; return newArray; } // this method is actually // -(void)connectionDidFinishLoading:(NSURLConnection *)connection -(void)method2 { mainArray = [self method1]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { mainArray = nil; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [mainArray release]; [super dealloc]; } @end

    Read the article

  • drawing different quartz 2d

    - by Cosizzle
    Hello, I'm trying to make a small application or demo thats a tab bar application. Each bar item loads in a new view. I've created a quartzView class that is called on by the controller: - (void)viewDidLoad { quartzView *drawingView = [[quartzView alloc] initWithFrame:CGRectMake(0,0,320,480)]; [self.view addSubview:drawingView]; [super viewDidLoad]; } From my understanding, the drawRect method must be triggered in order to render the object and to draw it. This is my quartzView class: #import "quartzView.h" @implementation quartzView #pragma mark shapes // Blue Circle - (void)drawRect:(CGRect)rect { NSLog(@"Trying to draw..."); CGContextRef ctx = UIGraphicsGetCurrentContext(); //get the current context CGContextClearRect(ctx, rect); //clear off the screen //draw a red square CGContextSetRGBFillColor(ctx, 255, 0, 0, 1); CGContextFillRect(ctx, CGRectMake(10, 10, 50, 50)); } // ==================================================================================================== #pragma mark - - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)dealloc { [super dealloc]; } @end So how would I go about to say, if the view is view one, draw a square if it's view two draw a circle. And so on.

    Read the article

  • iPhone JSON Object

    - by Cosizzle
    Hello, I'm trying to create a application that will retrieve JSON data from an HTTP request, send it to a the application main controller as a JSON object then from there do further processing with it. Where I'm stick is actually creating a class that will serve as a JSON class in which will take a URL, grab the data, and return that object. Alone, im able to make this class work, however I can not get the class to store the object for my main controller to retrieve it. Because im fairly new to Objective-C itself, my thoughts are that im messing up within my init call: -initWithURL:(NSString *) value { responseData = [[NSMutableData data] retain]; NSString *theURL = value; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; return self; } The processing of the JSON object takes place here: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSError *jsonError; SBJSON *json = [[SBJSON new] autorelease]; NSDictionary *parsedJSON = [json objectWithString:responseString error:&jsonError]; // NSArray object. listings = [parsedJSON objectForKey:@"posts"]; NSEnumerator *enumerator = [listings objectEnumerator]; NSDictionary* item; // to prove that it does work. while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } [responseString release]; } Now when calling the object within the main controller I have this bit of code in the viewDidLoad method call: - (void)viewDidLoad { [super viewDidLoad]; JSON_model *jsonObj = [[JSON_model alloc] initWithURL:@"http://localhost/json/faith_json.php?user=1&format=json"]; NSEnumerator *enumerator = [[jsonObj listings] objectEnumerator]; NSDictionary* item; // while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } }

    Read the article

  • Getting value of "i" from GEvent

    - by Cosizzle
    Hello, I'm trying to add an event listener to each icon on the map when it's pressed. I'm storing the information in the database and the value that I'm wanting to retrive is "i" however when I output "i", I get it's last value which is 5 (there are 6 objects being drawn onto the map) Below is the code, what would be the best way to get the value of i, and not the object itself. var drawLotLoc = function(id) { var lotLoc = new GIcon(G_DEFAULT_ICON); // create icon object lotLoc.image = url+"images/markers/lotLocation.gif"; // set the icon image lotLoc.shadow = ""; // no shadow lotLoc.iconSize = new GSize(24, 24); // set the size var markerOptions = { icon: lotLoc }; $.post(opts.postScript, {action: 'drawlotLoc', id: id}, function(data) { var markers = new Array(); // lotLoc[x].description // lotLoc[x].lat // lotLoc[x].lng // lotLoc[x].nighbourhood // lotLoc[x].lot var lotLoc = $.evalJSON(data); for(var i=0; i<lotLoc.length; i++) { var spLat = parseFloat(lotLoc[i].lat); var spLng = parseFloat(lotLoc[i].lng); var latlng = new GLatLng(spLat, spLng) markers[i] = new GMarker(latlng, markerOptions); myMap.addOverlay(markers[i]); GEvent.addListener(markers[i], "click", function() { console.log(i); // returning 5 in all cases. // I _need_ this to be unique to the object being clicked. console.log(this); }); } });

    Read the article

  • Getting an "i" from GEvent

    - by Cosizzle
    Hello, I'm trying to add an event listener to each icon on the map when it's pressed. I'm storing the information in the database and the value that I'm wanting to retrive is "i" however when I output "i", I get it's last value which is 5 (there are 6 objects being drawn onto the map) Below is the code, what would be the best way to get the value of i, and not the object itself. var drawLotLoc = function(id) { var lotLoc = new GIcon(G_DEFAULT_ICON); // create icon object lotLoc.image = url+"images/markers/lotLocation.gif"; // set the icon image lotLoc.shadow = ""; // no shadow lotLoc.iconSize = new GSize(24, 24); // set the size var markerOptions = { icon: lotLoc }; $.post(opts.postScript, {action: 'drawlotLoc', id: id}, function(data) { var markers = new Array(); // lotLoc[x].description // lotLoc[x].lat // lotLoc[x].lng // lotLoc[x].nighbourhood // lotLoc[x].lot var lotLoc = $.evalJSON(data); for(var i=0; i<lotLoc.length; i++) { var spLat = parseFloat(lotLoc[i].lat); var spLng = parseFloat(lotLoc[i].lng); var latlng = new GLatLng(spLat, spLng) markers[i] = new GMarker(latlng, markerOptions); myMap.addOverlay(markers[i]); GEvent.addListener(markers[i], "click", function() { console.log(i); // returning 5 in all cases. // I _need_ this to be unique to the object being clicked. console.log(this); }); } });

    Read the article

1