delegate

Swift UITableView delegate and dataSource declaration and retain cycles

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: As far as I understood, to use the delegate pattern in swift I had to declare a property like so: weak var delegate : TheDelegateProtocol ! And a protocol like so: @class_protocol protocol TheDelegateProtocol { } To avoid retain cycle and stick with what we are used to do in objective C. Now, if I look at what they have in the UITableView definition, I only see: var dataSource : UITableViewDataSource ! var delegate : UITableViewDelegate ! And: protocol UITableViewDelegate : NSObjectProtocol , UIScrollViewDelegate { [...] } I guess

Login flow failing after upgrading to iOS9

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: After upgrading my app to iOS9 I’am getting an error in my app which says: : objc[344]: Cannot form weak reference to instance (0x15919e00) of class LoginVC. It is possible that this object was over-released, or is in the process of deallocation. Below is the function in which i get this error: -(void)dismissLogin { self.isLoggingIn = NO; [self stopLoginAnimation]; [self dismissViewControllerAnimated:YES completion:NO]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self.appDelegate setLoginVC:nil]; [self.view

Javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: Failure in SSL library, usually a protocol error

匿名 (未验证) 提交于 2019-12-03 01:32:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to run the following code in android URLConnection l_connection = null; // Create connection uzip=new UnZipData(mContext); l_url = new URL(serverurl); if ("https".equals(l_url.getProtocol())) { System.out.println(">>>>>>>>>>>"); sslcontext = SSLContext.getInstance("TLS"); System.out.println(">>>>>>>>>>>"); sslcontext.init(null, new TrustManager[] { new CustomTrustManager()}, new java.security.SecureRandom()); HttpsURLConnection .setDefaultHostnameVerifier(new CustomHostnameVerifier()); HttpsURLConnection

Protocol Delegate Method is not called in Swift

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Protocol delegate method is not called.. First View controller code class ViewController: UIViewController,customDelegate { var seconviewcontroller : SecondViewController = SecondViewController() @IBOutlet weak var Label: UILabel! override func viewDidLoad() { super.viewDidLoad() seconviewcontroller.delegate = self } func didSelectData(_ result: String) { Label.text = result print("Didselect Data Call") } Second view controller code import UIKit protocol customDelegate: class { func didSelectData(_ result: String) } class

Error: the entity type requires a primary key

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to expand the question asked on this thread Binding listbox to observablecollection by giving it an ability to persistent the data. The structure is mostly the same except I installed Entity Framework Core, created a DbContext class to hold the records. I added a button to save the dataset to SQL Server. I did not encounter the compiling error but when I attempted to save the data in the database I got this run time exception: Message=The entity type 'Fruit' requires a primary key to be defined. The whole exception in

UNUserNotificationCenter did receive response with completion handler is never called iOS10, swift 2.3

匿名 (未验证) 提交于 2019-12-03 01:25:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am scheduling new notifications in iOS10, like this: func scheduleNotification (event : Meeting, todaysBadgeCounter: Int) { if #available(iOS 10.0, *) { let minutesBefore = 10 //interval in seconds from current point in time to notification let interval : NSTimeInterval = NSTimeInterval(secondsFromNowTo(event.startTime.dateByAddingTimeInterval(-minutesBefore * 60))) //only schedule in the future if(interval > 0){ let category = NotificationsController.notificationCategory let center = NotificationsController.notificationCenter center

Delegate must respond to locationManager:didUpdateLocations swift eroor

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hy guys, I'm making an app in swift 3.0 but I ran across a problem pretty soon. I set up necessary functions to ask for permission to use a location but every time I run the app I get the same error... Viewcontroller.h import UIKit import MapKit class ViewController: UIViewController { let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestWhenInUseAuthorization() locationManager

ios:EXC_BAD_ACCESS for Webview delegate

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a situation where I am trying to resolve these Crashlytics issues and I have this crash log Thread : Crashed: com.apple.main-thread 0 libobjc.A.dylib 0x34217f46 objc_msgSend + 5 1 UIKit 0x29a2d5a3 -[UIWebView webView:decidePolicyForNavigationAction:request:frame:decisionListener:] + 182 2 CoreFoundation 0x2630cad4 __invoking___ + 68 3 CoreFoundation 0x26239645 -[NSInvocation invoke] + 300 4 CoreFoundation 0x2623d0c7 -[NSInvocation invokeWithTarget:] + 50 5 WebKitLegacy 0x326d9261 -[_WebSafeForwarder forwardInvocation:] + 224 6

Simple App Delegate method to show an UIAlertController (in Swift)

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In obj-C when another iOS app (mail attachment, web link) was tapped with a file or link associated with my app. I would then catch this on openURL or didFinishLaunchingWithOptions and show a UIAlertView to confirm the user wants to import the data. Now that UIAlertView is depreciated I am trying to do the same thing but not really sure about the best way to do this? I am having trouble showing a simple alert when my App receives data from another app. This code worked fine in Objective-C with a UIAlertView : - (BOOL)application:

Action<T> vs delegate event

匿名 (未验证) 提交于 2019-12-03 01:14:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have seen developers using the below codes quite alternatively. What is the exact difference between these, and which ones go by the standard? Are they same, as Action and Func is a delegate as well: public event Action OnLeave; public void Leave() { OnLeave(new EmployeeEventAgs(this.ID)); } VS public delegate void GoOnLeave(EmployeeEventAgs e); public event GoOnLeave OnLeave; public void Leave() { OnLeave(new EmployeeEventAgs(this.ID)); } 回答1: Fwiw, neither example uses standard .NET conventions. The EventHandler generic should declare