Posts

Post not yet marked as solved
2 Replies
723 Views
HiI have an app that I want to submit that just does conversions of units, it does not store anything except user setting. But I am hoping to monetise it with google admob ads. Now that there is some legalese we have to include, what should we add to our privacy policy for admobs, which is presumably sending up some user data?---Mark
Posted
by logistes.
Last updated
.
Post not yet marked as solved
0 Replies
481 Views
HiI frequently want to explore the properties and methods and inheritance of the library code I am using in my app, with the "Jump to definition" item that the Xcode editor's context menu offers. But that item for no apparent reason is not present once I am in the library code. I often end up copying and pasting some class back to my app just to get "Jump to definition".Is there some setting that will enable this? Or is it a bug? I think it used to work. I have Xcode 10.1
Posted
by logistes.
Last updated
.
Post not yet marked as solved
3 Replies
842 Views
HiI just debugged a memory leak by making some of my protocols "class" and making the variables of that type weak.But what would i have been able to do if the project had a mix of structs and classes that implemented those protocols and I was not able to mark the protocol weak, but had to have a potential retain-cycle with a class?
Posted
by logistes.
Last updated
.
Post not yet marked as solved
6 Replies
1.5k Views
Hi,I want to write some reuable code that implements a protocol. It all went fine when it was added in an extension to ViewController, my own subclass of UIViewController, but when I changed the extension to UIViewController, I get the error message: Instance method 'adViewDidReceiveAd' nearly matches optional requirement 'adViewDidReceiveAd' of protocol 'GADBannerViewDelegate'against both the methods implemented (with the correct function name), and the code stops getting run.There was something like this back in XCode 8 (https://stackoverflow.com/questions/39495773/xcode-8-warning-instance-method-nearly-matches-optional-requirement )but they were saying it had been fixed. I am using version 10.0 (10A255).Here is the code that gives that error message:extension UIViewController: GADBannerViewDelegate { // From GADBannerViewDelegate (fully optional protocol) @objc func adViewDidReceiveAd(_ bannerView: GADBannerView) { bannerView.isHidden = false } @objc func adView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: GADRequestError) { bannerView.isHidden = true print("AdMob error:", error.localizedDescription) } Simply changing UIViewController to ViewController makes it work.I can't think of any reason that this shouldn't work as is. Can anyone give some certainty on what is up here?It may be relevant that the protocol used here is defined in Objective-C, and the methods are optional. I have added @objc as an attempt to get it to work, but that made no difference.TIAMark
Posted
by logistes.
Last updated
.
Post not yet marked as solved
1 Replies
1.8k Views
HiI was wondering how to handle the odd case of overflow. Swift is pretty keen to catch setting an Int to -Int.min, which is instant overflow. So I tricked the compiler by doing this: var m = Int.min + 10 for _ in 1 ... 10 { m -= 1 } do { let n = -m print("Minus min =", n) } catch { print("Trying to do -Int.min", error) }I first did it without the do catch, and it just crashed the app. But there is no Error that gets caught by the do ... catch syntax.Short of testing if m != Int.min every time you use the negative operator, is there a way to catch these gracefully?
Posted
by logistes.
Last updated
.
Post not yet marked as solved
3 Replies
597 Views
I have been making my app more accessible by using Text Style: Headline and Dynamic Type in all the UILabels and UITextFields. In one part of hte app I want to highlight a label and text field by giving the font a colour as well, which I did in IB. But when the app is running as soon as any new text is entered, the color of the font reverts to black.Why is this and how do I get what I am trying to do?
Posted
by logistes.
Last updated
.
Post marked as solved
6 Replies
5.1k Views
HiI have an app that doesn't work in landscape mode, but I would like it to work upside down. So in the project's General settings, Deployment Info, for Device orientation, I have Portrait and Upside Down checked, and Landscape Left and Landscape Right unchecked.But when I run it and turn the phone upside down, the app stays fixed to the phone, and doesn't show right side up.Is there something else I need to set?
Posted
by logistes.
Last updated
.
Post not yet marked as solved
6 Replies
3.5k Views
I have started applying dynamic type and preferred fonts to my app. The only part of the view controller that doesn't conform is a pair of segmented controls that stay stubbornly small when the labels etc are all expanding with the larger text slider in settings. How can I make the segmented control match the rest of the app?
Posted
by logistes.
Last updated
.
Post not yet marked as solved
1 Replies
3.6k Views
HiI have this code: let primayCurr = "https://api.independentreserve.com/Public/GetValidPrimaryCurrencyCodes" guard let url = URL(string: primayCurr) else { print("Invalid URL: \(primayCurr)"); return nil let task = URLSession.shared.dataTask(with: url) { data, response, error in guard error == nil else { print(error!) return } guard let data = data else { print("Data is empty") return } let json = try! JSONSerialization.jsonObject(with: data, options: []) print("JSON: ", json) } task.resume()The message area gets this:2017-11-21 22:41:58.919318+1000 AltcoinTrader[36412:12415444] dnssd_clientstub ConnectToServer: connect()-> No of tries: 12017-11-21 22:41:59.921886+1000 AltcoinTrader[36412:12415444] dnssd_clientstub ConnectToServer: connect()-> No of tries: 22017-11-21 22:42:00.922257+1000 AltcoinTrader[36412:12415444] dnssd_clientstub ConnectToServer: connect()-> No of tries: 32017-11-21 22:42:01.927400+1000 AltcoinTrader[36412:12415444] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:11 Err:-1 Errno:1 Operation not permitted2017-11-21 22:42:01.927796+1000 AltcoinTrader[36412:12415444] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)2017-11-21 22:42:01.928105+1000 AltcoinTrader[36412:12415444] TIC TCP Conn Failed [1:0x608000162580]: 10:-72000 Err(-65563)2017-11-21 22:42:01.929003+1000 AltcoinTrader[36412:12415423] Task <209F1681-53BB-4E9D-A553-E349AE087159>.<1> HTTP load failed (error code: -1003 [10:-72000])2017-11-21 22:42:01.929234+1000 AltcoinTrader[36412:12415423] Task <209F1681-53BB-4E9D-A553-E349AE087159>.<1> finished with error - code: -1003Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={NSUnderlyingError=0x604000046720 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, NSErrorFailingURLStringKey=https://api.independentreserve.com/Public/GetValidPrimaryCurrencyCodes/, NSErrorFailingURLKey=https://api.independentreserve.com/Public/GetValidPrimaryCurrencyCodes/, _kCFStreamErrorDomainKey=10, _kCFStreamErrorCodeKey=-72000, NSLocalizedDescription=A server with the specified hostname could not be found.}Not sure if the -1003 code is the more relevant one. I was getting that when trying String(contentsOf: url)I know the URL is a real one because I can paste it into a browser and get the right JSON string back. What am I doing wrong here? I am doing a mac app in Xcode 9.1 on an up-to-date macOS.RegardsMark
Posted
by logistes.
Last updated
.
Post not yet marked as solved
2 Replies
3.4k Views
HiI'm running Xcode 9.0 and testing a tricky bit of code around the keyboard appearing. I have put my own message in the code to help me debug it, but it is getting messay with all the extraneous and unhelpful messages of this sort"Can't find keyplane that supports type 8 for keyboard iPhone-PortraitChoco-DecimalPad ..."Is there a way to stop them?
Posted
by logistes.
Last updated
.
Post not yet marked as solved
0 Replies
568 Views
https://i.stack.imgur.com/vQHY1.pngI'm doing an online tutorial in Swift and iOS, and one exercise is to incorporate google ads in a trivial application. To do this I had to download and add the GoogleMobileAds framework, and since GoogleMobileAds is in Obj-C I needed a bridging header.But the bridging header can't see it.This is with Xcode 9, beta 6 (9M214v).But it all works nicely in the tutorial which was made a year or so ago.Any ideas?
Posted
by logistes.
Last updated
.