FAQ Database Discussion Community


PFUser not unwrapped - swift

ios,xcode,swift
I'm beginning to learn swift with parse and i've run into this error: "Value of optional type 'PFUser?' not unwrapped; did you mean to use '!' or '?' I can't seem to get it to work... PFFacebookUtils.logInWithPermissions(["public_profile", "user_about_me", "user_birthday"], block: { user, error in if user == nil { println("the...

App crashes when i start typing in uiseachbar in uitableview

ios
I am making a project in which i am fetching addressbook in my tableview with the help of NSObject class. Now , I allocated a UISearchbar in it , but when i start typing , the app crashes with the following error :---- 'Can't use in/contains operator with collection (not...

iOS: What is the callback when tapped on the empty space between keyboard and search bar to dismiss the keyboard when search bar is active

ios,objective-c,swift
I have SearchController for my TableViewController. I wanted to perform some actions when user taps on the empty space on the screen (between the keyboard and search bar) to dismisses the keyboard and displays the main Table View.

NS_ENUM as property in protocol

ios,objective-c,automatic-ref-counting
I came across to strange behaviour. I used to have: @property (nonatomic) ApplicationState applicationState; directly in my Application class. Now it's extracted to protocol @protocol ApplicationProtocol <NSObject> @property (nonatomic) ApplicationState applicationState; ApplicationState is Enum typedef NS_ENUM(NSUInteger, ApplicationState) { ApplicationStateNormal = 0, ApplicationStateExpanded = 1, ApplicationStateMaximized = 2 }; Now. It...

Parse: How can I update all rows with the same key value?Thanks

ios,swift,parse.com
How can I update all rows with the same key value in a Parse class? As my code, I think Parse would cost a lot of my money if there are 100 objects per user. Is there any other way to do that? Thanks a lot! let username = PFUser.currentUser()?.username...

Swift - UILabel from URL

ios,swift,uilabel,nsurl
I wanted to know if it's possible to load the text in a label from a URL. I was going to try and use NSURL to pull in a .txt file stored online. Would anyone know how to implement this with swift? Thanks...

IOS - Adjust cell height based on content

ios,uitableview,autolayout
im trying to build apps that have tableview cell similiar with twitter, there are text and images. My problem is i want to insert the image above the text. While it can be text only. So if there are no image, the text will be in position (0,0). And if...

coordinate deprecated as of iOS 7

ios,iphone,swift
I am trying to grab the latitude and longitude of a users location. I have a code which worked prior to deprecation, and I cannot figure out how to fix it. The error is on the coordinate section of latestLocation.coordinate.latitude and latestLocation.coordinate.longitude, and the error states: 'coordinate' is unavailable: APIs...

ios open call history

ios,call,history
How to open the call history programmatically? Sort of: call://history ?...

Regular expression to get url in string swift

ios,regex,swift
I try to get urls in text. So befor I used such expression let re = NSRegularExpression(pattern: "https?:\\/.*", options: nil, error: nil)! But I had a problem, when user input urls with Capitalized symbols like it doesn't match it ( I tried let re = NSRegularExpression(pattern: "(h|H)(t|T)(t|T)(p|P)s?:\\/.*", options: nil, error:...

Indent second line of UILabel

ios,objective-c,uilabel
So I have a UILabel that may or may not go to a second line, depending if it is on iPhone or iPad. What I would like to accomplish is to have it indent on the second line to line up correctly, if needed. On iPad it will almost never...

Can't figure out coder aDecoder: NSCoder

ios,xcode,swift
I'm making an app for archiving books, I'm at the point of hooking up a button to save the data, but I can't get past the initialisation. Here is the error Xcode is giving me : Property 'self.bookStore' not initialised at super.init call. And here is my code : import...

UITabBarViewController doesn't rotate - iOS

ios,uitabbarcontroller,auto-rotation,shouldstartload
I have a UITabBarViewController that contains 5 tabs and a login view which is not part of my tab bar, in my settings I have set that I support all device orientations. but when I run my app, only my login view is the only which rotates. I have created...

MFMessageComposeViewControllerDelegate not being called

ios,swift
I am trying to implement a class that will present a MFMessageComposeViewController from the AppDelegate. The class declaration looks like this: import UIKit import MessageUI class MyClass: NSObject, MFMessageComposeViewControllerDelegate { func sendAMessage() { // message view controller let messageVC = MFMessageComposeViewController() messageVC.body = "Oh hai!" messageVC.recipients = ["8675309"] // set...

TabBarController instance Swift 2.0

ios,tabbarcontroller,swift2
I am trying to Compile my app again now that Swift 2 is out and the thing is I am having an error with TabBarController instances. I am declaring the instances in vars in order to use methods from anothers ViewControllers. Here it's my code: let barViewControllers = self.tabBarController?.viewControllers let...

CPU & Memory steadily increase & FPS drops all because of vector movement

ios,objective-c,sprite-kit
My CPU & Memory steadily increases over the course of roughly 6 minutes during play testing of my current Sprite Kit game. I've found that the method '-(void)walkToward:(CGPoint)targetPosition' inside the Player class is responsible (it moves the character to a tapped location on screen), but I DON'T understand why. The...

Change background color of viewcontroller but not top area with clock

ios,user-interface,uiviewcontroller
I want to make my whole ViewController grey except I want the top area where it shows CARRIER and the current time to remain white. Is the only way just to stick a View that covers everything except that area, and set it to grey, or is there some way...

Override UITabBarController Icon Selection

ios,objective-c,uitabbarcontroller
I'm using a standard UITabBarController with icons at the bottom, each bringing to it's ownViewController. My question is basically: Is there a way to override what happens when an icon is selected rather then directly bringing them to the view? Reason being is because I'm adding a login screen to...

How to draw each a vertex of a mesh as a circle

ios,unity3d,shader,mesh,particle
How to draw each a vertex of a mesh as a circle?

Present a modal view using fade-in animation

ios
I presented a login screen as follows modally. Correct me if I am not right. UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"login"];//LOOK AT NEXT LINE [self presentViewController:ivc animated:YES completion:nil]; The login screen does appear but the animation is a slide up one. I prefer a fade...

SpriteKit collision angle of line and circle is odd

ios,sprite-kit,skphysicsbody
Suppose a circle is enclosed in a diamond, and the circle heads due right. I would expect a series of continual 90 degree angles as the circle draws a square within the diamond. What I'm seeing, however, is that the circle eventually gets pushed toward the center of the diamond...

Obj-C Instance method returning a instanceType called from Swift - Function produces expected type 'UIImage!' error

ios,objective-c,swift
I have this instance method in an existing Obj-C UIImage category: - (UIImage *)applyDarkEffect; I'm trying to call it from a Swift file like so: self.backgroundImageView.image = UIImage.applyDarkEffect(image) But get this compiler error: Function produces expected type 'UIImage!'; did you mean to call it with '()'? ...

How to get time difference based on GMT on Swift

ios,swift
I am trying to get a time difference based on a GMT time. where at the end of everyday the timer resets to zero. I've tried the below code on the Xcode simulator and every time i change the time on the mac, the difference also changes. how can i...

how i can solve Image auto resize in iphone 4 5 6 6+

ios,objective-c,iphone,objective
I give three types of image like image.png [email protected] [email protected] but not working image autoresize in all device....

ios8 Timezone parsing changed?

ios,nsdateformatter
Has the parsing for timzones changed in iOS8? I try to parse the date "2014-09-03 12:20:38.000 +0200" with this code and get nil: -(NSDateFormatter*) dateAndTimeFormatter{ if(!_dateAndTimeFormatter){ _dateAndTimeFormatter = [[NSDateFormatter alloc]init]; [_dateAndTimeFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS ZZZZZ"]; _dateAndTimeFormatter.dateStyle = NSDateFormatterShortStyle; _dateAndTimeFormatter.timeStyle = NSDateFormatterShortStyle; } return _dateAndTimeFormatter; } alternatively [_dateAndTimeFormatter setDateFormat:@"yyyy-MM-dd...

Adding Image And title both to UIsegmentControl IOS

ios,uiimage,title,uisegmentedcontrol
Is there a way so that you can set both image and title of UISegmentControl simultaneously, so that image appear next to the title , just like image appear next to title in UIButton. I am trying but if I set image of Selected segment of UISegmentControl then title disappears...

Unexpectedly found nil while unwrapping an Optional value - Plist

ios,swift,plist
i am trying to read from propriety list using swift but im getting this error, and thats the code im using to read from my plist : Arrays i'm using : var recipeNames :[String] = [] var recipeImages :[String] = [] var recipeTime :[String] = [] In viewDidload : var...

Set color CFAttributedStringRef

ios,objective-c
I have this methods for draw a table ant populated . What i want is to change the color for one word from each column , but i dont know how can i do it . Can somebeday help me ,please ? Any help will be appreciate . in my...

Is There A Neat Way to Attach a Completion Block to an NSURLSessionDataDelegate Callback in Swift?

ios,swift,nsurlsession,completion-block
OK, here's the deal: I have a URL call I'm making in a Swift app, sort of like so: /*! @brief Tests a given Root Server URL for validity @discussion What we do here, is append "/client_interface/serverInfo.xml" to the given URI, and test that for validity. @param inURIAsAString This contains...

Is this Swift syntax efficient?

ios,swift,syntax
Would this for loop fire each time the getter is accessed ? Or does Swift cache it 'behind the scenes' ? var colors: [UIColor] { get { var colors = [UIColor]() let palette = [UIColor.redColor(), UIColor.greenColor(), UIColor.blueColor(), UIColor.orangeColor(), UIColor.purpleColor(), UIColor.yellowColor()] var paletteIndex = 0 for _ in 0..<photos.count { colors.append(palette[paletteIndex])...

iOS 9 not opening Instagram app with URL SCHEME

ios,swift,swift2,ios9
The following URL opens on iOS 8.3 and lower, but it does not work and iOS 9 let instagramURL = NSURL(string: "instagram://app") Why won't the URL open?...

animating a view on top of uitableview

ios,swift,autolayout
I have a UINavigationController that has my custom ViewController with a tableView in it that takes up the whole screen. I want to push down the tableView and reveal a settings menu with just a couple items. My SettingsView.xib I created in a separate nib that is 320 x 90...

Multiple NSURLSessions Causing UITableView Problems

ios,objective-c,uitableview,nsurlsession
I'm running into a bit of a strange problem here. One of my NSURLSessions is in charge of getting information for restaurant information that I have stored (restaurant name, restaurant's logo URL, etc), and then the second NSURLSession is in charge of using the restaurant's logo URL to retrieve the...

Twilio Client Python not Working in IOS Browser

javascript,python,ios,flask,twilio
I have created a simple twilio client application to make phone calls from Web Browser to phones. I used a sample Flask app to generate a secure Capability Token and used twilio.min.js library to handle calls from my HTML. The functionality works fine in Computer Browsers ans Android Phone Browsers,...

Build error after I localized Info.plist

ios,objective-c,xcode,swift,localization
I localized Info.plist : And I got this build error : error: could not read data from '/Users/cherif/Apps/Wesh/Info.plist': The file “Info.plist” couldn’t be opened because there is no such file. Actually there are now two Info.plist files : fr.lproj/Info.plist Base.lproj/Info.plist How to localize the Info.plist path ?...

What is the best practice add video background view?

ios,objective-c,swift,video
I want to add background view with video (or gif) like in app "Uber" I'd like to use video background view for a long time in my app. And I want to know the answers to these questions: What of them will consume less battery energy Can I use it...

How to do a “show (e.g Push)” segue programatically without animation?

ios,objective-c,swift,storyboard,segue
How can I do a "show (e.g Push)" segue programatically without animation? None of the solutions I've found works the same way as the one in storyboard.

Beacon / IOS CLLocationManager get current region

ios,swift,cllocationmanager,ibeacon
I'm doing a program who is looking for beacon, I implemented CLLocationManager and my apps works except one point. I'm calling startMonitoringForRegion() in order to get the didEnterRegion/didExitRegion callback. Inside these function I'm doing startRangingBeaconsInRegion()/stopRangingBeaconsInRegion() in order to get precise information when the user is in the beacon area. My...

Transferring an Xcode project to another computer with all files/frameworks

ios,xcode,frameworks,transfer,projects
I am trying to copy over my Xcode project from one computer to another but it seems to lose frameworks and the locations for the images although i copied those too. PS I am using xcode and coding an app with a friend. Is there a useful source that can...

Swift SpriteKit edgeLoopFromRect Issue

ios,swift,sprite-kit,cgrect,skphysicsbody
The following code recognizes the bottom and top edges of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough force is applied. It is...

Do I have to use both of these methods?

ios,swift,uitableview
When I expand a UITableViewCell on touch, I know I have to update the UITableView. Right now I'm doing: tableView.beginUpdates() tableView.reloadRowsAtIndexPaths(indexPaths, withRowAnimation: UITableViewRowAnimation.Automatic) tableView.endUpdates() Do I need to use both updates methods as well as the reload method? Or is it just one or the other? I'm not completely understanding,...

Google Drive API (GTL) - Create multiple folder paths in order?

ios,objective-c,swift,google-drive-sdk,google-api-objc-client
I'm using the Google APIs Client Library for Objective-C (GTL) to access the Google Drive API. According to it's Introduction to the Google APIs Client Library for Objective-C, Query execution by the service is inherently asynchronous. Which means when you try to create a path like: root/a/b/c, before you can...

Setting delegates (for protocols) only works in prepareForSegue?

ios,objective-c,delegates,protocols
Most of the information I found involving implementing protocols and delegates involves a step where you do this; DestinationViewController *destinationVC = [[destinationViewController alloc] init]; destinationVC.delegate = self; But after hours of frustration because I couldn't get it to work I finally stumbled across another way to allocate the destinationVC in...

It is possible to continuously update the UILabel text as user enter value in UITextField in iOS

ios,objective-c,swift,uitextfield,uilabel
In my application i have one UILabel and UITextField. Initially UILabel text in nil. As soon as user enter some text in UITextField my UILabel text also Update. Let say When user enter A in UITextField my UILabel immediately show A, B in UITextField my UILabel show B and so...

iOS Swift: Sound not playing on iPhone Simulator

ios,iphone,swift,audio,ios-simulator
In my iOS Swift application, and i am trying to play sound on click of a button. func playSound() { var audioPlayer = AVAudioPlayer() let soundURL = NSBundle.mainBundle().URLForResource("doorbell", withExtension: "mp3") audioPlayer = AVAudioPlayer(contentsOfURL: soundURL, error: nil) audioPlayer.play() } I am running the application in iOS iPhone Simulator. I have doorbell.mp3...

Is it possible to obtain an unique iCloud user ID on cocoa?

ios,iphone,cocoa,ipad,icloud
My iOS app is currently on beta in TestFlight, and as a way to retribute to the nice people who helped me test it I would like to offer them some goodies such as, for instance, the full final version of the app for free. For this, I was thinking...

How to prevent _User table from growing unnecessarily when using PFAnonymousUtils iOS SDK?

ios,parse.com
What is the best way to handle the scenario described below? I am giving the user limited access (READONLY) when logged in anonymously. The problem i am facing is that i am afraid is that the _User table would grow unnecessarily with redundant data. Steps: 1. user logged in anonymously...

iPod Touch (5th gen) 'Source type 1 not available' crash when using UIImagePickerControllerSourceTypeCamera

ios,objective-c,ipod-touch
The iPod Touch (5th gen) has both a front and rear camera so why does my app crash when i try to present a UIImagePickerController with sourceType: UIImagePickerControllerSourceTypeCamera - (void)openImagePickerType:(NSString *)type { UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; if([type isEqualToString:kImagePickerCameraString]) imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; if([type isEqualToString:kImagePickerLibraryString]) imagePicker.sourceType =...

NSString to NSDate doesn't work

ios,objective-c,nsdateformatter
now it works with this code: NSString *myDate = @"06/18/2015 8:26:17 AM"; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss a"]; [dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]]; NSDate *date = [dateFormatter dateFromString:myDate]; [dateFormatter setDateFormat:@"dd.MM. HH:mm"]; NSString *dateString = [dateFormatter stringFromDate:date]; cell.timeLabel.text = dateString; ...

How can I convert an Int array into a String? array in Swift

ios,arrays,swift,casting,type-conversion
I have an array that looks like this: var arr: [Int] = [1,2,3,4,5] In order to print this, I would like to convert this to: var newArr: [String?] = ["1","2","3","4","5"] Please help me out! Thanks in advance....

Trying to dismiss a popover view controller with a table view inside of it

ios,objective-c,uipopovercontroller
I'm trying to dismiss a popover when selecting a cell inside of it. I have created a custom delegate to support this however it is not working: In my class that houses the PopOver and table View I have the following: In .h: @protocol DismissDelegate <NSObject> -(void)didTap; @end @interface AssistanceNeededAtPopOverViewController...

Parse: Facebook user unlink and login again creates two user table entries

ios,swift,parse.com
I see that my parse login through Facebook code looks like this. PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) { (user: PFUser?, error: NSError?) -> Void in if let user = user { if user.isNew { println("User signed up and logged in through Facebook!") let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil) graphRequest.startWithCompletionHandler({ (connection, result,...

Implementing Applovin Ads with Swift & SpriteKit

ios,swift,applovin
I would like some help with integrating interstitial ads from Applovin using Swift. Currently, I have managed to successfully integrate the SDK and initialize it using ALSdk.initializeSdk(). I have a folder in my project directory called Applovin which contains: headers folder (with all the .h files inside) and libApplovinSdk.a. I...

drawing views after time intervals

ios,objective-c
I need to draw views after time interval for example creating the first view then wait 5 second and create the other one, I am using this: -(void) drawView { int x=0; x+=16; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(x, 580, 16, 25)]; view.backgroundColor = [UIColor blackColor]; [self.view addSubview:view]; } [self...

Getting video from Asset Catalog using On Demand ressources

ios,xcode,xcode7,ios9,asset-catalog
I attributed to my .mp4 video the "tokyo" tag for example, and set it as installed during the app installation. Now before I was using a Path to get it from my resources, now it's different because it's located on the Asset Catalog. After found documentations, I tried something like...

How can I display the time offset (years, months, weeks, …) from two dates at my labels?

ios,xcode,swift
I am getting Use of unresolved identifier 'self' in my app. After reading this link, I wrapped the code in a class. Note: I am using an extension I got from this answer at S.O. class SetDate { var seconds = date2.secondsFrom(date1) var minutes = date2.minutesFrom(date1) var hours = date2.hoursFrom(date1)...

Slide in an UIButton and push other UIButton when a certain distance is reached

ios,objective-c,uiviewanimation,nslayoutconstraint
I would like to slide in a UIButton (grey color in screenshot) from the left to right and center it on the screen. There is an UIButton (orange color in screenshot) already though that is centered and this button should be pushed to the right and always have a distance...

IOS rightBarButtonItem on UINavigationController in swift

ios,swift,uibarbuttonitem,uinavigationitem
I'm trying to put a rightBarButtonItem on a second view controller of an UINavigationViewController stack. I'm creating and setting the button in viewDidLoad of the view controller that I want to show. My actual code looks like this: override func viewDidLoad() { super.viewDidLoad() menu_button_ = UIBarButtonItem(image: UIImage(named: "menu"), style: UIBarButtonItemStyle.Plain...

How can I show ONLY the date (and not the time) using NSDateFormatter?

ios,iphone,swift
I think the question is pretty straightforward. I need only the date to appear, and not the time. Couldn't find anything for Swift, so my code is here: cell.date.text = NSDateFormatter.localizedStringFromDate(dates[indexPath.row], dateStyle: .ShortStyle, timeStyle: .ShortStyle) ...

Objective-C AVCaptureDevice Front Camera

ios,objective-c,camera,avcapturedevice,avcapture
I have followed a tutorial that guided through a way to make a custom but simple camera app, almost exactly to the needs of the use I would like it. I actually have two issues that I need changing but I will focus on this first one for now. The...

Updating Core Data Model using two separate View Controllers

ios,objective-c,uitableview,core-data
I originally had my app setup to store one line items in a single entity within my core data model. I have since decided to change this to allow the main uitableview to simply list the name of each item and then when you tap on an item you can...

Detect UIImageView Touch in Swift

ios,swift,uiimageview
How would you detect and run an action when a UIImageView is touched? This is the code that I have so far: override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { var touch: UITouch = UITouch() if touch.view == profileImage { println("image touched") } } ...

disable swipe gesture for iCarousel

ios,swipe-gesture,icarousel
I am using iCarousel to display an array of images and I want to disable the swipe gesture. I did not find that in the documentation. not sure if this is doable or not

Best way to save traffic in iOS Parse App

ios,arrays,swift,parse.com,traffic
I have a logic problem in my app using Parse, Regarding which path to choose to save in traffic, and if someone has already faced a similar problem, I will really appreciate the help. Also, you can end up helping other developers facing the same problem I have a social...

How can I fix crash when tap to select row after scrolling the tableview?

ios,xcode,swift,uitableview,tableviewcell
I have a table view like this: when the user tap one row, I want uncheck the last row and check the selected row. So I wrote my code like this: (for example my lastselected = 0) func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var lastIndexPath:NSIndexPath = NSIndexPath(forRow: lastSelected, inSection:...

Extra table cells when UITableViewController is embedded into a Container in a UIViewController

ios,swift,uitableview,uiviewcontroller
In order to customize a table view and add some additional controls to it, I've embedded a UTTableViewController into a Container View and placed that container View into a UIViewController. I've followed the instructions I found here: Embedding TableView in TableViewController into another view TableView is configured with four static...

iOS Keyboard “Done” button load action

ios,swift,cocoa-touch
I'm trying to get "Done" button on to load an action, preferably the action that I have for my button. Here's the UITextField declaration let someTextField = UITextField() Trying to add a target to the textField someTextField.addTarget(self, action: "loginActionButton", forControlEvents: .EditingDidEndOnExit) ...

try to recover views from custom cell

ios,uitableview
I made a custom cell from my storyboard, with an UIImageView and a UILabel. Each of them have a tag 100 for the imageView and 102 for UILabel. I try to get them in my datasource method but as below, they are still nil and I don't know why. ...

Xcode UIWebView not changing page with changed URL

ios,objective-c,xcode,uiwebview
I'm automatically generating a NSURL based on the distance of a pan gesture on the screen (long story...). Anyways, I'm having no problem generating the URL. The URL dynamically changes, and then I have an NSTimer that repeats every second which tells a UIWebView to reload with the new URL....

stringByReplacingOccurrencesOfString giving strange error

ios,swift
For some reason, this is giving me an error. swearWordPair is defined as a [String]. For example ["Hello", "Hi"] let swearWordsAndReplacements : [[String]] = [["anus", "butt"], ["arse", "butt"]] The error this gives me is Cannot invoke 'stringByReplacingOccurrencesOfString' with an argument list of type '(String, withString: String, options: NSStringCompareOptions, range: NSRange)...

Call method after asynchronous request obj-c

ios,objective-c,asynchronous,uiviewcontroller,nsobject
In my app I init a new object, where there is method which calls NSURLConnection's sendAsynchronousRequest method. After the request, I would like to call a method in the caller UIViewController. I tried to use a static method but I then I can't control IBOutlets. How can I do this?...

type casting in objective-c, (NSInteger) VS. integerValue

ios,xcode,casting
I don't very understand about the diference between (NSInteger)aNumberValue and [aNumberValue integerValue], then do some test. For example, here is a response data from server: You can see it's an int but the value is hold by NSNumber. I retrieve the data by writting NSInteger count = (NSInteger) dic[@"count"];, and...

iOS 8 Swift CS193P Calculator Bug Switch Operation

ios,swift
I just started learning Swift with Stanford tutorial. I have Xcode 6.3.2. I'm getting a bug at a switch operation and can't understand how to solve it. I attached a screenshot as well @IBAction func operate(sender: UIButton) { let operation = sender.currentTitle! if userIsInTheMiddleOfTypingANumber{ enter() } switch operation{ case "➕":...

After an insert into the UITableView : custom the cell

ios,objective-c,uitableview
I'm using insertion into my UITableView with this : Skill * newSkill = [[Skill alloc] init]; newSkill.name = @"Nouvelle compétence"; newSkill.pathPicto = @"generic"; [self.skills insertObject:newSkill atIndex:0]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; [self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationTop]; [self.tableView endUpdates]; It works great but now I want that the inserted cell be...

Scaling everything up and down for different devices in UIStoryboard

ios,uistoryboard
Is it possible to have the storyboard scale everything up or down depending on the screen size or do I have to do it programmatically? For example the UI on iPhone 6 plus would look exactly like the one on iPhone 5 but just larger.

Admob interstitial ad delegate

ios,swift,admob,interstitial
I am trying to assign a delegate to admob interstitial ad so i can handle ad events. The GADInterstitialDelegate implementing class: class AdDelegate: NSObject, GADInterstitialDelegate { //Interstitial delegate func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) { println("interstitialDidFailToReceiveAdWithError:\(error.localizedDescription)") } func interstitialDidReceiveAd(ad: GADInterstitial!) { println("interstitialDidReceiveAd") } func interstitialWillDismissScreen(ad: GADInterstitial!) {...

Set NSObject property - EXC_BAD_ACCESS

ios,objective-c,exc-bad-access,nsobject
Process : App is on the home view controller and is requesting data on API to set an NSObject property. The request is processing on a private method. User change the view controller to a second view controller (the request is still processing asynchronously) The second view controller is loaded...

Split double-digit NSInteger into Two NSIntegers

ios,nsinteger
I am trying to figure out how to take a double-digit NSInteger on iOS (like 11) and turn it into 2 separate NSIntegers, each looking like "1". It will always be just 2 digits in the NSInteger, no more, no less, and no decimals.

Call function on Server from iOS app - Objective C

ios,objective-c,json,server,backend
If you are familiar with Parse.com's Javascript SDK, this is what I am trying to do for my own server for my iOS app (Objective-c). I want to be able to send some a string to the function that is on my server, have the server run its function and...

How to disable the Copy/Hide feature in UIImagePickerController when long pressing a image …?

ios,swift,ios8,uiimagepickercontroller,ios8.3
- Actually am using UIImagePickerController for my usecase,and if i long press any picture ,it shows Copy/Hide option (as shown in the sample image) - I dont want the Copy/Hide feature. Guide me with some suggestions if u too have encountered :)... Thanks in advance...iOS Geeks...PLZ refer my code snippet...

iOS: Go back to entry point view controller which is not part of navigation controller

ios,uinavigationcontroller,swrevealviewcontroller
I have a login view controller which is outside my navigation controller. When a user logs out, I want them to be back to the login view controller. I am using SWRevealViewController and Storyboards. User Flow: -> Login View Controller -> SWRevealViewController-> UINavigationController...

starting to work with iOS push notifications

ios,objective-c,push-notification
i started following this tutorial i found via google. http://code.tutsplus.com/tutorials/setting-up-push-notifications-on-ios--cms-21925 However i got stuck on basically the first step where it said that the methods are deprecated, i changed them to the ones suggested by Xcode the original code was [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; i changed it to...

Why doesn't a UITableView scroll until I have 2 additional rows?

ios,uitableview
Scenario: Embedded UITableView in a standard UIViewController's view. Three (3) 80-pt rows fill the UITableView. Problem: UITableView doesn't scroll until the number of rows > 5. I've tested this by varying the number of displayed rows and attempted to scroll. Three (3) rows fills the UITableView. Four (4) fills but...

UITapGestureRecognizer sender is the gesture, not the ui object

ios,xcode,swift,uigesturerecognizer
I've got a button called and I gave it a UIGestureRecognizer so that an IBAction is only run when the button is long pressed. You do this by adding a UILongPressGestureRecognizer to the button iteself. Then you control drag that gesture recognizer to a function like this: @IBAction func handleGesture(sender:...

IOS draggable objects not saving position

ios,position,uigesturerecognizer
I currently have a view which contains a number of buttons and a single text field. The users can drag the buttons around, and when finished, interact with the text field. Dragging the buttons using UIPanGestureRecognizer seems to work, however once a user interacts with the text field, all of...

How do I use my class in AppDelegate.swift

ios,swift,appdelegate
I have a ‘Member' class inside the project and I'm trying to pass some data from Phone to Watch extension. The error says: Use of unresolved identifier ‘Member' I tried to create a module ‘MemberKit’ and import it but I still get this eror. Thanks in advance! func application(application: UIApplication,...

Using sockets to build real time chat for iOS?

ios,objective-c,sockets,chat,real-time
If I wanted to build a real time chat app for iOS using Objective-C, what would be the best way of going about it?

How can I make both of these UICollectionViews appear in the same View?

ios,swift,uicollectionview
I have two UICollectionViews that I need in one View. They have two different CollectionViewCell classes. The first CollectionView cell class is ConfirmOffersCollectionViewCell and the second is ConfirmRequestsCollectionViewCell. I am able to have both CollectionViews appear and function if I set both cells to the same class, but they display...

Characters and Strings in Swift

ios,string,swift,unicode,character
Reading the documentation and this answer, I see that I can initialize a Unicode character in either of the following ways: let narrowNonBreakingSpace: Character = "\u{202f}" let narrowNonBreakingSpace = "\u{202f}" As I understand, the second one would actually be a String. And unlike Java, both of them use double quotes...

Difference between stringByAppendingString and appendString in ios

ios,objective-c,swift,nsstring,nsmutablestring
What is the difference between stringByAppendingString and appendString? If NSString is not mutable then how could it append string?

Using Core Data with watchOS 2.0

ios,watchkit,watch-os-2,watch-os
I made an iOS/Apple Watch app with WatchKit 1.0 that uses a shared group container and a custom framework to access the same Core Data store. Now, in the transition guide for watchOS 2.0, Apple says this: If your existing Watch app and iOS app use a shared group container...

strange behaviour with UINavigationController and autolayout top layout guide

ios,layout,uiscrollview,uinavigationcontroller,autolayout
I am using auto layout for a controller under navigation controller. For this controller, I mainly have a scroll view inside the controller's view. the alignment rule for the scroll view is top layout guide, bottom layout guide, leading aligned with super view and trailing as well. the layout is...

Is possible to save Realm documentation for offline reading?

android,ios,documentation,realm
I'm going to vacations this Saturday and I need to have Realm API documentation available for offline reading (https://realm.io/docs/swift/latest/api/index.html). Does it exist somewhere for download? Thanks

Turn a switch Off or On on the basis of another switch state

ios,xcode,uiswitch
How can I turn a switch off inside a different switch? Here's an example - When the isMale switch is turned on, turn off the isFemale switch. - (IBAction)isMale:(id)sender { if ([sender isOn]) { //TURN isFemale SWITCH OFF } else { ... } } and - (IBAction)isFemale:(id)sender { if ([sender...

How to create UITableViewCells with complex content in order to keep scrolling fluent

ios,swift,uitableview,cocoa-touch,ios-charts
I am working on a project where I have a table view which contains a number of cells with pretty complex content. It will be between usually not more than two, but in exceptions up to - lets say - 30 of them. Each of these complex cells contain a...

iOS search api for Maps

ios,mapkit,core-location
Is there a search api for apple maps? Like in apple maps, if you start typing an address, it filters the list with some possibilities. Is this available to developers? I saw that they added some MKLocalSearch in iOS 7, but i could not find anything that gives that capability....

Why using ? in this case is not working? (swift)

ios,swift
My purpose is to assign the color of UIView from an existing image: self.myView.backgroundColor = UIColor(patternImage: UIImage(named: "04_white_back_page2")?) As I understand, I don’t know whether this UIImage(named: "04_white_back_page2") contains nil or a value, so: if it has value use it, and otherwise just consider the whole expression nil, and do...

pushviewcontroller doesn't work?

ios,objective-c,pushviewcontroller
There is a button at the viewcontroller and when i click the button pushviewcontroller doesn't work. my appdelegate.m file : - (BOOL)applicationUIApplication *)application **didFinishLaunchingWithOptionsNSDictionary** *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:EK_SCREEN_BOUNDS]; ExampleViewController *exampleViewController = [ExampleViewController new]; self.window.rootViewController = exampleViewController; [self.window makeKeyAndVisible]; return YES; } Button click method (in ExampleViewController): mainViewController...

Underline in attributed text not working in iPhone 6+

ios,iphone,nsattributedstring
I want to create a method that returns me attributed text. here is the code that i am using - (NSAttributedString *)getUnderlineAttributedStringForText:(NSString *)strWholeString andTextToHaveLink:(NSString *)strLink TextColor:(UIColor *)textColor LinkColor:(UIColor *)linkColor withFont:(UIFont*)font { NSRange stringRange = NSMakeRange(0, strWholeString.length); NSRange linkRange = [strWholeString rangeOfString:strLink]; NSLog(@"String Link :: %@",[strWholeString substringWithRange:linkRange]); NSMutableAttributedString *attributedString =...

UIWebView path depends on previous pressed button Xcode

ios,objective-c,iphone,xcode,uiviewcontroller
I have a ViewController (A), containing n buttons. all buttons map to other ViewController(B) containing a WebView to show a different PDF. Instead of creating n ViewController, I would know how to change path according to which button was pressed. my wrong tries: 1- use tags of buttons in ClassB...