Search Results

Search found 2166 results on 87 pages for 'obj'.

Page 4/87 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Why does unity obj import flip my x coordinate?

    - by milkplus
    When I import my wavefront obj model into unity and then draw lines over it with the same coordinates in the obj file, the x coordinate is negated. I don't see any option in the importer that might be doing that. And I'm using the same localToWorldMatrix and the same coordinate data in the .obj file. Hmmm GL.PushMatrix(); GL.MultMatrix(transform.localToWorldMatrix); CreateMaterial(); lineMaterial.SetPass(0); GL.Color(new Color(0, 1, 0)); GL.Begin(GL.LINES); GL.Vertex(p1); GL.Vertex(p2); GL.Vertex(p2); GL.Vertex(p3); //... GL.End(); GL.PopMatrix();

    Read the article

  • Using Unit Tests While Developing Static Libraries in Obj-C

    - by macinjosh
    I'm developing a static library in Obj-C for a CocoaTouch project. I've added unit testing to my Xcode project by using the built in OCUnit framework. I can run tests successfully upon building the project and everything looks good. However I'm a little confused about something. Part of what the static library does is to connect to a URL and download the resource there. I constructed a test case that invokes the method that creates a connection and ensures the connection is successful. However when my tests run a connection is never made to my testing web server (where the connection is set to go). It seems my code is not actually being ran when the tests happen? Also, I am doing some NSLog calls in the unit tests and the code they run, but I never see those. I'm new to unit testing so I'm obviously not fully grasping what is going on here. Can anyone help me out here? P.S. By the way these are "Logical Tests" as Apple calls them so they are not linked against the library, instead the implementation files are included in the testing target.

    Read the article

  • Re-usable Obj-C classes with custom values: The right way

    - by Prairiedogg
    I'm trying to reuse a group of Obj-C clases between iPhone applications. The values that differ from app to app have been isolated and I'm trying to figure out the best way to apply these custom values to the classes on an app-to-app basis. Should I hold them in code? // I might have 10 customizable values for each class, that's a long signature! CarController *controller = [[CarController alloc] initWithFontName:@"Vroom" engine:@"Diesel" color:@"Red" number:11]; Should I store them in a big settings.plist? // Wasteful! I sometimes only use 2-3 of 50 settings! AllMyAppSettings *settings = [[AllMyAppSettings alloc] initFromDisk:@"settings.plist"]; MyCustomController *controller = [[MyCustomController alloc] initWithSettings:settings]; [settings release]; Should I have little, optional n_settings.plists for each class? // Sometimes I customize CarControllerSettings *carSettings = [[CarControllerSettings alloc] initFromDisk:@"car_settings.plist"]; CarController *controller = [[CarController alloc] initWithSettings:carSettings]; [carSettings release]; // Sometimes I don't, and CarController falls back to internally stored, reasonable defaults. CarController *controller = [[CarController alloc] initWithSettings:nil]; Or is there an OO solution that I'm not thinking of at all that would be better?

    Read the article

  • Visual Studio build fails: unable to copy exe-file from obj\debug to bin\debug

    - by Nailuj
    This is a question asked before, both here on Stack Overflow and other places, but none of the suggestions I've found this far has helped me, so I just have to try asking a new question. Scenario: I have a simple Windows Forms application (C#, .NET 4.0, Visual Studio 2010). It has a couple of base forms that most other forms inherit from, it uses Entity Framework (and POCO classes) for database access. Nothing fancy, no multi-threading or anything. Problem: All was fine for a while. Then, all out of the blue, Visual Studio failed to build when I was about to launch the application. I got the warning "Unable to delete file '...bin\Debug\[ProjectName].exe'. Access to the path '...bin\Debug\[ProjectName].exe' is denied." and the error "Unable to copy file 'obj\x86\Debug\[ProjectName].exe' to 'bin\Debug\[ProjectName].exe'. The process cannot access the file 'bin\Debug\[ProjectName].exe' because it is being used by another process." (I get both the warning and the error when running Rebuild, but only the error when running Build - don't think that is relevant?) I understand perfectly fine what the warning and error message says: Visual Studio is obviously trying to overwrite the exe-file while it the same time has a lock on it for some reason. However, this doesn't help me find a solution to the problem... The only thing I've found working is to shut down Visual Studio and start it again. Building and launching then works, untill I make a change in some of the forms, then I have the same problem again and have to restart... Quite frustrating! As I mentioned above, this seems to be a known problem, so there are lots of suggested solutions. I'll just list what I've already tried here, so people know what to skip: Creating a new clean solution and just copy the files from the old solution. Adding the following to the following to the project's pre-build event: if exist "$(TargetPath).locked" del "$(TargetPath).locked"   if not exist "$(TargetPath).locked" if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked" Adding the following to the project properties (.csproj file): <GenerateResourceNeverLockTypeAssembliestrue</GenerateResourceNeverLockTypeAssemblies However, none of them worked for me, so you can probably see why I'm starting to get a bit frustrated. I don't know where else to look, so I hope somebody has something to give me! Is this a bug in VS, and if so is there a patch? Or has I done something wrong, do I have a circular reference or similar, and if so how could I find out? Any suggestions are highly appreciated :)

    Read the article

  • EXC_BAD_ACCESS when simply casting a pointer in Obj-C

    - by AlexChilcott
    Hi all, Frequent visitor but first post here on StackOverflow, I'm hoping that you guys might be able to help me out with this. I'm fairly new to Obj-C and XCode, and I'm faced with this really... weird... problem. Googling hasn't turned up anything whatsoever. Basically, I get an EXC_BAD_ACCESS signal on a line that doesn't do any dereferencing or anything like that that I can see. Wondering if you guys have any idea where to look for this. I've found a work around, but no idea why this works... The line the broken version barfs out on is the line: LevelEntity *le = entity; where I get my bad access signal. Here goes: THIS VERSION WORKS NSArray *contacts = [self.body getContacts]; for (PhysicsContact *contact in contacts) { PhysicsBody *otherBody; if (contact.bodyA == self.body) { otherBody = contact.bodyB; } if (contact.bodyB == self.body) { otherBody = contact.bodyA; } id entity = [otherBody userData]; if (entity != nil) { LevelEntity *le = entity; CGPoint point = [contact contactPointOnBody:otherBody]; } } THIS VERSION DOESNT WORK NSArray *contacts = [self.body getContacts]; for (NSUInteger i = 0; i < [contacts count]; i++) { PhysicsContact *contact = [contacts objectAtIndex:i]; PhysicsBody *otherBody; if (contact.bodyA == self.body) { otherBody = contact.bodyB; } if (contact.bodyB == self.body) { otherBody = contact.bodyA; } id entity = [otherBody userData]; if (entity != nil) { LevelEntity *le = entity; CGPoint point = [contact contactPointOnBody:otherBody]; } } Here, the only difference between the two examples is the way I enumerate through my array. In the first version (which works) I use for (... in ...), where as in the second I use for (...; ...; ...). As far as I can see, these should be the same. This is seriously weirding me out. Anyone have any similar experience or idea whats going on here? Would be really great :) Cheers, Alex

    Read the article

  • 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32

    - by numerical25
    having trouble getting my directx going I get the following error 1>Linking... 1>main.obj : error LNK2001: unresolved external symbol _D3D10CreateDeviceAndSwapChain@32 1>C:\Users\numerical25\Desktop\Intro ToDirectX\msdnTutorials\tutorial0\tutorial\Debug\tutorial.exe : fatal error LNK1120: 1 unresolved externals below is my code // include the basic windows header file #include <windows.h> #include <windowsx.h> #include <d3d10.h> ID3D10Device* g_pd3dDevice; IDXGISwapChain* g_pSwapChain; // the WindowProc function prototype LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); bool InitDirect3D(HWND); // the entry point for any Windows program int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // the handle for the window, filled by a function HWND hWnd; // this struct holds information for the window class WNDCLASSEX wc; // clear out the window class for use ZeroMemory(&wc, sizeof(WNDCLASSEX)); // fill in the struct with the needed information wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = L"WindowClass1"; // register the window class RegisterClassEx(&wc); // create the window and use the result as the handle hWnd = CreateWindowEx(NULL, L"WindowClass1", // name of the window class L"Our First Windowed Program", // title of the window WS_OVERLAPPEDWINDOW, // window style 300, // x-position of the window 300, // y-position of the window 640, // width of the window 480, // height of the window NULL, // we have no parent window, NULL NULL, // we aren't using menus, NULL hInstance, // application handle NULL); // used with multiple windows, NULL // display the window on the screen ShowWindow(hWnd, nCmdShow); // enter the main loop: // this struct holds Windows event messages MSG msg; bool finished = InitDirect3D(hWnd); // Enter the infinite message loop while(TRUE) { // Check to see if any messages are waiting in the queue while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { // Translate the message and dispatch it to WindowProc() TranslateMessage(&msg); DispatchMessage(&msg); } // If the message is WM_QUIT, exit the while loop if(msg.message == WM_QUIT) break; // Run game code here // ... // ... }; } // this is the main message handler for the program LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // sort through and find what code to run for the message given switch(message) { // this message is read when the window is closed case WM_DESTROY: { // close the application entirely PostQuitMessage(0); return 0; } break; } // Handle any messages the switch statement didn't return DefWindowProc (hWnd, message, wParam, lParam); } bool InitDirect3D(HWND g_hWnd) { DXGI_SWAP_CHAIN_DESC sd; ZeroMemory( &sd, sizeof(sd) ); sd.BufferCount = 1; sd.BufferDesc.Width = 640; sd.BufferDesc.Height = 480; sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; sd.BufferDesc.RefreshRate.Numerator = 60; sd.BufferDesc.RefreshRate.Denominator = 1; sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; sd.OutputWindow = g_hWnd; sd.SampleDesc.Count = 1; sd.SampleDesc.Quality = 0; sd.Windowed = TRUE; if( FAILED( D3D10CreateDeviceAndSwapChain( NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice ) ) ) { return FALSE; } return TRUE; }

    Read the article

  • Obj-msg-send error in numberOfSectionsInTableView

    - by mukeshpawar
    import "AddBillerCategoryViewController.h" import "Globals.h" import "AddBillerViewController.h" import "AddBillerListViewController.h" import"KlinnkAppDelegate.h" @implementation AddBillerCategoryViewController @synthesize REASON, RESPVAR, currentAttribute,tbldata,strOptions; // This recipe adds a title for each section //Initialize the table view controller with the grouped style (AddBillerCategoryViewController *) init { if (self = [super initWithStyle:UITableViewStyleGrouped]);// self.title = @"Crayon Colors"; return self; } -(void)showBack { [[self navigationController] pushViewController:[[AddBillerViewController alloc] init] animated:YES]; } (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if ([viewController isKindOfClass:[AddBillerCategoryViewController class]]) { AddBillerCategoryViewController *controller = (AddBillerCategoryViewController *)viewController; [controller.tbldata reloadData]; } } (void)viewDidLoad { appDelegate = (KlinnkAppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.catListArray.count; // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem; //self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] // initWithTitle:@"Back" // style:UIBarButtonItemStylePlain // target:self // action:@selector(showBack)] autorelease]; if(gotOK == 0) { //self.navigationItem.leftBarButtonItem.enabled = FALSE; dt = [[DateTime alloc] init]; strChannelID = @"IGLOO|MOBILE"; strDateTime = [dt findDateTime]; strTemp = [dt findSessionTime]; strSessionID = [appDelegate.KMobile stringByAppendingString:strTemp]; strResponseURL = @"http://115.113.110.139/Test/CbbpServerRequestHandler"; strResponseVar = @"serverResponseXML"; strRequestType = @"GETCATEGORY"; NSLog(@"Current Session id - %@", strSessionID); //conn = [[NSURLConnection alloc] init]; receivedData = [[NSMutableData data] retain]; //.................... currentAttribute = [[NSMutableString alloc] init]; // create XMl xmlData = [[NSData alloc] init]; xmlData = [self createXML]; // XMl has been created now convert it in to string xmlString = [[NSString alloc] initWithData:xmlData encoding:NSASCIIStringEncoding]; // Ataching other infromatin to he xml parameterString = [[NSString alloc] initWithString:@"mobileRequestXML="]; requestString = [[NSString alloc] init]; requestString = [parameterString stringByAppendingString:xmlString]; // give space betn two element. requestString = [requestString stringByReplacingOccurrencesOfString:@"<" withString:@" <"]; // Initalizing other parameters postData = [requestString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; postLength = [NSString stringWithFormat:@"%d",[postData length]]; firstRequest = [[[NSMutableURLRequest alloc] init] autorelease]; REASON = [[NSMutableString alloc] init]; RESPVAR = [[NSMutableString alloc] init]; NSLog(@"\n \n Sending for 1st time........\n"); [self sendRequest]; NSLog(@"\n \n Sending for 2nd time........\n"); [self sendRequest]; NSLog(@"\n \n both request send........\n \n "); } //[tbldata reloadData]; [self retain]; [super viewDidLoad]; } -(void)sendRequest { finished = FALSE; NSLog(@"\n Sending Request \n\n %@", requestString); conn = [[NSURLConnection alloc] init]; if(gotOK == 0) [firstRequest setURL:[NSURL URLWithString:@"http://115.113.110.139/Test/CbbpMobileRequestHandler"]]; if(gotOK == 1) { [firstRequest setURL:[NSURL URLWithString:@"http://115.113.110.139//secure"]]; gotOK = 2; } [firstRequest setHTTPMethod:@"POST"]; [firstRequest setValue:postLength forHTTPHeaderField:@"Content-Length"]; [firstRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [firstRequest setHTTPBody:postData]; conn = [conn initWithRequest:firstRequest delegate:self startImmediately:YES]; [conn start]; while(!finished) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } if (conn) { //receivedData = [[NSMutableData data] retain]; NSLog(@"\n\n Received %d bytes of data",[receivedData length]); } else { NSLog(@"\n Not responding"); } } (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@" \n Send didReciveResponse"); [receivedData setLength:0]; } (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@" \n Send didReciveData"); [receivedData appendData:data]; } (void)connectionDidFinishLoading:(NSURLConnection *)connection { finished = TRUE; NSLog(@" \n Send didFinishLaunching"); // do something with the data // receivedData is declared as a method instance elsewhere NSLog(@"\n\n Succeeded! DIDFINISH Received %d bytes of data\n\n ",[receivedData length]); NSString *aStr = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]; NSLog(aStr); //[conn release]; if([aStr isEqualToString:@"OK"]) gotOK = 1; NSLog(@" Value of gotOK - %d", gotOK); if(gotOK == 2) { responseData = [aStr dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; parser = [[NSXMLParser alloc] initWithData:responseData]; [parser setDelegate:self]; NSLog(@"\n start parsing"); [parser parse]; NSLog(@"\n PArsing over"); NSLog(@"\n check U / S and the RESVAR is - %@",RESPVAR); NSRange textRange; textRange =[aStr rangeOfString:@"<"]; if(textRange.location != NSNotFound) { if([RESPVAR isEqualToString:@"U"]) { self.navigationItem.rightBarButtonItem.enabled = TRUE; self.navigationItem.leftBarButtonItem.enabled = TRUE; NSLog(@" \n U......."); UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:REASON delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [alert show]; [alert release]; } if([RESPVAR isEqualToString:@"S"]) { NSLog(@"\n S........"); [[self navigationController] pushViewController:[[AddBillerCategoryViewController alloc] init] animated:YES]; //[self viewDidLoad]; //[tbldata reloadData]; } } else { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Problem" message:@"Enable to process your request at this time. Please try again." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; [alert show]; [alert release]; //self.navigationItem.leftBarButtonItem.enabled = TRUE; } } NSLog(@"\n Last line of connectionDidFinish "); //[tableView reloadData]; } -(NSData *)createXML { NSString *strXmlNode = @" channel alliaceid session reqtype responseurl responsevar "; NSString *tempchannel = [strXmlNode stringByReplacingOccurrencesOfString:@"channel" withString:strChannelID options:NSBackwardsSearch range:NSMakeRange(0, [strXmlNode length])]; NSString *tempalliance = [tempchannel stringByReplacingOccurrencesOfString:@"alliaceid" withString:@"WALLET365" options:NSBackwardsSearch range:NSMakeRange(0, [tempchannel length])]; NSString *tempsession = [tempalliance stringByReplacingOccurrencesOfString:@"session" withString:strSessionID options:NSBackwardsSearch range:NSMakeRange(0, [tempalliance length])]; NSString *tempreqtype = [tempsession stringByReplacingOccurrencesOfString:@"reqtype" withString:strRequestType options:NSBackwardsSearch range:NSMakeRange(0,[tempsession length])]; NSString *tempresponseurl = [tempreqtype stringByReplacingOccurrencesOfString:@"responseurl" withString:strResponseURL options:NSBackwardsSearch range:NSMakeRange(0, [tempreqtype length])]; NSString *tempresponsevar = [tempresponseurl stringByReplacingOccurrencesOfString:@"responsevar" withString:strResponseVar options:NSBackwardsSearch range:NSMakeRange(0,[tempresponseurl length])]; NSData *data= [[NSString stringWithString:tempresponsevar] dataUsingEncoding:NSUTF8StringEncoding]; return data; } (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if([elementName isEqualToString:@"RESPVAL"]) currentAttribute = [NSMutableString string]; if([elementName isEqualToString:@"REASON"]) currentAttribute = [NSMutableString string]; if([elementName isEqualToString:@"COUNT"]) currentAttribute = [NSMutableString string]; if([elementName isEqualToString:@"CATNAME"]) currentAttribute = [NSMutableString string]; } (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if([elementName isEqualToString:@"RESPVAL"]) { [RESPVAR setString:currentAttribute]; //NSLog(@"\n Response VAR - %@", RESPVAR); } if([elementName isEqualToString:@"REASON"]) { [REASON setString:currentAttribute]; //NSLog(@"\n Reason - %@", REASON); } if([elementName isEqualToString:@"COUNT"]) { NSString *temp1 = [[NSString alloc] init]; temp1 = [temp1 stringByAppendingString:currentAttribute]; catCount = [temp1 intValue]; [temp1 release]; //NSLog(@"\n Cat Count - %d", catCount); } if([elementName isEqualToString:@"CATNAME"]) { [appDelegate.catListArray addObject:[NSString stringWithFormat:currentAttribute]]; //NSLog(@"%@", appDelegate.catListArray); } } (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(self.currentAttribute) [self.currentAttribute setString:string]; } /* (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } */ /* (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; } */ /* (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; } */ /* (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; } */ /* // Override to allow orientations other than the default portrait orientation. (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } pragma mark Table view methods -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { KlinnkAppDelegate *appDelegated = (KlinnkAppDelegate *)[[UIApplication sharedApplication] delegate]; return appDelegated.catListArray.count; } // Customize the appearance of table view cells. (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... AddBillerCategoryViewController *mbvc = (AddBillerCategoryViewController *)[appDelegate.catListArray objectAtIndex:indexPath.row]; [cell setText:mbvc.strOptions]; return cell; } (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; // [self.navigationController pushViewController:anotherViewController]; // [anotherViewController release]; gotOK = 0; int j = indexPath.row; appDelegate.catName = [[NSString alloc] init]; appDelegate.catName = [appDelegate.catName stringByAppendingString:[appDelegate.catListArray objectAtIndex:j]]; [[self navigationController] pushViewController:[[AddBillerListViewController alloc] init] animated:YES]; } /* // Override to support conditional editing of the table view. (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ /* // Override to support editing the table view. (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { // Delete the row from the data source [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES]; } else if (editingStyle == UITableViewCellEditingStyleInsert) { // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view } } */ /* // Override to support rearranging the table view. (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { } */ /* // Override to support conditional rearranging of the table view. (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the item to be re-orderable. return YES; } */ (void)dealloc { [REASON release]; [RESPVAR release]; [currentAttribute release]; [tbldata release]; [super dealloc]; } @end In the Above code .. numberOfSectionsInTableView ,i get error of obj-msg-send i have intialize the array catlist and even not released it anywhere still why i am getting this error please help me i am badly stuck' thanks in advacnce

    Read the article

  • Cannot see the variable In my own JQuery plugin's function.

    - by qinHaiXiang
    I am writing one of my own JQuery plugin. And I got some strange which make me confused. I am using JQuery UI datepicker with my plugin. ;(function($){ var newMW = 1, mwZIndex = 0; // IgtoMW contructor Igtomw = function(elem , options){ var activePanel, lastPanel, daysWithRecords, sliding; // used to check the animation below is executed to the end. // used to access the plugin's default configuration this.opts = $.extend({}, $.fn.igtomw.defaults, options); // intial the model window this.intialMW(); }; $.extend(Igtomw.prototype, { // intial model window intialMW : function(){ this.sliding = false; //this.daysWithRecords = []; this.igtoMW = $('<div />',{'id':'igto'+newMW,'class':'igtoMW',}) .css({'z-index':mwZIndex}) // make it in front of all exist model window; .appendTo('body') .draggable({ containment: 'parent' , handle: '.dragHandle' , distance: 5 }); //var igtoWrapper = igtoMW.append($('<div />',{'class':'igtoWrapper'})); this.igtoWrapper = $('<div />',{'class':'igtoWrapper'}).appendTo(this.igtoMW); this.igtoOpacityBody = $('<div />',{'class':'igtoOpacityBody'}).appendTo(this.igtoMW); //var igtoHeaderInfo = igtoWrapper.append($('<div />',{'class':'igtoHeaderInfo dragHandle'})); this.igtoHeaderInfo = $('<div />',{'class':'igtoHeaderInfo dragHandle'}) .appendTo(this.igtoWrapper); this.igtoQuickNavigation = $('<div />',{'class':'igtoQuickNavigation'}) .css({'color':'#fff'}) .appendTo(this.igtoWrapper); this.igtoContentSlider = $('<div />',{'class':'igtoContentSlider'}) .appendTo(this.igtoWrapper); this.igtoQuickMenu = $('<div />',{'class':'igtoQuickMenu'}) .appendTo(this.igtoWrapper); this.igtoFooter = $('<div />',{'class':'igtoFooter dragHandle'}) .appendTo(this.igtoWrapper); // append to igtoHeaderInfo this.headTitle = this.igtoHeaderInfo.append($('<div />',{'class':'headTitle'})); // append to igtoQuickNavigation this.igQuickNav = $('<div />', {'class':'igQuickNav'}) .html('??') .appendTo(this.igtoQuickNavigation); // append to igtoContentSlider this.igInnerPanelTopMenu = $('<div />',{'class':'igInnerPanelTopMenu'}) .appendTo(this.igtoContentSlider); this.igInnerPanelTopMenu.append('<div class="igInnerPanelButtonPreWrapper"><a href="" class="igInnerPanelButton Pre" action="" style="background-image:url(images/igto/igInnerPanelTopMenu.bt.bg.png);"></a></div>'); this.igInnerPanelTopMenu.append('<div class="igInnerPanelSearch"><input type="text" name="igInnerSearch" /><a href="" class="igInnerSearch">??</a></div>' ); this.igInnerPanelTopMenu.append('<div class="igInnerPanelButtonNextWrapper"><a href="" class="igInnerPanelButton Next" action="sm" style="background-image:url(images/igto/igInnerPanelTopMenu.bt.bg.png); background-position:-272px"></a></div>' ); this.igInnerPanelBottomMenu = $('<div />',{'class':'igInnerPanelBottomMenu'}) .appendTo(this.igtoContentSlider); this.icWrapper = $('<div />',{'class':'icWrapper','id':'igto'+newMW+'Panel'}) .appendTo(this.igtoContentSlider); this.icWrapperCotentPre = $('<div class="slider pre"></div>').appendTo(this.icWrapper); this.icWrapperCotentShow = $('<div class="slider firstShow "></div>').appendTo(this.icWrapper); this.icWrapperCotentnext = $('<div class="slider next"></div>').appendTo(this.icWrapper); this.initialPanel(); this.initialQuickMenus(); console.log(this.leftPad(9)); newMW++; mwZIndex++; this.igtoMW.bind('mousedown',function(){ var $this = $(this); //alert($this.css('z-index') + ' '+mwZIndex); if( parseInt($this.css('z-index')) === (mwZIndex-1) ) return; $this.css({'z-index':mwZIndex}); mwZIndex++; //alert(mwZIndex); }); }, initialPanel : function(){ this.defaultPanelNum = this.opts.initialPanel; this.activePanel = this.defaultPanelNum; this.lastPanel = this.defaultPanelNum; this.defaultPanel = this.loadPanelContents(this.defaultPanelNum); $(this.defaultPanel).appendTo(this.icWrapperCotentShow); }, initialQuickMenus : function(){ // store the current element var obj = this; var defaultQM = this.opts.initialQuickMenu; var strMenu = ''; var marginFirstEle = '8'; $.each(defaultQM,function(key,value){ //alert(key+':'+value); if(marginFirstEle === '8'){ strMenu += '<a href="" class="btPanel" panel="'+key+'" style="margin-left: 8px;" >'+value+'</a>'; marginFirstEle = '4'; } else{ strMenu += '<a href="" class="btPanel" panel="'+key+'" style="margin-left: 4px;" >'+value+'</a>'; } }); // append to igtoQuickMenu this.igtoQMenu = $(strMenu).appendTo(this.igtoQuickMenu); this.igtoQMenu.bind('click',function(event){ event.preventDefault(); var element = $(this); if(element.is('.active')){ return; } else{ $(obj.igtoQMenu).removeClass('active'); element.addClass('active'); } var d = new Date(); var year = d.getFullYear(); var month = obj.leftPad( d.getMonth() ); var inst = null; if( obj.sliding === false){ console.log(obj.lastPanel); var currentPanelNum = parseInt(element.attr('panel')); obj.checkAvailability(); obj.getDays(year,month,inst,currentPanelNum); obj.slidePanel(currentPanelNum); obj.activePanel = currentPanelNum; console.log(obj.activePanel); obj.lastPanel = obj.activePanel; obj.icWrapper.find('input').val(obj.activePanel); } }); }, initialLoginPanel : function(){ var obj = this; this.igPanelLogin = $('<div />',{'class':"igPanelLogin"}); this.igEnterName = $('<div />',{'class':"igEnterName"}).appendTo(this.igPanelLogin); this.igInput = $('<input type="text" name="name" value="???" />').appendTo(this.igEnterName); this.igtoLoginBtWrap = $('<div />',{'class':"igButtons"}).appendTo(this.igPanelLogin); this.igtoLoginBt = $('<a href="" class="igtoLoginBt" action="OK" >??</a>\ <a href="" class="igtoLoginBt" action="CANCEL" >??</a>\ <a href="" class="igtoLoginBt" action="ADD" >????</a>').appendTo(this.igtoLoginBtWrap); this.igtoLoginBt.bind('click',function(event){ event.preventDefault(); var elem = $(this); var action = elem.attr('action'); var userName = obj.igInput.val(); obj.loadRootMenu(); }); return this.igPanelLogin; }, initialWatchHistory : function(){ var obj = this; // for thirt part plugin used if(this.sliding === false){ this.watchHistory = $('<div />',{'class':'igInnerPanelSlider'}).append($('<div />',{'class':'igInnerPanel_pre'}).addClass('igInnerPanel')) .append($('<div />',{'class':'igInnerPanel'}).datepicker({ dateFormat: 'yy-mm-dd',defaultDate: '2010-12-01' ,showWeek: true,firstDay: 1, //beforeShow:setDateStatistics(), onChangeMonthYear:function(year, month, inst) { var panelNum = 1; month = obj.leftPad(month); obj.getDays(year,month,inst,panelNum); } , beforeShowDay: obj.checkAvailability, onSelect: function(dateText, inst) { obj.checkAvailability(); } }).append($('<div />',{'class':'extraMenu'})) ) .append($('<div />',{'class':'igInnerPanel_next'}).addClass('igInnerPanel')); return this.watchHistory; } }, loadPanelContents : function(panelNum){ switch(panelNum){ case 1: alert('inside loadPanelContents') return this.initialWatchHistory(); break; case 2: return this.initialWatchHistory(); break; case 3: return this.initialWatchHistory(); break; case 4: return this.initialWatchHistory(); break; case 5: return this.initialLoginPanel(); break; } }, loadRootMenu : function(){ var obj = this; var mainMenuPanel = $('<div />',{'class':'igRootMenu'}); var currentMWId = this.igtoMW.attr('id'); this.activePanel = 0; $('#'+currentMWId+'Panel .pre'). queue(function(next){ $(this). html(mainMenuPanel). addClass('panelShow'). removeClass('pre'). attr('panelNum',0); next(); }). queue(function(next){ $('<div style="width:0;" class="slider pre"></div>'). prependTo('#'+currentMWId+'Panel').animate({width:348}, function(){ $('#'+currentMWId+'Panel .slider:last').remove() $('#'+currentMWId+'Panel .slider:last').replaceWith('<div class="slider next"></div>'); $('.btMenu').remove(); // remove bottom quick menu obj.sliding = false; $(this).removeAttr('style'); }); $('.igtoQuickMenu .active').removeClass('active'); next(); }); }, slidePanel : function(currentPanelNum){ var currentMWId = this.igtoMW.attr('id'); var obj = this; //alert(obj.loadPanelContents(currentPanelNum)); if( this.activePanel > currentPanelNum){ $('#'+currentMWId+'Panel .pre'). queue(function(next){ alert('inside slidePanel') //var initialDate = getPanelDateStatus(panelNum); //console.log('intial day in bigger panel '+initialDate) $(this). html(obj.loadPanelContents(currentPanelNum)). addClass('panelShow'). removeClass('pre'). attr('panelNum',currentPanelNum); $('#'+currentMWId+'Panel .next').remove(); next(); }). queue(function(next){ $('<div style="width:0;" class="slider pre"></div>'). prependTo('#'+currentMWId+'Panel').animate({width:348}, function(){ //$('#igto1Panel .slider:last').find(setPanel(currentPanelNum)).datepicker('destroy'); $('#'+currentMWId+'Panel .slider:last').empty().removeClass('panelShow').addClass('next').removeAttr('panelNum'); $('#'+currentMWId+'Panel .slider:last').replaceWith('<div class="slider next"></div>') obj.sliding = false;console.log('inuse inside animation: '+obj.sliding); $(this).removeAttr('style'); }); next(); }); } else{ ///// current panel num smaller than next $('#'+currentMWId+'Panel .next'). queue(function(next){ $(this). html(obj.loadPanelContents(currentPanelNum)). addClass('panelShow'). removeClass('next'). attr('panelNum',currentPanelNum); $('<div class="slider next">empty</div>').appendTo('#'+currentMWId+'Panel'); next(); }). queue(function(next){ $('#'+currentMWId+'Panel .pre').animate({width:0}, function(){ $(this).remove(); //$('#igto1Panel .slider:first').find(setPanel(currentPanelNum)).datepicker('destroy'); $('#'+currentMWId+'Panel .slider:first').empty().removeClass('panelShow').addClass('pre').removeAttr('panelNum').removeAttr('style'); $('#'+currentMWId+'Panel .slider:first').replaceWith('<div class="slider pre"></div>') obj.sliding = false; console.log('inuse inside animation: '+obj.sliding); }); next(); }); } }, getDays : function(year,month,inst,panelNum){ var obj = this; // depand on the mysql qurey condition var table_of_record = 'moviewh';//getTable(panelNum); var date_of_record = 'watching_date';//getTableDateCol(panelNum); var date_to_find = year+'-'+month; var node_of_xml_date_list = 'whDateRecords';//getXMLDateNode(panelNum); var user_id = '1';//getLoginUserId(); //var daysWithRecords = []; // empty array before asigning this.daysWithRecords.length = 0; $.ajax({ type: "GET", url: "include/get.date.list.process.php", data:({ table_of_record : table_of_record,date_of_record:date_of_record,date_to_find:date_to_find,user_id:user_id,node_of_xml_date_list:node_of_xml_date_list }), dataType: "json", cache: false, // force broser don't cache the xml file async: false, // using this option to prevent datepicker refresh ??NO success:function(data){ // had no date records if(data === null) return; obj.daysWithRecords = data; } }); //setPanelDateStatus(year,month,panelNum); console.log('call from getdays() ' + this.daysWithRecords); }, checkAvailability : function(availableDays) { // var i; var checkdate = $.datepicker.formatDate('yy-mm-dd', availableDays); //console.log( checkdate); // for(var i = 0; i < this.daysWithRecords.length; i++) { // // if(this.daysWithRecords[i] == checkdate){ // // return [true, "available"]; // } // } //console.log('inside check availablility '+ this.daysWithRecords); //return [true, "available"]; console.log(typeof this.daysWithRecords) for(i in this.daysWithRecords){ //if(this.daysWithRecords[i] == checkdate){ console.log(typeof this.daysWithRecords[i]); //return [true, "available"]; //} } return [true, "available"]; //return [false, ""]; }, leftPad : function(num) { return (num < 10) ? '0' + num : num; } }); $.fn.igtomw = function(options){ // Merge options passed in with global defaults var opt = $.extend({}, $.fn.igtomw.defaults , options); return this.each(function() { new Igtomw(this,opt); }); }; $.fn.igtomw.defaults = { // 0:mainMenu 1:whatchHistor 2:requestHistory 3:userManager // 4:shoppingCart 5:loginPanel initialPanel : 5, // default panel is LoginPanel initialQuickMenu : {'1':'whatchHIstory','2':'????','3':'????','4':'????'} // defalut quick menu }; })(jQuery); usage: $('.openMW').click(function(event){ event.preventDefault(); $('<div class="">').igtomw(); }) HTML code: <div id="taskBarAndStartMenu"> <div class="taskBarAndStartMenuM"> <a href="" class="openMW" >??IGTO</a> </div> <div class="taskBarAndStartMenuO"></div> </div> In my work flow: when I click the "whatchHistory" button, my plugin would load a panel with JQuery UI datepicker applied which days had been set to be availabled or not. I am using the function "getDays()" to get the available days list and stored the data inside daysWithRecords, and final the UI datepicker's function "beforeShowDay()" called the function "checkAvailability()" to set the days. the variable "daysWithRecords" was declared inside Igtomw = function(elem , options) and was initialized inside the function getDays() I am using the function "initialWatchHistory()" to initialization and render the JQuery UI datepicker in the web. My problem is the function "checkAvailability()" cannot see the variable "daysWithRecords".The firebug prompts me that "daysWithRecords" is "undefined". this is the first time I write my first plugin. So .... Thank you very much for any help!!

    Read the article

  • ResponseStatusLine protocol violation

    - by Tom Hines
    I parse/scrape a few web page every now and then and recently ran across an error that stated: "The server committed a protocol violation. Section=ResponseStatusLine".   After a few web searches, I found a couple of suggestions – one of which said the problem could be fixed by changing the HttpWebRequest ProtocolVersion to 1.0 with the command: 1: HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(strURI); 2: req.ProtocolVersion = HttpVersion.Version10;   …but that did not work in my particular case.   What DID work was the next suggestion I found that suggested the use of the setting: “useUnsafeHeaderParsing” either in the app.config file or programmatically. If added to the app.config, it would be: 1: <!-- after the applicationSettings --> 2: <system.net> 3: <settings> 4: <httpWebRequest useUnsafeHeaderParsing ="true"/> 5: </settings> 6: </system.net>   If done programmatically, it would look like this: C++: 1: // UUHP_CPP.h 2: #pragma once 3: using namespace System; 4: using namespace System::Reflection; 5:   6: namespace UUHP_CPP 7: { 8: public ref class CUUHP_CPP 9: { 10: public: 11: static bool UseUnsafeHeaderParsing(String^% strError) 12: { 13: Assembly^ assembly = Assembly::GetAssembly(System::Net::Configuration::SettingsSection::typeid); //__typeof 14: if (nullptr==assembly) 15: { 16: strError = "Could not access Assembly"; 17: return false; 18: } 19:   20: Type^ type = assembly->GetType("System.Net.Configuration.SettingsSectionInternal"); 21: if (nullptr==type) 22: { 23: strError = "Could not access internal settings"; 24: return false; 25: } 26:   27: Object^ obj = type->InvokeMember("Section", 28: BindingFlags::Static | BindingFlags::GetProperty | BindingFlags::NonPublic, 29: nullptr, nullptr, gcnew array<Object^,1>(0)); 30:   31: if(nullptr == obj) 32: { 33: strError = "Could not invoke Section member"; 34: return false; 35: } 36:   37: FieldInfo^ fi = type->GetField("useUnsafeHeaderParsing", BindingFlags::NonPublic | BindingFlags::Instance); 38: if(nullptr == fi) 39: { 40: strError = "Could not access useUnsafeHeaderParsing field"; 41: return false; 42: } 43:   44: if (!(bool)fi->GetValue(obj)) 45: { 46: fi->SetValue(obj, true); 47: } 48:   49: return true; 50: } 51: }; 52: } C# (CSharp): 1: using System; 2: using System.Reflection; 3:   4: namespace UUHP_CS 5: { 6: public class CUUHP_CS 7: { 8: public static bool UseUnsafeHeaderParsing(ref string strError) 9: { 10: Assembly assembly = Assembly.GetAssembly(typeof(System.Net.Configuration.SettingsSection)); 11: if (null == assembly) 12: { 13: strError = "Could not access Assembly"; 14: return false; 15: } 16:   17: Type type = assembly.GetType("System.Net.Configuration.SettingsSectionInternal"); 18: if (null == type) 19: { 20: strError = "Could not access internal settings"; 21: return false; 22: } 23:   24: object obj = type.InvokeMember("Section", 25: BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic, 26: null, null, new object[] { }); 27:   28: if (null == obj) 29: { 30: strError = "Could not invoke Section member"; 31: return false; 32: } 33:   34: // If it's not already set, set it. 35: FieldInfo fi = type.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic | BindingFlags.Instance); 36: if (null == fi) 37: { 38: strError = "Could not access useUnsafeHeaderParsing field"; 39: return false; 40: } 41:   42: if (!Convert.ToBoolean(fi.GetValue(obj))) 43: { 44: fi.SetValue(obj, true); 45: } 46:   47: return true; 48: } 49: } 50: }   F# (FSharp): 1: namespace UUHP_FS 2: open System 3: open System.Reflection 4: module CUUHP_FS = 5: let UseUnsafeHeaderParsing(strError : byref<string>) : bool = 6: // 7: let assembly : Assembly = Assembly.GetAssembly(typeof<System.Net.Configuration.SettingsSection>) 8: if (null = assembly) then 9: strError <- "Could not access Assembly" 10: false 11: else 12: 13: let myType : Type = assembly.GetType("System.Net.Configuration.SettingsSectionInternal") 14: if (null = myType) then 15: strError <- "Could not access internal settings" 16: false 17: else 18: 19: let obj : Object = myType.InvokeMember("Section", BindingFlags.Static ||| BindingFlags.GetProperty ||| BindingFlags.NonPublic, null, null, Array.zeroCreate 0) 20: if (null = obj) then 21: strError <- "Could not invoke Section member" 22: false 23: else 24: 25: // If it's not already set, set it. 26: let fi : FieldInfo = myType.GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic ||| BindingFlags.Instance) 27: if(null = fi) then 28: strError <- "Could not access useUnsafeHeaderParsing field" 29: false 30: else 31: 32: if (not(Convert.ToBoolean(fi.GetValue(obj)))) then 33: fi.SetValue(obj, true) 34: 35: // Now return true 36: true VB (Visual Basic): 1: Option Explicit On 2: Option Strict On 3: Imports System 4: Imports System.Reflection 5:   6: Public Class CUUHP_VB 7: Public Shared Function UseUnsafeHeaderParsing(ByRef strError As String) As Boolean 8:   9: Dim assembly As [Assembly] 10: assembly = [assembly].GetAssembly(GetType(System.Net.Configuration.SettingsSection)) 11:   12: If (assembly Is Nothing) Then 13: strError = "Could not access Assembly" 14: Return False 15: End If 16:   17: Dim type As Type 18: type = [assembly].GetType("System.Net.Configuration.SettingsSectionInternal") 19: If (type Is Nothing) Then 20: strError = "Could not access internal settings" 21: Return False 22: End If 23:   24: Dim obj As Object 25: obj = [type].InvokeMember("Section", _ 26: BindingFlags.Static Or BindingFlags.GetProperty Or BindingFlags.NonPublic, _ 27: Nothing, Nothing, New [Object]() {}) 28:   29: If (obj Is Nothing) Then 30: strError = "Could not invoke Section member" 31: Return False 32: End If 33:   34: ' If it's not already set, set it. 35: Dim fi As FieldInfo 36: fi = [type].GetField("useUnsafeHeaderParsing", BindingFlags.NonPublic Or BindingFlags.Instance) 37: If (fi Is Nothing) Then 38: strError = "Could not access useUnsafeHeaderParsing field" 39: Return False 40: End If 41:   42: If (Not Convert.ToBoolean(fi.GetValue(obj))) Then 43: fi.SetValue(obj, True) 44: End If 45:   46: Return True 47: End Function 48: End Class   Technorati Tags: C++,CPP,VB,Visual Basic,F#,FSharp,C#,CSharp,ResponseStatusLine,protocol violation

    Read the article

  • Textures in Opengl ES 2 not working properly

    - by Adl
    Hi! I'm working with Opengl ES 2 on iphone and right now I am trying to get my textures working on my objects. I'm using .obj files and all the data in them are correct. I have written a parser myself to retrieve all data, I convert it to static arrays in C. I discard the material properties for now, only getting the image path from the .mtl files manually. I have an object with 336 triangles, making this non-trivial to observe, with appertaining vertices, vertex faces and texture coordinates (u,v). Passing all data into the shaders, the resulting image is this: http://img530.imageshack.us/img530/9637/pic1io.png http://img404.imageshack.us/img404/7358/pic2pg.png But it should look like this (Displaying it in an object viewer). Please ignore the material properties. http://img16.imageshack.us/img16/1401/pic3cq.png Using this image as a texture: http://img217.imageshack.us/img217/1300/shirtdiffuse.png I'm thinking it might have to do with texture coordinate faces ? It is defined in my .obj file, and I'm not using them at all. In books and tutorials I have not found anything concerning this. Regards Niclas

    Read the article

  • NSString variable out of scope in sub-class (iPhone/Obj-C)

    - by Rich
    I am following along with an example in a book with the code exactly as it is in the example code as well as from the book, and I'm getting an error at runtime. I'll try to describe the life cycle of this variable as good as I can. I have a controller class with a nested array that is populated with string literals (NSArray of NSArrays, the nested NSArrays initialized with arrayWithObjects: where the objects are all string literals - @"some string"). I access these strings with a helper method added via a category on NSArray (to pull strings out of a nested array). My controller gets a reference to this string and assigns it to a NSString property on a child controller using dot notation. The code looks like this (nestedObjectAtIndexPath is my helper method): NSString *rowKey = [rowKeys nestedObjectAtIndexPath:indexPath]; controller.keypath = rowKey; keypath is a synthesized nonatomic, retain property defined in a based class. When I hit a breakpoint in the controller at the above code, the NSString's value is as expected. When I hit the next breakpoint inside the child controller, the object id of the keypath property is the same as before, but instead of showing me the value of the NSString, XCode says that the variable is "out of scope" which is also the error I see in the console. This also happens in another sub-class of the same parent. I tried googling, and I saw slightly similar cases where people were suggesting this had to do with retain counts. I was under the impression that by using dot notation on a synthesized property, my class would be using an "auto generated accessor" that would be increasing my retain count for me so that I wouldn't have this problem. Could there be any implications because I'm accessing it in a sub-class and the prop is defined in the parent? I don't see anything in the book's errata about this, but the book is relatively new (Apress - More iPhone 3 Dev). I also have double checked that my code matches the example 100 times.

    Read the article

  • Obj-C component-based game architecture and message forwarding

    - by WanderWeird
    Hello, I've been trying to implement a simple component-based game object architecture using Objective-C, much along the lines of the article 'Evolve Your Hierarchy' by Mick West. To this end, I've successfully used a some ideas as outlined in the article 'Objective-C Message Forwarding' by Mike Ash, that is to say using the -(id)forwardingTargetForSelector: method. The basic setup is I have a container GameObject class, that contains three instances of component classes as instance variables: GCPositioning, GCRigidBody, and GCRendering. The -(id)forwardingTargetForSelector: method returns whichever component will respond to the relevant selector, determined using the -(BOOL)respondsToSelector: method. All this, in a way, works like a charm: I can call a method on the GameObject instance of which the implementation is found in one of the components, and it works. Of course, the problem is that the compiler gives 'may not respond to ...' warnings for each call. Now, my question is, how do I avoid this? And specifically regarding the fact that the point is that each instance of GameObject will have a different set of components? Maybe a way to register methods with the container objects, on a object per object basis? Such as, can I create some kind of -(void)registerMethodWithGameObject: method, and how would I do that? Now, it may or may not be obvious that I'm fairly new to Cocoa and Objective-C, and just horsing around, basically, and this whole thing may be very alien here. Of course, though I would very much like to know of a solution to my specific issue, anyone who would care to explain a more elegant way of doing this would additionally be very welcome. Much appreciated, -Bastiaan

    Read the article

  • Sorting a 2D array in obj-c?

    - by Debashis
    I have a 2D array as follows: [[@"string value", @"string value", NSInteger], [@"string value", @"string value", NSInteger], [@"string value", @"string value", NSInteger]] How would I sort the second dimension of arrays by the NSInteger?

    Read the article

  • [obj-c] autorelease problem

    - by BQuadra
    Why the NSArray allocated with arrayWithObjects dealloc automatically if already used by BObject object?? in teory NSArray must remain allocated all the BObject life time... [[BObject alloc] initObjectName:@"oneObject" states: [NSArray arrayWithObjects: [[State alloc] initStateName:@"stand_front" singleImg:[NSArray arrayWithObjects:[UIImage imageNamed:@"front_1.png"], nil]], [[State alloc] initStateName:@"front_walking" frames: [NSArray arrayWithObjects: [UIImage imageNamed:@"front_1.png"], [UIImage imageNamed:@"front_2.png"], [UIImage imageNamed:@"front_3.png"], [UIImage imageNamed:@"front_4.png"], [UIImage imageNamed:@"front_5.png"], [UIImage imageNamed:@"front_6.png"], [UIImage imageNamed:@"front_7.png"], [UIImage imageNamed:@"front_8.png"], nil] duration:0.8 repeat:0], nil] isSolid:TRUE];

    Read the article

  • OBJ-C: Call an instance of core-plot graph from separate view controller

    - by Kevin
    I'm using a view controller i.e. ViewController:UIViewController and have another class GraphViewController:UIViewController . How do I call an instance of GraphViewController and place it into my ViewController? I am currently trying to call the plot within my ViewController directly, but I want to make the graph modular so I don't have to copy code if I use the same graph again. ViewController has methods -(void) refreshGraph; //Inhereted Methods -(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot; -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; How do I move these methods to a separate class and then call it to get the same plot in my ViewController? I am sure there must be a thread on this somewhere but I can't seem to find it.

    Read the article

  • Calling Save on a Configuration obj with a custom sectiongroup of type NameValueSectionHandler

    - by Allen
    I've got aConfiguration object that I can easily read and write settings from and call Save(ConfigurationSaveMode.Minimal, true) on and that typically works just fine. However, I now have a config file that has a custom sectionGroup defined of type System.Configuration.NameValueSectionHandler (I didn't write that part and I can't change it). Now when I call the Save method, it throws a TypeLoadException Message: Type System.Configuration.NameValueSectionHandler does not inherit from System.Configuration.ConfigurationSectionGroup. Callstack: at System.Configuration.TypeUtil.VerifyAssignableType (Type baseType, Type type, Boolean throwOnError) at System.Configuration.TypeUtil.GetConstructorWithReflectionPermission (Type type, Type baseType, Boolean throwOnError) at System.Configuration.MgmtConfigurationRecord.CreateSectionGroupFactory (FactoryRecord factoryRecord) at System.Configuration.MgmtConfigurationRecord.EnsureSectionGroupFactory (FactoryRecord factoryRecord) at System.Configuration.MgmtConfigurationRecord.GetSectionGroup (String configKey) at System.Configuration.ConfigurationSectionGroupCollection.Get (String name) at System.Configuration.ConfigurationSectionGroupCollection. <GetEnumerator>d__0.MoveNext() at System.Configuration.Configuration.ForceGroupsRecursive (ConfigurationSectionGroup group) at System.Configuration.Configuration.SaveAsImpl (String filename, ConfigurationSaveMode saveMode, Boolean forceSaveAll) at System.Configuration.Configuration.Save (ConfigurationSaveMode saveMode, Boolean forceSaveAll) at MyCompany.MyProduct.blah.blah.Save () in C:\\projects\\blah\\blah\\blah.cs:line blah For reference, the configuration goes like so <configuration> <configSections> ... normal sections here that work just fine, followed by ... <sectionGroup name="threadSettings" type="System.Configuration.NameValueSectionHandler"> <section name="T1" type="System.Configuration.DictionarySectionHandler"/> <section name="T2" type="System.Configuration.DictionarySectionHandler"/> <section name="T3" type="System.Configuration.DictionarySectionHandler"/> </sectionGroup> </configSections> <applicationSettings /> <threadSettings> <T1> <add key="key-here" value="value-here"/> </T1> ... T2 and T3 here as well, thats not interesting ... </threadSettings> </configuration> If I remove the actual sections and the definition for the custom section groups, I am able to read / write settings just fine and even call Save just fine. Obviously the custom section groups could be setup a little nicer but I can't fix that so I'm wondering: Is it possible to get the Configuration object to save if it has custom sectionGroups of the NameValueSectionHandler type

    Read the article

  • Generating a list of Strings in Obj C

    - by eco_bach
    Hi It seems that Objective C jumps thru hoops to make seemingly simple tasks extremely difficult. I simply need to create a sequence of strings, image1.jpg, image2.jpg, etc etc ie in a loop var imgString:String='image'+i+'.jpg; I assume a best practice is to use a NSMutableString with appendString method? What am I doing wrong?? NSMutableString *imgString; for(int i=1;i<=NUMIMAGES;i++){ imgString.appendString(@"image"+i+@".jpg"); } I get the following error error: request for member 'appendString' in something not a structure or union

    Read the article

  • touchesBegin & touchesMove Xcode Obj C Question

    - by AndrewDK
    So I have my app working good when you press and drag along. I also have UIButtons set to Touch Down in Interface Builder. As well when you drag you need to drag from the outside of the UIButton. You cannot click on the UIButton and drag to the other. TOUCHES MOVED: Code: -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event touchesForView:self.view] anyObject]; CGPoint location = [touch locationInView:touch.view]; if(CGRectContainsPoint(oneButton.frame, location)) { if (!oneButton.isHighlighted){ [self oneFunction]; [oneButton setHighlighted:YES]; } }else { [oneButton setHighlighted:NO]; } // if(CGRectContainsPoint(twoButton.frame, location)) { if (!twoButton.isHighlighted){ [self twoFunction]; [twoButton setHighlighted:YES]; } }else { [twoButton setHighlighted:NO]; } } TOUCHES BEGAN: Code: - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event touchesForView:self.view] anyObject]; CGPoint location = [touch locationInView:touch.view]; if(CGRectContainsPoint(oneButton.frame, location)) { [self oneFunction]; [oneButton setHighlighted:YES]; } if(CGRectContainsPoint(twoButton.frame, location)) { [self twoFunction]; [twoButton setHighlighted:YES]; } } I want to be able to click on any of the button fire the function & also be able to drag from one button on to the other and fire that function. So basically just being able to click on a button and slide your finger over and activate the other button without having to press and slide from outside of the button. I think I'm close, need a bit of help. Hope thats clear enough. Thanks.

    Read the article

  • how to make a explorer like logic in Obj C for iphone

    - by Ekra
    Hi friends, To make the query simple first we can take example:- If we open the explorer in our Windows desktop how it shows us the tree. As we keep on clicking the tree it get expanded and shows the file in it. The same way I want to show a explorer which gets expanded as the user clicks on it(I want to get the business logic the UI is simple). The information of the explorer i.e. which folder has what files come in a XML format to me. I have 2 options of getting the XML either I can get the whole XML at one query(but I guess this might slow the application if the XML is quite big). OR I can get the XML for every list like first only the root structure then if user clicks on any folder in root I can get the list(the files or folders inside that folder) of that particular folder. Now the question is What would be the approach to implement both the method and which would be the best. Should I need to create some dictionary to maintain the link of the files like which file is inside what. I am not able to get as how I would be able to link all the files. Any hint or direction would be highly appreciated. Thanks in advance

    Read the article

  • lastIndexOf in obj-c?

    - by Debashis
    How would I get the last occurrence of an NSString within another NSString? For example, in "abc def ghi abc def ghi," I want to find the index of the second "abc," not the first. I know I could do this with a bunch of rangeOfStrings, but is there already a function for that?

    Read the article

  • NOOB Memory Problem - EXC_BAD_ACCESS (OBJ-C/iPhone)

    - by Michael Bordelon
    I have been banging my head against the wall for a couple days and need some help. I have a feeling that I am doing something really silly here, but I cannot find the issue. This is the controller for a table view. I put the SQL in line to simplify it as part of the troubleshooting of this error. Normally, it would be in an accessor method in a model class. It gets through the SQL read just fine. Finds the two objects, loads them into the todaysWorkout array and then builds the cells for the table view. The table view actually comes up on the scree and then it throws the EXC_BAD_ACCESS. I ran instruments and it shows the following: 0 CFString Malloc 1 00:03.765 0x3946470 176 Foundation -[NSPlaceholderString initWithFormat:locale:arguments:] 1 CFString Autorelease 00:03.765 0x3946470 0 Foundation NSRecordAllocationEvent 2 CFString CFRelease 0 00:03.767 0x3946470 0 Bring It -[WorkoutViewController viewDidLoad] 3 CFString Zombie -1 00:03.917 0x3946470 0 Foundation NSPopAutoreleasePool Here is the source code for the controller. I left it all in there just in case there is something extraneous causing the problem. I sincerely appreciate any help I can get: HEADER: #import <UIKit/UIKit.h> #import <sqlite3.h> #import "NoteCell.h" #import "BIUtility.h" #import "Bring_ItAppDelegate.h" #import "MoveListViewController.h" @class MoveListViewController; @class BIUtility; @interface WorkoutViewController : UITableViewController { NSMutableArray *todaysWorkouts; IBOutlet NoteCell *woNoteCell; MoveListViewController *childController; NSInteger scheduleDay; BIUtility *bi; } @property (nonatomic, retain) NSMutableArray *todaysWorkouts; @property (nonatomic, retain) NoteCell *woNoteCell; @property (nonatomic,retain) BIUtility *bi; //@property (nonatomic, retain) SwitchCell *woSwitchCell; @end CLASS: #import "WorkoutViewController.h" #import "MoveListViewController.h" #import "Profile.h" static sqlite3 *database = nil; @implementation WorkoutViewController @synthesize todaysWorkouts; @synthesize woNoteCell; @synthesize bi; //@synthesize woSwitchCell; - (void)viewDidLoad { [super viewDidLoad]; bi = [[BIUtility alloc] init]; todaysWorkouts = [[NSMutableArray alloc] init]; NSString *query; sqlite3_stmt *statement; //open the database if (sqlite3_open([[BIUtility getDBPath] UTF8String], &database) != SQLITE_OK) { sqlite3_close(database); NSAssert(0, @"Failed to opendatabase"); } query = [NSString stringWithFormat:@"SELECT IWORKOUT.WOINSTANCEID, IWORKOUT.WORKOUTID, CWORKOUTS.WORKOUTNAME FROM CWORKOUTS JOIN IWORKOUT ON IWORKOUT.WORKOUTID = CWORKOUTS.WORKOUTID AND DATE = '%@'", [BIUtility todayDateString]]; if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { Workout *wo = [[Workout alloc] init]; wo.woInstanceID = sqlite3_column_int(statement, 0); wo.workoutID = sqlite3_column_int(statement, 1); wo.workoutName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 2)]; [todaysWorkouts addObject:wo]; [wo release]; } sqlite3_finalize(statement); } if(database) sqlite3_close(database); [query release]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //todaysWorkouts = [BIUtility todaysScheduledWorkouts]; static NSString *noteCellIdentifier = @"NoteCellIdentifier"; UITableViewCell *cell; if (indexPath.section < ([todaysWorkouts count])) { cell = [tableView dequeueReusableCellWithIdentifier:@"OtherCell"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier: @"OtherCell"] autorelease]; cell.accessoryType = UITableViewCellAccessoryNone; } if (indexPath.row == 0) { Workout *wo = [todaysWorkouts objectAtIndex:indexPath.section]; [cell.textLabel setText:wo.workoutName]; } else { [cell.textLabel setText:@"Completed?"]; [cell.textLabel setFont:[UIFont fontWithName:@"Arial" size:15]]; [cell.textLabel setTextColor:[UIColor blueColor]]; } } else { cell = (NoteCell *)[tableView dequeueReusableCellWithIdentifier:noteCellIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"NoteCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } } return cell; //[cell release]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; if (indexPath.section < ([todaysWorkouts count]) && (row == 0)) { MoveListViewController *moveListController = [[MoveListViewController alloc] initWithStyle:UITableViewStylePlain]; moveListController.workoutID = [[todaysWorkouts objectAtIndex:indexPath.section] workoutID]; moveListController.workoutName = [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]; moveListController.woInstanceID = [[todaysWorkouts objectAtIndex:indexPath.section] woInstanceID]; NSLog(@"Workout Selected: %@", [[todaysWorkouts objectAtIndex:indexPath.section] workoutName]); Bring_ItAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.workoutNavController pushViewController:moveListController animated:YES]; } else { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (indexPath.section < ([todaysWorkouts count]) && (row == 1)) { if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else { cell.accessoryType = UITableViewCellAccessoryNone; } } } [tableView deselectRowAtIndexPath:indexPath animated:YES]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger h = 35; return h; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return ([todaysWorkouts count] + 1); //return ([todaysWorkouts count]); } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return 2; } else { return 1; } } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section < ([todaysWorkouts count])) { return @"Workout"; } else { return @"How Was Your Workout?"; } } - (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 { [super viewDidUnload]; // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [todaysWorkouts release]; [bi release]; [super dealloc]; } @end

    Read the article

  • take out objects from randomizer obj c

    - by David Pollak
    hello everyone, I'm a new "developer" trying to build some iPhone app I'm making an app which gets text from a list of objects in a NSArray and then randomizes them and display one in a TextView, here's the code: - (IBAction)azione{ NSArray *myArray= [NSArray arrayWithObjects: @"Pasta",@"Pizza",@"Wait",@"Go", nil]; int length = [myArray count]; int chosen = arc4random() % length; testo.text = [myArray objectAtIndex: chosen]; } what I want to do now, is when I open the app and get a random object, to take it out from the list, so that it won't be picked again ex. I open the appI get "Pizza"Do the action againI don't get "Pizza" anymore, only "Pasta" "Wait" and "Go" What should I do ? Which code should I use ? Thanks for answers

    Read the article

  • Obj-C combining strings

    - by Brodie4598
    this must be such a simple problem but can someone tell me why this doesnt work: visibilityString1 = @"the"; visibilityString2 = @"end"; visibilityString = (@"This is %@ %@", visibilityString1, visibilityString2); Every time I try to combine strings this way, it will only return the second string so what I get is: end

    Read the article

  • Obj-C : Passing parameters back from a detailViewController in a navigation controller

    - by Garfield81
    Hi I am using a navigation Controller on an iPhone app. I am able to pass data forward when I push a controller into the navigation stack but how do I pass data back when I pop the controller. What I am basically trying to achieve is the root navigation controller view displays a number of fields that can be edited. A user then clicks on one of the fields to be edited and a EditViewController is pushed onto the stack with the name of the field the user wants to edit. Now the users enters the new value of the field and presses save to pop the view controller. So how do I get the value from the editViewController back to the root navigation controller view?

    Read the article

  • obj-c problem setting array with componentsSeperatedByString

    - by Brodie4598
    I have a data source with about 2000 lines that look like the following: 6712,Anaktuvuk Pass Airport,Anaktuvuk Pass,United States,AKP,PAKP,68.1336,-151.743,2103,-9,A What I am interested in is the 6th section of this string so I want to turn it into an array, then i want to check the 6th section [5] for an occurrance of that string "PAKP" Code: NSBundle *bundle = [NSBundle mainBundle]; NSString *airportsPath = [bundle pathForResource:@"airports" ofType:@"dat"]; NSData *data = [NSData dataWithContentsOfFile:airportsPath]; NSString *dataString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]; NSArray *dataArray = [dataString componentsSeparatedByString:@"\n"]; NSRange locationOfAirport; NSString *workingString = [[NSString alloc]initWithFormat:@""]; NSString *searchedAirport = [[NSString alloc]initWithFormat:@""]; NSString *airportData = [[NSString alloc]initWithFormat:@""]; int d; for (d=0; d < [dataArray count]; d=d+1) { workingString = [dataArray objectAtIndex:d]; testTextBox = workingString; //works correctly NSArray *workingArray = [workingString componentsSeparatedByString:@","]; testTextBox2 = [workingArray objectAtIndex: 0]; //correctly displays the first section "6712" testTextBox3 = [workingArray objectAtIndex:1] //throws exception index beyond bounds locationOfAirport = [[workingArray objectAtIndex:5] rangeOfString:@"PAKP"]; } the problem is that when the workingArray populates, it only populates with a single object (the first component of the string which is "6712". If i have it display the workingString, it correctly displays the entire string, but for some reason, it isn't correctly making the array using the commas. i tried it without using the data file and it worked fine, so the problem comes from how I am importing the data. ideas?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >