Posts

Showing posts with the label core

Strings are objects in Java, so why don't we use 'new' to create them?

Image
Clash Royale CLAN TAG #URR8PPP Strings are objects in Java, so why don't we use 'new' to create them? We normally create objects using the new keyword, like: new Object obj = new Object(); Strings are objects, yet we do not use new to create them: new String str = "Hello World"; Why is this? Can I make a String with new ? new You should also have a look on this question stackoverflow.com/questions/456575/java-wrapper-equality-test – changed Jan 5 '10 at 21:56 Because string literals are already objects. – EJP Feb 7 '16 at 9:33 Note that new String(...) has been used to circumvent an implementation detail when substringing large string...

Custom Model Binder Provider always null .net core

Image
Clash Royale CLAN TAG #URR8PPP Custom Model Binder Provider always null .net core I'm having a problem trying to get custom model binders to work as a query parameter like I have gotten to work previously in .net framework 4.7. To ensure this wasn't a scenario where my object was too complex, I reduced the model to a simple string but even then I cannot get this to work. I have a simple model I would like to be binded from query parameters. public class SearchModel { public string SearchTerms { get; set; } } And I have configured the ModelBinder and ModelBinderProvider as shown here like so. public class TestModelBinder : IModelBinder { public Task BindModelAsync(ModelBindingContext bindingContext) { if (bindingContext.ModelType != typeof(SearchModel)) { throw new ArgumentException($"Invalid binding context supplied {bindingContext.ModelType}"); } var model = (SearchModel)bindingContext.Model ?? new SearchModel(); va...

WatchKit and Core Location Not Requesting User Permission

Image
Clash Royale CLAN TAG #URR8PPP WatchKit and Core Location Not Requesting User Permission I cannot get location services on WatchOS 4 to request user permission. My info.plist with privacy usage description in WatchKit Extension is above. My code is below. When it is run, no authorization is requested and I don't get any location updates. private let locationManager = CLLocationManager() override func willActivate() { super.willActivate() locationManager.allowsBackgroundLocationUpdates = true locationManager.delegate = self self.locationManager.requestWhenInUseAuthorization() } func locationServicesAuthorizationStatus(_ status: CLAuthorizationStatus) { locationManager.requestWhenInUseAuthorization() switch status { case .notDetermined: print("LocationServicesAuthorizationStatus: .notdetermined") self.locationManager.requestWhenInUseAuthorization() locationServicesStateNotDetermined() case .restricted, .denied: ...