cocoa-touch
How to dismiss a modal that was presented in a UIStoryboard with a modal segue?
There isn’t any storyboard magic for dismissing a modal view controller without writing at least a little bit of code. But while you do have to implement some code of your own, you don’t necessarily have to go to that much trouble. You can just have a button in view controller B that calls [self … Read more
Reading data from response header of NSURLConnection
If the URL is an HTTP URL, then the NSURLResponse that you receive in your connection’s delegate’s -connection:didReceiveResponse: method (or via another method) will be an NSHTTPURLResponse, which has an -allHeaderFields method that lets you access the headers. NSURLResponse* response = // the response, from somewhere NSDictionary* headers = [(NSHTTPURLResponse *)response allHeaderFields]; // now query … Read more
How to change the value of an NSMutableArray at a particular index
Use -insertObject:atIndex: or replaceObjectAtIndex:withObject:.
Xcode 4.6, used as the name of the previous parameter rather than as part of the selector [duplicate]
Your first method is declaring the selector +addFormatPrice::. With spaces, it looks like + (NSString *)addFormatPrice:(double)dblPrice :(BOOL)booRemoveCurSymbol; This is invoked like [NSString addFormatPrice:0.3 :YES]. What you should do is actually give a name to the previous parameter, such as + (NSString *)addFormatPrice:(double)dblPrice removeCurSymbol:(BOOL)booRemoveCurSymbol; Which would then be invoked like [NSString addFormatPrice:0.3 removeCurSymbol:YES].
Can you access application delegate from within a UITableViewDataSource function?
The Application is a singleton which maintains a reference to the app delegate. You can always access your app delegate using: [UIApplication sharedApplication].delegate You may need to cast the return to your own app delegate class to get rid of warnings. Even better, write an accessor that returns your upcast app delegate: #pragma mark access … Read more
Moving a CLLocation by x meters
A conversion to Swift, taken from this answer: func locationWithBearing(bearingRadians:Double, distanceMeters:Double, origin:CLLocationCoordinate2D) -> CLLocationCoordinate2D { let distRadians = distanceMeters / (6372797.6) // earth radius in meters let lat1 = origin.latitude * M_PI / 180 let lon1 = origin.longitude * M_PI / 180 let lat2 = asin(sin(lat1) * cos(distRadians) + cos(lat1) * sin(distRadians) * cos(bearingRadians)) let … Read more
How to replace a character in NSString without inserting a space?
I just ran the following as a test NSString * myString = @”Hello,”; NSString * newString = [myString stringByReplacingOccurrencesOfString:@”,” withString:@””]; NSLog(@”%@xx”,newString); And I get 2010-04-05 18:51:18.885 TestString[6823:a0f] Helloxx as output. There is no space left.