iOS Swift cannot set AWSSNSSubscribeInput.protocol parameter - amazon-web-services

I am using Swift for iOS app development in Xcode 6.1.1.
I am trying to programatically subscribe the app to a AWS SNS topic. As I know, you need to set:
let subscriptionRequest = AWSSNSSubscribeInput()
subscriptionRequest.protocol = "application"
subscriptionRequest.topicArn = kMyTopicArn
subscriptionRequest.endpoint = endPointARN
But the problem here is the IDE keeps telling me that
subscriptionRequest.protocol = "application"
is not acceptable and it won't even build.
Really have no idea how to solve this. Could anyone help here? THANKS!

This has something to do with the reserved words in Swift. To escape, just simple wrap the word in ``, e.g.
subscriptionRequest.`protocol` = "application"
See this for more: Reserved Words In Swift and How to Escape Them

Related

Google Tag Manager Server Side Custom Client Regex Problem

I am currently trying to develop a custom client template for the Google Tag Manager Server Side and would like to react to a certain URL pattern. Unfortunately, I'm either being silly with the regex or there is somehow a problem with the sandbox JS. I have simplified the example. There is a problem with the backslash at the beginning. Here is the code and the error message. Does anyone have an idea?
const claimRequest = require('claimRequest');
let text = "/abc";
let pattern = /\/ab[c]/;
let result = pattern.test(text);
claimRequest();
And the error message:
1 Error(s) parsing the input:
token recognition error at: '\'
Offending token '' at 4,15.
It appears that as this is a sandboxed limited capabilities javascript environment where RegExp constructor have not been included, hence i am also unable to perform this basic and very common task of splitting templates per country let's say. Quite a big limitation in my opinion.
Here is the full list of supported js in custom templates and RegExp isn't there. Hope they'll add it in the future: https://developers.google.com/tag-platform/tag-manager/templates/standard-library

RLMRealm(path:) Argument labels '(path:)' do not match any available overloads

I just tried to install the latest version of Realm (2.1.0) for Swift 3 and I'm getting an error on this line: let realm = RLMRealm(path: databasePath) - DataManager.swift:258:21: Argument labels '(path:)' do not match any available overloads
The declaration of the argument is here:
var databasePath : String
I know that swift 3 is requiring label for the first argument, but I've looked everywhere for the replacement and can't find an answer.
+ [RLMRealm realmWithPath:] was an API that was deprecated and entirely removed from Realm many months ago. It was replaced with + [RLMRealm realmWithConfiguration:], where you supply an RLMRealmConfiguration object with the file path to the target file set in its fileURL property.
let configuration = RLMRealmConfiguration.defaultConfiguration()
configuration.fileURL = URL(path: databasePath)
let realm = RLMRealm(configuration: configuration)
On a side note, unless you've got a specific reason for using the Objective-C version of Realm in Swift, I highly recommend you use the native Swift version of Realm instead. That one should be a lot easier, and feel a lot more natural in Swift 3. :)

Assign text input value to a variable in Calabash

I'm evaluating Calabash coming from an Appium & Selenium background.
In Selenium i can simply assign the .attribute("value") to a variable and then do what I want with it. I'm looking for something similar in Calabash.
Specifically in an Android app (although I am looking for a cross platform solution) I have an EditText that I can query with :text and I can see the value in the output i.e.
irb(main):008:0> query("EditText",:text)
[
[0] "17512"
]
How can I perform the same function as a step definition in calabash and assign the output (i.e. 17512) to a variable?
Any advice is much appreciated.
This post helped me get what I needed: https://sqa.stackexchange.com/questions/8385/how-to-get-the-text-to-verify-for-edittext-in-calabash-android
Particularly actual_email = query("EditText id:'txt_email'", :text).first

Email ID Validation in C++ in Blackberry 10

I want to validate an email id entered by the use inside a textfield from C++ in Blackberry 10 App.
Can anyone suggest how it can be done ?
thanks in advance.
Use the Validator API added in 10.1: cascades_validator.html">https://developer.blackberry.com/cascades/reference/bb_cascades_validator.html
You would need to supply your own regex to match an email though. There are lots of examples that do that on the Internet. You can start with (and maybe just end with) the information on http://www.regular-expressions.info/email.html

New Route not working on IIS 7.5

I have been developing an MVC application locally (IIS Express) and deploing to IIS 7.5 periodically in order to test.
I have just added a new named Route to my Global.asax.cs file:
routes.MapRoute(
"MyCustomRoute", // Route name
"{documentID}/{year}", // URL with parameters
new { controller = "Documents", action = "CurrentVersion", year = DateTime.Now.Year }, // Parameter defaults
new { documentID = #".*\d+.*" } // Regex matches only where documentID contains numerical values.
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Documents", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
I have set up a Html.RouteLink using "MyCustomRoute" and all works well on my local machine.
However, when I run this on the Web Server, Html.RouteLink is generating an empty link. In addition, if i enter the URL directly into the browser, it gives a 404.
It seems as if the Route has not registered. What am I missing?
It's impossible for us to debug your route without seeing the code, and if you use the right tools, it will be very easy for you to see what's going on and what is being matched.
Phil Haack built an excellent open source tool called RouteDebugger. You can get it through NuGet and read about how to use it at http://haacked.com/archive/2011/04/12/routedebugger-2.aspx . A more robust version of this project is available as RouteMagic and is at Codeplex and git. Details at this blog post
UPDATE
Based on your regex, you're documentID is not being matched due to greediness. .* will match everything, so you it will never have the opportunity to match \d+, because the preceding pattern will cannibalize all matches. You can read about regex greediness and laziness at http://www.regular-expressions.info/repeat.html .
UPDATE 2
Regexes are probably the thing I'm worst at programming, and the only reason I recognized that issue is because I am so bad at them that I've run into the same issue about a million times. That being said, I think #"(.*?)(\d+?)(.*?)" will do the trick. It should work without any of the parentheses as well (like #".*?\d+?.*?"), but I like to keep them in there for readability (mostly because I'm so bad at them).