{"id":6032,"date":"2014-04-12T00:29:50","date_gmt":"2014-04-12T00:29:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/12\/objective-ccocos2d-iphonerelated-issues-collection-of-common-programming-errors\/"},"modified":"2014-04-12T00:29:50","modified_gmt":"2014-04-12T00:29:50","slug":"objective-ccocos2d-iphonerelated-issues-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/12\/objective-ccocos2d-iphonerelated-issues-collection-of-common-programming-errors\/","title":{"rendered":"objective-c,cocos2d-iphoneRelated issues-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c521c11562c3540db79eca1cd632bd5e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBrock Woolf<br \/>\nobjective-c cocoa cocoa-touch nsstring<br \/>\nI have an NSString like so:@&#8221;200hello&#8221;or @&#8221;0 something&#8221;What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @&#8221;200hello&#8221; would become int = 200.and @&#8221;0 something&#8221; would become int = 0.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/530d60c4e39f05f49896c2c37078411a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBartosz Ciechanowski<br \/>\nobjective-c lambda objective-c-blocks continuations structured-programming<br \/>\nWhen using methods which return blocks they can be very convenient. However, when you have to string a few of them together it gets messy really quicklyfor instance, you have to call 4 URLs in succession:[remoteAPIWithURL:url1 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){[remoteAPIWithURL:url3 success:^(int status){[remoteAPIWithURL:url2 success:^(int status){\/\/succes!!!}];}];}]; }];So for every iteration I go one level deeper, and I don&#8217;t even handle errors in the nested<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e497767d0a1523c9afbbe2722a73523?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRakhe Kara<br \/>\nios iphone objective-c cocoa-touch<br \/>\nActually this crash is not reproducing every time, even not frequently but we got this crash in our production app. I am not sure where is the problem. It is telling crash is happening in thread 4 in Environments class line number 38.Code:NSBundle* bundle = [NSBundle mainBundle];NSString* envsPListPath = [bundle pathForResource:@&#8221;Environment&#8221; ofType:@&#8221;plist&#8221;];Line 38: NSDictionary *environments = [[NSDictionary alloc] initWithContentsOfFile:envsPListPath];But according to exception type:00000020<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cc54370be995ce0d68289d82ec143fe1?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nMusterknabe<br \/>\nios objective-c<br \/>\nI have the following problem. I have a Model, called User. When the user now logins with Facebook, my app checks if the user exists already in the database. To not freeze the UI (since I&#8217;m coming from Android) I thought to use NSURLConnection sendAsynchronousRequest. What worked at first was the following:My User Model had a method to do the whole task of the AsynchronousRequest and then when finished would set a variable to loading. Then other classes, could simply check with while ( !user.loa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3786e4b772ba9c3fcebdb7c53684aa52?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJosh Bradley<br \/>\nobjective-c sockets bsd-sockets<br \/>\nOk, I have a problem with building a socket using Objective-C. If you&#8217;ll take a look at my code below, through help with example code and other sources, I was able to build a complete socket I believe. The problem is that when I compile it, it builds fine (no syntax problems), but there are no sockets being created. As you&#8217;ll notice I&#8217;ve commented out a lot of things in Server2.m and have isolated the problem to the very beginning when I create the struct for the listeningSocket. By the way, if<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/49756adee7cc8a8a3b80c85639ff3d82?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTodd Ditchendorf<br \/>\nobjective-c xcode frameworks compiler-errors parsekit<br \/>\nI am trying to add the Parsekit framework to my OSX Xcode project. I&#8217;ve never added a 3rd party framework before and I can&#8217;t get it to work right.I dragged the included Xcode project into my &#8216;Groups &amp; Files&#8217; pane and chose to Add it to my project. I then dragged Parsekit.framework underneath the Link Binary With Libraries heading. Then I double-clicked my target app and added Parsekit as a Direct Dependency. I also added libicucore.dylib as a Linked Library (as it says to do this on their si<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c66f5ead165235158b86a421c1adb00d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nzioolek<br \/>\nobjective-c cocoa nsimage pgm<br \/>\nHi everyone! It is my first post here.I am quite new in objective-c so maybe my question is not so hard but It is a problem for me. I&#8217;ve searched the web and didn&#8217;t find any useful hints for me&#8230; I am writing a program in Objective-c in Xcode. I need to read and display a pgm file (P5 with two bytes per pixel). To do that i&#8217;m trying to subclass NSImageRep but I don&#8217;t know how to create a proper bitmap for this file and how to draw it. Below is my code so far:header:@interface CTPWTPGMImageRep :<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4926053f9238c44da0ea8dc27ce113ba?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOliver<br \/>\niphone objective-c uiscrollview<br \/>\nHow can I force a UIScrollView in which paging and scrolling are on to only move vertically or horizontally at a given moment?My understanding is that the directionalLockEnabled property should achieve this, but a diagonal swipe still causes the view to scroll diagonally instead of restricting motion to a single axis.Edit: to be clearer, I&#8217;d like to allow the user to scroll horizontally OR vertically, but not both simultaneously.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dc26c949cc5a1d13a346dc231f4f1159?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nElwisz<br \/>\nobjective-c osx cocoa nsdocument autosave<br \/>\nI have a NSDocument based OS X app which instead of creating new documents with a blank page shows a panel to the user to chose a template from, like for example Apple&#8217;s Pages.app does.I made this by manually creating a new NSDocument instance when the user starts a new document and immediately setting a property on it to reflect which template the user has chosen for it:MyNSDocumentSubclass *newDoc = [sharedDocumentController makeUntitledDocumentOfType:fileType error:&amp;err]; [newDoc setTempl<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/536bcab5572944d66f04d12670638e08?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKanwar Singh<br \/>\niphone objective-c json ios6 afnetworking<br \/>\nI have webservice in java. and i am posting JSON by AFnetworking but its not working when i user below codeNSURL *url = [NSURL URLWithString:@&#8221;http:\/\/localhost8080\/webservice\/usersprofile\/&#8221;]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; \/\/ don&#8217;t forget to set parameterEncoding! httpClient.parameterEncoding = AFJSONParameterEncoding;NSDictionary *params = @{@&#8221;id&#8221;:@&#8221;12&#8243;,@&#8221;firstName&#8221; : @&#8221;Tested&#8221;, @&#8221;lastName&#8221;:@&#8221;User&#8221;,@&#8221;email&#8221;:@&#8221;TEsted@gmail.com&#8221;,@&#8221;age&#8221;:@&#8221;25&#8243;,@&#8221;addLine1&#8243;:@&#8221;T<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3a506e3d5853364fcfd5b3d473daf7c4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWaneck<br \/>\niphone ios opengl-es cocos2d-iphone antialiasing<br \/>\nI am new to opengl programming, but I am doing something very basic, and the difference of quality between a custom opengl code and cocos2d is huge!I am trying just to load an image and continuously rotate it every frame. With my code, I get a lot of flickering, sharp edges, while cocos2d has it all nice and smooth. I&#8217;ve set up 4x Multi-Sampling Anti-Aliasing using apple&#8217;s recommended code for iOs 4 on my code, and still it looks very bad in comparison to cocos2d without any MSAA.You can see the<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/996952de195a8bc83b2421e49a754e7d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLearnCocos2D<br \/>\ncocos2d-iphone callback game-physics chipmunk cocos2d-iphone-3.0<br \/>\nI&#8217;m using Cocos2d v3 and want to change a body from dynamic to static after colliding with another body. At the moment I&#8217;ve got:-(void)ccPhysicsCollisionPostSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB {_player.physicsBody.type = CCPhysicsBodyTypeStatic; }or-(BOOL)ccPhysicsCollisionPreSolve:(CCPhysicsCollisionPair *)pair static:(CCNode *)nodeA wildcard:(CCNode *)nodeB {_player.physicsBody.type = CCPhysicsBodyTypeStatic;return YES; }but neither works. I get<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b3e4dd7c5432a1c61160d1b9b87399ff?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGuru<br \/>\nobjective-c cocos2d-iphone core-audio simpleaudioengine<br \/>\nI read about preloading sounds in SimpleAudioEngine through [[SimpleAudioEngine sharedEngine] preloadEffect:@&#8221;bell.wav&#8221;];But, with this there are memory leaks which I read on couple of sites. On some websites it was used like this: &#8211;(void)loadSoundFilesInBackground {NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];[[SimpleAudioEngine sharedEngine] preloadEffect:@&#8221;bell.wav&#8221;];[pool release]; }What is the best way to load sound files in background through SimpleAudioEngine ? What is the<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8d63368d48ce7cd63f3be1eeced67d37?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTiddly<br \/>\niphone ios cocos2d-iphone cocos2d<br \/>\nI&#8217;m using cocos2d for iOS. Not sure if I&#8217;m doing something wrong here or if CCParallaxNode does something strange that I just don&#8217;t understand.I&#8217;m trying to create a few layers of parallax scrolling in the background of my game, at the moment I just have one layer added to the parallax node till I can figure out what&#8217;s going wrong. When the game loads the layer it&#8217;s always offset down and left by about 30% of the image size. I&#8217;ve uploaded an image demonstrating the difference in position here ht<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/32cdc777a19a6f2b2129decd30061cd1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkender<br \/>\niphone cocoa-touch memory-management cocos2d-iphone<br \/>\nI have an iPhone application in Cocos2d that sometimes crashes on actual device, due to memory problems. What I have so far found out is that the scenes, when switched, aren&#8217;t fully released &#8211; the [retainCount] for them is somewhat about 4-10 \ud83d\ude42 The dealloc method never gets called, and then I assume, when I switch the scenes a few times, the memory issue shows up. I&#8217;m wondering &#8211; where should I relese the scene? Since it has number of children, I suppose I should be doing a cleanup-removal of t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/996952de195a8bc83b2421e49a754e7d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLearnCocos2D<br \/>\ncocos2d-iphone uialertview<br \/>\nI am trying to lay buttons on top of a background image for a UIAlertView in Cocos2d. Its not working with the code below. any suggestions?UIAlertView *Win=[[UIAlertView alloc] initWithTitle:@&#8221;You Win&#8221; message:nil delegate:self cancelButtonTitle:@&#8221;Next&#8221; otherButtonTitles:@&#8221;Replay&#8221;,@&#8221;Quit&#8221;, nil];UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-50, -30, 400, 300)];NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathCom<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/09c3d801fb82afdfd7e2715d95e1bab5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nWhite Money<br \/>\niphone cocos2d cocos2d-iphone<br \/>\nI&#8217;m wonderring that what&#8217;s the difference between ccTouchesCancelled and ccTouchesEnded events in Cocos2d?Thanks! Tien<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/pJmdo.jpg?s=32&amp;g=1\" \/><br \/>\nOpenLearner<br \/>\ncocos2d-iphone cocos2d<br \/>\nI have a simple CCRotateBy action in a sequence; it is followed by a call to another method which confirms that the CCRotateBy completed (otherwise, that CCCallFunc would not get called in the sequence if CCRotateBy didn&#8217;t complete):-(void)correctRotation{if (self.rotationAmount){CCLOG(@&#8221;correcting rotation inside: %i&#8221;,self.buildNum);CCRotateBy*second=[CCRotateBy actionWithDuration:1 angle:-self.rotationAmount];CCEaseBackInOut*bounce2=[CCEaseBackInOut actionWithAction:second];CCCallFunc*func=[CC<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/Y6tnm.png?s=32&amp;g=1\" \/><br \/>\n25 revs, 2 users 100%Lukasz<br \/>\niphone cocos2d-iphone opengl-es-2.0 alpha blending<br \/>\nI have very simple CCScene with ONLY 1 CCLayer containing:CCSprite for background with standard blending mode CCRenderTexture to draw paint brushes, with its sprite attached to root CCLayer above background sprite:_bgSprite = [CCSprite spriteWithFile:backgroundPath]; _renderTexture = [CCRenderTexture renderTextureWithWidth:self.contentSize.width height:self.contentSize.height]; [_renderTexture.sprite setBlendFunc:(ccBlendFunc){GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}]; [self addChild:_bgSprite z:-1<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7f4ee98206d84b25a83228e285c678f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGeoffroy<br \/>\nc++ cocos2d-iphone copywithzone<br \/>\nI have some trouble.I made some interface (abstract class in c++). Implemented it in my class (derived from CCObject too). In third class I try to invoke method of interface and got SIGABORT. Here the code\/\/interface classclass CallBackInterface{public:virtual void SomeMethod() = 0;};\/\/my class that implement the interface class MyClass : public CallBackInterface, public CCObject{public:void SomeMethod(){\/*some realization*\/}; };\/\/class that invoke the SomeMethodclass CallBacker(){public:CallBa<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brock Woolf objective-c cocoa cocoa-touch nsstring I have an NSString like so:@&#8221;200hello&#8221;or @&#8221;0 something&#8221;What I would like to be able to do is take the first occuring number in the NSString and convert it into an int. So that @&#8221;200hello&#8221; would become int = 200.and @&#8221;0 something&#8221; would become int = 0. Bartosz Ciechanowski objective-c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6032","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6032"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6032\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}