spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » OBJECTIVE C » Page 1
Forward/pass through UIGesture (swipe) to sibling view
I've found a solution for this issue. While I was unable to forward the swipe up/down gestures to the image views behind the scrollview, I've now added gesture recognisers with direction up/down to the scrollview. In the gesture recognisers actions, I determine the point of the gesture within the window and hittest the window's first view for these point with a nil event. In the custom scrollview,

Categories : Objective C

Duplicate Symbols when removing Preprocessor code
You seem to have these constants defined in a header file. The header file is imported into multiple other files; the definition is thus repeated across all those files. Multiple definitions using the same name are not allowed. What you want to do instead is to declare the constant in the header: extern NSString * const NOTIFICATION_PLAYBACK_STATE_CHANGED; extern indicates to the compiler "thi

Categories : Objective C

Calling a Method on Watchkit
Check the target for your Methods class and make sure it is in your watch kit extensions target. Alternately, look at building a framework for your shared classes. https://developer.apple.com/videos/wwdc/2014/?id=416

Categories : Objective C

Calabash-ios - Put the device is Airplane Mode
It is not possible to put your device into Airplane mode with Calabash iOS. You could write a backdoor method in your app that simulates Airplane mode. Be aware however, that Calabash iOS embeds an http server in your application; that is how the client gem communicates with your app. http://calabashapi.xamarin.com/ios/Calabash/Cucumber/Core.html#backdoor-instance_method The Xamarin Test Clo

Categories : Objective C

How to pass an encrypted NSString with stringByAppendingFormat?
Typically you would base64 encode binary data in an http request. NSString *encoded = [encryptedData base64EncodedStringWithOptions: NSDataBase64Encoding64CharacterLineLength];

Categories : Objective C

iOS static library?
Please provide the compiler error that you hit. Regarding the size issue, check that both libraries are including the same architectures. If you compile liborange for just one architecture, it might pick up just the correct arch from libapple and therefore be smaller.

Categories : Objective C

remove cache in wkwebview objective c
Try setting up the cache first when the application loads. -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { int cacheSizeMemory = 4*1024*1024; // 4MB int cacheSizeDisk = 32*1024*1024; // 32MB NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlca

Categories : Objective C

localized images do not load without app restart
There is one simple workaround Use different images with different name according to language and load the image according to the language chosen from code. e.g. In tableView cellForRowAtIndexPath Method if(language = english) { imageName = @"logo_english"; } else if (language = french) { imageName = @"logo_french"; } Otherwise use apple native localisation of images which takes effect aft

Categories : Objective C

Objective-c Web/URL preview as in facebook app
You can do it with something like this: UIWebView *webView = [[UIWebView alloc] initWithFrame: CGRectMake(0.0, 0.0, 1.0, 1.0)]; webView.delegate = self; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: [NSURL URLWithString: @"www.my_url.com"] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: myTimeoutValue]; [self.webView loadRequest: request];

Categories : Objective C

UITableViewCell display wrong content
Am I correct if I guess that "wrong content" means the textLabel of the cells in your first section have the wrong color? That's because you don't set the textColor of the textLabel in your section == 0 code path. Cells are reused, so if you use the same reuse identifier you have to set the attributes in all your code paths. The cell from section 1 keeps the textColor for the label once it was s

Categories : Objective C

Focus not changing even if the focuspointofinterest has changed on iPhone6 and iPhone6+ only
This is not as much of an answer as it is a workaround. From observation, when in AVCaptureFocusModeAutoFocus mode, the focus triggers a scan and focuses on the required point of interest and then then locks the focus (AVCaptureFocusModeLocked). If you change mode to AVCaptureFocusModeContinuousAutoFocus, without changing the point of interest, the camera will perform a full frame focus and so

Categories : Objective C

