Use of Unresolved Identifier adding second pin MapKit swift - swift

I am trying to add another pin to my map.
It has worked fine with
artworkPin = Artwork(title:"Wind Wand",locationName:"Majestic",discipline:"Statue",
coordinate:windwandcoord)
but now I've tried adding
artworkPin2 = Artwork(title:"Wind Wand2",locationName:" Not Majestic",discipline:"Statue",
coordinate:windwandcoord2)
but this is giving me an error of Use of unresolved identifier 'artworkPin2'
Any thoughts on what might be causing this?

The error means there is no variable named artworkPin2 in the current scope.
So assuming you are creating a new, local variable, you need to use var (or let):
var artworkPin2 = Artwork(title:"Wind Wand2",locationName:" Not Majestic",discipline:"Statue",
coordinate:windwandcoord2)
Or perhaps you need to add a property named artworkPin2 to your class and assign to that property.

Related

Identify the test device for Admob

I use the code below:
let request : GADRequest = GADRequest ()
request.testDevices = ["xxxxxxx",kGADSimulatorID]
But I am getting the below warning:
'testDevices' is deprecated: Use GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers.
Do I use a syntax to remove the warning?
You should use this:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Instead of:
request.testDevices = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Swift Solution
It turns out the AdMob/GoogleAdManager deviceId can be found by computing the MD5 of the advertisingIdentifier. This way you can retrieve and use the test deviceId in code without having to previously have got a device's identifier from the console log.
To avoid the faff of using an ObjC-Swift bridging header (getting MD5 via <CommonCrypto/CommonCrypto.h>), I'd suggest using a Swift wrapper around the CommonCrypto framework, e.g this one:
SwiftCrypto
Using the above framework (which adds an extension property to String for computing the MD5 hash), it is a simple matter of querying against:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers ?? []).contains(ASIdentifierManager.shared().advertisingIdentifier.uuidString.md5)
This is a modification to 10623169's answer.
To get a valid ID, for the current device, that can be set in "testDevices", get the MD5 of this: UIDevice.current.identifierForVendor?.uuidString
The asIdentifier value can be completely invalid if the user hasn't given permission for tracking. But the UIDevice.current.identifierForVendor is a valid UUID for the app, that will persist across launches (but perhaps not if you delete the app and reinstall).
Use the syntax to remove the warning:
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers
You don't have to set this at all. As the AdMob Developer Doc says:
iOS simulators are automatically configured as test devices.
Source: https://developers.google.com/admob/ios/test-ads#enable_test_devices

Using getBounds on geoJSON feature

I've tried map.fitBounds(geojsonFeature.getBounds()); and I get this error:
geojsonFeature.getBounds() is not a function.
Here is the code: http://jsfiddle.net/0aqxktov/
What is going wrong here?
Thanks in advance.
Your variable geojsonFeature is just an object, there is no method named getBounds() there, as you can easily check.
Instead of that, give your geoJSON layer a name...
var feature = L.geoJson(geojsonFeature).addTo(map);
And use that to call getBounds():
map.fitBounds(feature.getBounds());
Here is the updated JSFiddle: http://jsfiddle.net/qofrgm2k/

When does a model get updated after the model data has changed?

There is a method named updateBindings(true?) in openui5. But I'm not sure when I have to invoke it. Sometimes, setting the modified data to a model causes view changes, which indicates the underlying model data actually gets changed. Sometimes it won't work.
The first example demonstrates that the model doesn't get changed without updateBindings(true).
http://jsbin.com/hulavutoha/edit?html,css,output
The second example derives from the first one. But the model gets updated even without updateBindings(true).
http://jsbin.com/lepuladivu/edit?html,css,output
So, what's the difference between the two examples? When do I need to invoke updateBindings(true) on a model so that it will get updated? What's the intent of the parameter true passed to updateBindings()?
If you add a console print in your formatter function
formatter : function(books) {
console.log("go!!!");
return books[0];
}
you can see that in the first example the function is not executed.
This because if you change a leaf property the linked conponent in thew view (using data-binding) receive the change event only if it bind exactly the leaf property.
P.S.
Instead to use getData
var data = oModel.getData();
data.books[0] = "my book";
oModel.setData(data);
you can use getProperty
var data = oModel.getProperty("/");
data.books[0] = "my book";
//oModel.setProperty("/", data);
In this mode the last line is not required

How to use webpack.config in karma.conf without duplication

I would like to require the webpack.config in karma.conf to reduce duplication. Somehow it is not working and some errors are being thrown.
Module not found: Error: a dependency to an entry point is not allowed
ERROR [karma]: Uncaught ReferenceError: webpackJsonp is not defined
the way webpack.config is required in karma.conf
var webpackConfig = require('./webpack.config');
webpackConfig.devtool = 'inline-source-map';
webpackConfig.plugins.push(new RewirePlugin());
The entry and output property of the webpack.config are not needed in karma.conf, that might be messing with the setup. How can I get rid of it?
I have tried: webpackConfig.entry = {}; which didn't succeed.
The problem could also be something else?
Would be very nice if you could point to an existing example or correct my mistake!

AFNetworkActivityLogger's level in SWIFT

I have a project in SWIFT where I use AFNetworking and AFNetworkActivityLogger for debugging. I am having troubles to change the "level" attribute. By default it is set to AFLoggerLevelInfo, but I need it to AFLoggerLevelDebug.
I tried the following in my AppDelegate.swift:
AFNetworkActivityLogger.sharedLogger().level = AFLoggerLevelDebug
which results in "Use of unresolved identifier 'AFLoggerLevelDebug'". Anyone knows how to change the level of AFNetworkActivityLogger?
The AFHTTPRequestLoggerLevel is an enum, so you want:
AFNetworkActivityLogger.sharedLogger().level = AFHTTPRequestLoggerLevel.AFLoggerLevelDebug
or
AFNetworkActivityLogger.sharedLogger().level = .AFLoggerLevelDebug