[Solved] How to open Documents files of device programmatically in iOS [closed]

To open office files within an iOS app you can: 1- Use UIWebView . Here is a sample code with a document included in the app’s resources. NSString *path = [[NSBundle mainBundle] pathForResource:@”document” ofType:@”ppt”]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [self.webView loadRequest:request]; 2- You can use the QuickLook framework to preview … Read more

[Solved] Sort strings alphabetically AND by length?

tl;dr: the key paths you are looking for are “length” and “self” (or “description” or “uppercaseString” depending on what how you want to compare) As you can see in the documentation for NSSSortDescriptor, a sort descriptor is created “by specifying the key path of the property to be compared”. When sorting string by their length, … Read more

[Solved] draw a layer with some color in iPhone Application

If your app is just quitting with no debug error, there still could be a message sent to some deallocated instance. Try turning on NSZombieEnabled by following the instructions here: http://www.codza.com/how-to-debug-exc_bad_access-on-iphone This will tell you when a bad message is sent. Further, if you’d like to ask a question involving specific code, you’ll get better … Read more

[Solved] how can I use NSURLConnection Asynchronously?

Block code is your friend. I have created a class which does this for you Objective-C Block code. Create this class here Interface class #import <Foundation/Foundation.h> #import “WebCall.h” @interface WebCall : NSObject { void(^webCallDidFinish)(NSString *response); } @property (nonatomic, retain) NSMutableData *responseData; -(void)setWebCallDidFinish:(void (^)(NSString *))wcdf; -(void)webServiceCall :(NSString *)sURL_p : (NSMutableArray *)valueList_p : (NSMutableArray *)keyList_p; @end Implementation … Read more

[Solved] Objective-C programming [closed]

Almost certainly you have: Thing account1[6] = { … }; for (i = 0; i <= 6; i++) { if ([user1 isEqualToString:account1[i].name]) and the compiler knows that <= 6 will go beyond the bounds of the array (last index is 5 not 6). To correct: for (i = 0; i < 6; i++) ^ solved … Read more

[Solved] unrecognized selector sent to instance AdViewController [closed]

This method is deprecated in iOS5. You must build your project to target iOS 5 or earlier. http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAccelerometerDelegate_Protocol/DeprecationAppendix/AppendixADeprecatedAPI.html You must replace it with Core Motion functionality to move to a newer version of iOS. http://developer.apple.com/library/ios/#documentation/CoreMotion/Reference/CMMotionManager_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40009670 2 solved unrecognized selector sent to instance AdViewController [closed]

[Solved] Open a link when alert ok button is pressed [closed]

You don’t actually need pathAlert.delegate = self. You’ve already set the delegate in the initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles: method call. In your .h file, you need to do this: @interface YourViewControllerName : UIViewController <UIAlertViewDelegate> And in the .m file add this method: – alertView:(id)alert didDismissWithButton:(int)index { [[UIpplication sharedApplication] openURL:[NSURL URLWithString:@”foo”]; } Alternatively, and possibly better might be to … Read more

[Solved] How to check if 2 Dates have a difference of 30days? [duplicate]

You can convert both dates to seconds with timeIntervalSince1970 and then check if difference is bigger than 2592000 (30*24*60*60 which is 30 days * 24 hours * 60 minutes * 60 seconds). NSTimeInterval difference = [date1 timeIntervalSince1970] – [date2 timeIntervalSince1970]; if(difference >2592000) { //do your stuff here } EDIT: For more compact version you can … Read more

[Solved] Navigation Bar gets funky if Swipe Gesture and Back Button are triggered at the same time

To fix this I disable user interactions for the navigationsbar. To do so, I subclass UINavigationViewController and use Key-Value-Observing to detect the state of the gesture recognizer. #import “NavigationViewController.h” @interface NavigationViewController () @end @implementation NavigationViewController – (void)viewDidLoad { [super viewDidLoad]; [self.interactivePopGestureRecognizer addObserver:self forKeyPath:@”state” options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:NULL]; } – (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void … Read more

[Solved] Is it true that using view controllers and viewDidLoad method for implementing my methods? [closed]

You don’t have to use (performSelector:withObject:afterDelay:) all the time ! Say you have two methods implemented in your viewController : -(void) firstMethod { //do stuff here } -(void) secondMethod { //do stuff here } you can call those methods this way : – (void)viewDidLoad { [super viewDidLoad]; [self firstMethod]; [self secondMethod]; } Now what we … Read more

[Solved] Checking whether elements of an Array contains a specified String

NSString has a rangeOfString function that can be used for looking up partial string matches. This function returns NSRange. You can use the location property. … NSArray *qwer = [NSArray arrayWithObjects:@”Apple Juice”,@”Apple cake”,@”Apple chips”,@”Apple wassail”nil]; for (NSString *name in qwer){ if ([name rangeOfString:keyword].location == NSNotFound) { NSLog(@”contains”); } } … Reference : https://developer.apple.com/reference/foundation/nsstring/1416849-rangeofstring https://developer.apple.com/reference/foundation/nsrange Thanks … Read more