JSON ObjectiveC - Error
I go to your URL and get this message {"status":{"message":"the daily limit of 30000 credits for demo has been exceeded. Please use an application specific account. Do not use the demo account for your application.","value":18}} But you can try my code, it worked for me NSString *strUrl = @"http://api.geonames.org/weatherIcaoJSON?ICAO=YBBN&username=demo"; NSURL *url = [NSURL URLWithString:st

Categories : Objective C

Swift: How to check object is Array or String class?
Given a value extracted from a dictionary: var value: AnyObject? = keywords[index] You can check its type using the is operator: if value is NSString { println("It's a string") } else if values is NSArray { println("It's an NSArray") } or using a switch statement: switch (value) { case let value as NSString: println("It's an NSString") case let value as NSArray: println("I

Categories : Objective C

(Swift/iOS) Is it possible to get user purchased items from In app purchases?
There isn't. It's up to you to manage this information. You can do this the easy way locally using NSUserDefaults and restoring purchases (for new devices). Or the lengthier way - storing all purchases on your server.

Categories : Objective C

semaphore_wait_trap when accessing class singleton using Swift
When MyManager gets created, a lock is used to prevent other threads from accessing the variable while it is being created. You cannot access this variable from within the init method. It doesn't just seem to hang your program, it will every single time hang your program because you are creating a deadlock. Solution: Don't use that variable from your init method. Don't access _SharedInstance fro

Categories : Objective C

Derived UICollectionViewCell always returns null from dequeueReusableCellWithReuseIdentifier
Make sure in the xib file that the File's Owner property indicates the class name that implements it. Then, implement: - (NSString *)reuseIdentifier { return @"imageCell"; } in your ImageViewCell implementation. There also might be a way to set this in interface builder, rather than overriding the getter. By the way, if your ImageViewCell is backed by a xib, initWithFrame: will not be the

Categories : Objective C

UIView class properties seemingly disappear when I call drawRect:
This is a nasty one! I think you have 2 instances of PlayingCardView: Your view connected to your IBOutlet in Interface Builder Your (same) view in IB where/because you have not set the class to PlayingCardView. So that drawRect call is actually happening on the PlayingCardView in your IB when it is loaded from IB and not on the "outlet" view where you are setting the rank and suit. I am gu

Categories : Objective C

For Loops, i and Strings Troubles in Objective C
Try changing [@"/current%d.html", num]; to [NSString stringWithFormat:@"/current%d.html", num]; When you enclose your statement in [], Obj-C expects the statement to be a message-receiver pair. Here the +(NSString *)stringWithFormat:(NSString *) class method receives the NSSting @"/current%d.html", num" message/parameter. Don't know all the proper terminology, but thats the get of it I believe

Categories : Objective C

NSBitmapImageRep from duration for animated GIF
So thanks to Heinrich I now know that the gif as two values, the real one and the clamped value. Sadly NSBitmapImageRep only provides the clamped value, but with CGImageProperty I can read both values. So I iterate through each frame, update the duration with the correct one and in the end create a CAAnimation like in: https://github.com/orta/GIFs/blob/master/objc/GIFs/ORImageView.m So this is th

Categories : Objective C

calling a method in IBAction method
remove [self touchesBegan] from your "Touch" method you are 1. calling this method without the necessary parameters, so you are probably getting unrecognized selector sent to instance, 2. the uiview calls this method on its own, you just need to override it

Categories : Objective C

How do I add multiple ViewControllers to my UIPageViewController?
Here is the fully working code if anyone is interested. Took me a while to get it right, but eventually this worked perfectly! #import "PageViewController.h" @interface PageViewController () @property (nonatomic, retain) UIViewController *first; @property (nonatomic, retain) UIViewController *second; @property (nonatomic, retain) UIViewController *third; @property (nonatomic, retain) UIViewCon

Categories : Objective C

How to lower a UIView element in a SpriteKit scene
Here's a SpriteKit-friendly way to draw random lines on a background image. The basic steps are Create a blank image Convert the image to an SKTexture Create a sprite with the texture Draw a random line on the image Update the sprite's texture with the image Wait for 0.1 seconds Iterate over steps 4-6 In GameScene.m, add the following -(void)didMoveToView:(SKView *)view { self.scaleMode

Categories : Objective C

What does this segue error mean?
Warning: Attempt to present <GameOver: 0x7ffc7b714280> on <Playing_Page: 0x7ffc7b7128b0> whose view is not in the window hierarchy! Can someone explain to me what this means, and which View isn't in the window hierarchy It means exactly what it says. You have a view controller called Playing_Page and a view controller called GameOver. You told Playing_Page to presentViewContro

Categories : Objective C

What is the correct way of accessing a Swift Delegate from Objective-C?
You have the right idea, but have a few bugs that are preventing this from working. You've declared Geo32Boundaries as conforming to the DiscoveryContributeProtocol, but it doesn't need to and doesn't actually implement it, it only has a property that conforms to that protocol. That's the source of the "Method 'radiusString:' not implemented" error: @interface Geo32Boundaries: UIViewController

Categories : Objective C

How to enable/disable push notification from the app iOS 8
The registerForRemoteNotificationTypes method is deprecated. Apple lists the new method that you should use (registerForRemoteNotifications). Hard to tell if your question is about the warning you get, or about it functioning as you expect it to.

Categories : Objective C

NSStackView does not layout views properly
Alright, I've found the solution to my own problem and I am posting it so everyone who searches for this and finds the question will have the answer. The issue is that NSScrollView does not have an intrinsic content size, which prohibits the NSStackView which knowing what height it ought to be, hence the second NSScrollView was being collapsed. The constraints created by default in Xcode give the

Categories : Objective C

How can I get the amound of seconds from a NSDate ("hh:mm:ss") and vice versa
You could have a place holder date e.g. 00:00:00 and then use the NSDate function timeIntervalSinceDate: to get the seconds. Converting back again you could use the dateWithTimeInterval: method. Obviously both these dates would have to be the same year month and day and you could use any arbitrary values for these as long as they are the same.

Categories : Objective C

What happens to the Users/username/Library directory. Why can't I change the current directory?
The Library directory does exist but it is hidden as standard. Open up the terminal and type the command: chflags nohidden ~/Library/. Then look again and it will be magically there! Edit: for programming with NSFileManager there's a very useful function: NSSearchPathForDirectoriesInDomains(). E.g. To get the desktop do directory: NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDeskto

Categories : Objective C

When should I use nil in objective-c?
Essentially because memory is now all managed by ARC you could get away with using either or in your code. However, nil is for all Objective-C objects e.g. NSError whilst NULL is for C style things like (void*).

Categories : Objective C

Is there a way to declare an objective-C block typedef whose arguments contain that typedef?
rmaddy's comment is correct. Just as in C, a typedef cannot use itself. Basically, a typedef does not make a real type, but just makes an alias that the compiler expands out at compile-time. It is always possible to manually expand all typedefs in your program yourself (which is sometimes an instructive exercise), so that your program is written without typedefs. However, a recursive typedef canno

Categories : Objective C

More than one inverse relationship to the same entity in core data
I solved this using entity inheritance as described here: https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreData/Articles/cdMOM.html

Categories : Objective C

Why is this code updating location twice every time?
After a quick look at Apple's documentations, I've noticed that the delegate method you are using, - locationManager:didUpdateToLocation:fromLocation: is deprecated since iOS 6. Instead, you should use - locationManager:didUpdateLocations:. Try replacing your code with the code below and see if it make any difference: EDIT- I've edit the code below to handle the double-call you get. From you

Categories : Objective C

In Cocoa on OS X, what use interface component allows the user to select a new file?
Use the NSSavePanel component. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSSavePanel_Class/index.html.

Categories : Objective C

Unable to "pop" view controller using "Show" segue in XCode 6
So I figured out the issue to this problem. Essentially when passing the data back to the parent controller to the delegate, I wasn't on the main thread. Therefore it would eventually timeout and return to the view, but very slowly. My two views: QRScanner.m < The scanning view @interface ScanQRViewController () @end @implementation ScanQRViewController @synthesize scanPreview, scanPreviewL

Categories : Objective C

Objective C - Error loading bundle
You cannot load resources from outside your application bundle or bundle container. "/var/ mobile/Documents" is inaccessible to your application. The actual error you are getting is that the system could not load the executable for the bundle. -loadAndReturnError: is for loading code in that bundle. You seem to be loading a bundle that has resources, but not executable code.

Categories : Objective C

Errors With Switch Statement to Present New View
One of the unfortunate things about "switch" statements is that you can't declare variables within them. You need to declare your variables above and outside of your switch statement. Something like: OnePlayerViewController *onePlayerViewController; TwoPlayersViewController *twoPlayersViewController; switch (self.players) { case 1: onePlayerViewController = [self.storyboard instant

Categories : Objective C

Calculation for start and end dates of the month are incorrect
startOfMonth prints incorrectly also. The times are actually correct, however when you print them, it prints with your timezone. Printing a date will print that date in the UTC timezone. You can print it in your set timezone like this: NSLog(@" startOfMonth: %@ endOfMonth: %@ interval: %d",[startOfMonth descriptionWithLocale:[NSLocale systemLocale]], [endOfMonth descriptionWithLocale:[NSLocal

Categories : Objective C

How would you incorporate a Swift struct/enum into Objective-C?
There are a number of Swift features that can't be used in Objective-C. I posted an answer to a question the other day that asked something similar. I'll re-post the answer here: According to Apple's docs on Swift and Objective-C compatibility: You’ll have access to anything within a class or protocol that’s marked with the @objc attribute as long as it’s compatible with Objective-C

Categories : Objective C

objective-c animations - how to set end position, direction and type
There is no "starting position". There is no "direction of movement" or "type of animation". Animation is a change over time. The view is a certain way at the time your code runs. UIView animation has 6 possible view properties. You change any of those in the animation block (which states the time) and the change is animated - that is, instead of the change just happening, kaboom, it is performed

Categories : Objective C


Recently Add
Adding 'data' to an NSMutable Array - Xcode
Forward/pass through UIGesture (swipe) to sibling view
Duplicate Symbols when removing Preprocessor code
Calling a Method on Watchkit
Calabash-ios - Put the device is Airplane Mode
How to pass an encrypted NSString with stringByAppendingFormat?
iOS static library?
remove cache in wkwebview objective c
localized images do not load without app restart
Objective-c Web/URL preview as in facebook app
UITableViewCell display wrong content
Focus not changing even if the focuspointofinterest has changed on iPhone6 and iPhone6+ only
JSON ObjectiveC - Error
Swift: How to check object is Array or String class?
(Swift/iOS) Is it possible to get user purchased items from In app purchases?
semaphore_wait_trap when accessing class singleton using Swift
Derived UICollectionViewCell always returns null from dequeueReusableCellWithReuseIdentifier
UIView class properties seemingly disappear when I call drawRect:
For Loops, i and Strings Troubles in Objective C
NSBitmapImageRep from duration for animated GIF
calling a method in IBAction method
How do I add multiple ViewControllers to my UIPageViewController?
How to lower a UIView element in a SpriteKit scene
What does this segue error mean?
What is the correct way of accessing a Swift Delegate from Objective-C?
How to enable/disable push notification from the app iOS 8
NSStackView does not layout views properly
How can I get the amound of seconds from a NSDate ("hh:mm:ss") and vice versa
What happens to the Users/username/Library directory. Why can't I change the current directory?
When should I use nil in objective-c?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.