iphone,cocos2d-iphone,objective-cRelated issues-Collection of common programming errors
sobox studio
iphone ios ipad animation uinavigationcontroller
I know this is an error that has been explained at length in numerous other questions. However it still seems to be a topic for debate as its highly subjective. I have two questions;How detrimental is this error?I’ve been working on an app that requires a custom UINavigationController. I create a false root that allows me to change the perceived root more easily. To create this affect I ‘pop’ to the false root then immediately ‘push’ the new one. Like this;[self popToViewController:self.fakeRoot
gcamp
iphone
I have string like 123-123-1234 so I want to convert string into this format (123) 123-1234 so any idea to develop this functionality.Thanks in advance.
RexOnRoids
iphone sqlite sqlite3
I’m using a few sqlite3_bind routines (in the iPhone SDK) as shown below to make a single update (INSERT or UPDATE) to a table:sqlite3_bind_text(update_statement, 1, aString, -1, SQLITE_TRANSIENT);sqlite3_bind_int(update_statement, 2, anInteger);sqlite3_bind_int(update_statement, 3, pk);However, upon checking the updated table I discover unexpected results. I followed the progress using ‘step over’ in the Xcode Debugger and it looks like this group of three sqlite3_bind routines is being looped
rickharrison
iphone nsdate nsdateformatter
I am trying to do some basic operations with Dates on the iPhone. I want to take a string like “2010-02-19” and turn it into a string like “Friday, Feb 19.” The strings I will be receiving will always be in 2010-02-19. Right now, I am running the following code that works, but it produces a warning that says “NSDate may not respond to +dateWithNaturalLanguageString:”NSDate *date = [NSDate dateWithNaturalLanguageString:scheduled]; NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelea
DA.
iphone safari hover
I’m experimenting with ways to have tooltips work across a variety of mobile devices. Unfortunately, the span of devices I need to support ranges from Nokias to iPhones.Unfortunately, some of the browsers I’m dealing with don’t support the use of the title attribute for tooltips on focus. As such, I need to come up with a different solution.For starters, I’m playing with pure-css tooltips: http://psacake.com/web/jl.aspThis method uses the :hover pseudo class to position and set the z-index of a
Danial
iphone objective-c memory-management memory-leaks nsdictionary
In my application I have a connection to an sqlite3 database. I have made a wrapper class, in this wrapper class I have an NSMutableDictionary and NSMutableArray.Each time a query is run I removeAllObjects from the dictonary and the array in the rapper class (I don’t release it). I then add the results from the query to the array and dictionary. The dictionary contains another subdictionaries.I have a tableViewController, in this class I get data from the database using my rapper class and copy
Tullio Onion Sebastiani
iphone objective-c ios6 storyboard navigationcontroller
I’m developing an iOS6 App with storyboards and i’m encountering an unexpected beahviour. My app is almost in portrait mode , and i would keep this orientation in all the views except two.For this reason the project supports both landscape and portrait mode, i’ve subclassed navigation controller with a category (as explained almost everywhere :-)in Appdelegate.m and every view controller implements – (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskPortrait; (landscap
Alexi Groove
iphone objective-c ocmock
I want to unit test the custom init method of a class that inherits from NSURLConnection — how would I do this if the init of my testable class invokes NSURLConnection’s initWithRequest?I’m using OCMock and normally, I can mock objects that are contained within my test class. For this inheritance scenario, what’s the best approach to do this?- (void)testInit { id urlRequest = [OCMockObject mockForClass:[NSURLRequest class]];MyURLConnectionWrapper *conn = [[MyURLConnectionWrapper alloc] initWi
msgambel
iphone objective-c ipad settings volume
Currently, I’m setting the volume to max, and then checking if the volume is at max, or a lower value. If it’s at a lower value, then the user must have a Volume Lock on their system.This works fine, but I’m wondering if there is some method to call, or property to check which tells me this in code for free? I’ve been looking online as to how to do this, but I can’t seem to find anything. Thanks in advance!Edit: It turns out that my previous method of setting the max volume and then checking if
Vikings
iphone objective-c ios4 iphone-sdk-3.0
I am having unexpected results with my application. I am using a settings bundle, and I want to the default switch to turn on. The switches are off when I start my application. But the sound and the shake are working. I just want the switch to be one when my application loads, and the sound and the shake to be enabled.- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Set the application defaultsNSUserDefaults *defaults = [NSU
kender
iphone cocoa-touch memory-management cocos2d-iphone
I 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’t fully released – the [retainCount] for them is somewhat about 4-10 🙂 The dealloc method never gets called, and then I assume, when I switch the scenes a few times, the memory issue shows up. I’m wondering – where should I relese the scene? Since it has number of children, I suppose I should be doing a cleanup-removal of t
LearnCocos2D
cocos2d-iphone uialertview
I 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:@”You Win” message:nil delegate:self cancelButtonTitle:@”Next” otherButtonTitles:@”Replay”,@”Quit”, nil];UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(-50, -30, 400, 300)];NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathCom
White Money
iphone cocos2d cocos2d-iphone
I’m wonderring that what’s the difference between ccTouchesCancelled and ccTouchesEnded events in Cocos2d?Thanks! Tien
OpenLearner
cocos2d-iphone cocos2d
I 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’t complete):-(void)correctRotation{if (self.rotationAmount){CCLOG(@”correcting rotation inside: %i”,self.buildNum);CCRotateBy*second=[CCRotateBy actionWithDuration:1 angle:-self.rotationAmount];CCEaseBackInOut*bounce2=[CCEaseBackInOut actionWithAction:second];CCCallFunc*func=[CC
25 revs, 2 users 100%Lukasz
iphone cocos2d-iphone opengl-es-2.0 alpha blending
I 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
Geoffroy
c++ cocos2d-iphone copywithzone
I 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
Mason
ios cocos2d-iphone
I think I might be causing a bug in my code because I’m unclear about what the cleanup: part of removeChild:cleanup: method of cocos2d ccnode class.Thanks.
oopology
objective-c cocos2d-iphone nsarray
What are the differences between NSArray and CCArray? Also, in what cases will one be preferred to the other with respect to game programming?
Sushi Ninja
ios cocos2d-iphone
I’m currently trying to create an endlessly scrolling background with a character who jumps up and down and collects items that come along the way. My problem lies with the items that need to be created and then moved.I’ve looked at CCSpriteBatchNode and NSMutableArray but I’m not sure which to use.I reviewed Steffen Itterheim’s example from his book regarding creating bullets while initializing and then using them when needed. I thought that this would be inefficient and taxing on the iPhone. A
Just Kidding
objective-c cocos2d-iphone
I’m using a Objective-C framework for game development called Cocos2d-iphone.This is how I create a button-graphic in the game:CCMenuItemImage *battle;battle = [CCMenuItemImage itemFromNormalImage:@”BattleFightOption1.png” selectedImage:@”BattleFightOption2.png”target:self selector:@selector(battleFightOption)];Basically, when the user clicks the button, method battleFightOption runs.But I wonder, I never did define battleFightOption in the interface.. so, my question is: when is it necessary to
epologee
objective-c interface coding-style implementation
If you write method implementations in Objective-C, it is pretty standard to sum up the methods of a class in the corresponding @interface blocks. Publically accessible methods go in the header file’s interface, not-so-public methods can go in an empty category on top of the implementation file.But it’s not neccessary to declare an interface for every method. If you only reference the methods below their implementation code of the same class/file, there’s no need to put any declaration anywhere
Cristian Civera
c++ ios objective-c opencv
I’m using this function to convert UIImage to Mat- (cv::Mat)cvMatFromUIImage:(UIImage *)image { CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage); CGFloat cols = image.size.width; CGFloat rows = image.size.height;cv::Mat cvMat(rows, cols, CV_8UC4); // 8 bits per component, 4 channels (color channels + alpha)CGContextRef contextRef = CGBitmapContextCreate(cvMat.data, // Pointer to datacols, // Width of bitmaprows, // Heig
Zephyer
objective-c json parsing afnetworking
im trying to parse some JSON. for simplicity ill explain using the default example at github: when running:NSURL *url = [NSURL URLWithString:@”http://httpbin.org/ip”]; NSURLRequest *request = [NSURLRequest requestWithURL:url];AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {NSLog(@”IP Address: %@”, [JSON valueForKeyPath:@”origin”]);} failure:nil];[operation start];i get
Ben
ios objective-c cocoa-touch nsdate nsdateformatter
In short words I plan to get current dateTime, change the time and make it local to Malaysia Time by applying +0800 to timezone.The result is unexpected :-(NSDate *)departureDateTime {NSDate *date = [NSDate date];NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];NSDateComponents *components = [gregorian components: NSUIntegerMax fromDate: date];[components setHour: 7];[components setMinute: 59];[components setSecond: 17];NSDate *newDate = [gregorian dat
horseshoe7
ios objective-c core-data nsmanagedobject mogenerator
I have a project using CoreData. I use Mogenerator to generate the subclasses.When I set the value of a property, this value isn’t actually assigned. Each subsequent time I try to set the value, the previous value I set it to was not assigned.This worked fine as my underlying data framework was Mantle, but since moving to CoreData, this stopped working. I rely on KVO to keep some UIView objects up-to-date with the model.Again, the ivars of a CoreData NSManagedObject subclass do not seem to ta
John
objective-c xcode4 ios-sdk-4.3 aqgridview
I am new in Iphone development . Now, i am trying to develop an AQGridView in iphone . I downloaded the zip file of AQGridView from Github socil coding site. The example application of AQGridView (ImageDemo,SpringBoard,ExpanderDemo) can not run in xcode 4 and ios sdk 4.3.At compail time they showing some error “AlanQuatermain-AQGridView-4072978/Examples/ImageDemo/main.m:14:5: error: unexpected ‘@’ in program [3]”The error indicator shown at main(). The code of main() is bellow.int main(int argc
Krishnan
objective-c memo
I came to know that, it is better to use copy on @property of NSString than retain due to the problems you can get if you are provided with a NSMutableString. Is the same condition holds true for NSArray , NSDictionary, NSMutableData ?
Danial
iphone objective-c memory-management memory-leaks nsdictionary
In my application I have a connection to an sqlite3 database. I have made a wrapper class, in this wrapper class I have an NSMutableDictionary and NSMutableArray.Each time a query is run I removeAllObjects from the dictonary and the array in the rapper class (I don’t release it). I then add the results from the query to the array and dictionary. The dictionary contains another subdictionaries.I have a tableViewController, in this class I get data from the database using my rapper class and copy
Tullio Onion Sebastiani
iphone objective-c ios6 storyboard navigationcontroller
I’m developing an iOS6 App with storyboards and i’m encountering an unexpected beahviour. My app is almost in portrait mode , and i would keep this orientation in all the views except two.For this reason the project supports both landscape and portrait mode, i’ve subclassed navigation controller with a category (as explained almost everywhere :-)in Appdelegate.m and every view controller implements – (NSUInteger)supportedInterfaceOrientations{return UIInterfaceOrientationMaskPortrait; (landscap
Alexi Groove
iphone objective-c ocmock
I want to unit test the custom init method of a class that inherits from NSURLConnection — how would I do this if the init of my testable class invokes NSURLConnection’s initWithRequest?I’m using OCMock and normally, I can mock objects that are contained within my test class. For this inheritance scenario, what’s the best approach to do this?- (void)testInit { id urlRequest = [OCMockObject mockForClass:[NSURLRequest class]];MyURLConnectionWrapper *conn = [[MyURLConnectionWrapper alloc] initWi
Web site is in building