How to develop a Qlik Sense Extension that works in Mashups with multiple apps - qliksense

My Extension doesn't work in Mashups that load objects from multiple apps.
It seems to work, when my extension is from the app that is loaded first by Qlik Sense. But if my Extension is in two different Apps, one of those works and the other doesn't.

TL;DR
Don’t use:
qlik.currApp()
Do use
qlik.currApp(this)
to make your Extension support being used in Mashups with multiple apps.
Detailed Explaination
If you need to call functions on the app behind the extension object, then you probably use qlik.currApp();
qlik.currApp() gives you the current App that is loaded. That is fine if only one app is loaded into an mashup. But if there are multiple apps, qlik.currApp() just gives you the first app, that it loaded.
According to the Qlik Sense Documentation on the currApp method:
qlik.currApp(reference)
Gets a reference to the current app. Use the currApp method in an
extension to get a reference to the app currently displayed.
Image you have two apps: A and B. A is loaded first. Then you include also an object from App B into the Mashup. But the type of object is an Extension and that extension uses qlik.currApp(), it is likely, that this object won’t work properly. That extension will call functions on app A even though it is from app B.
You can tell Qlik which app you want to reference. For that you need the reference to the extension instance. You get it as the this reference inside your paint method in the Extension Code:
paint: function(§element, layout){
var app = qlik.currApp(this);
// [...]
}
In case you have another closure inside the paint function, you need to save the this reference. If not, the this reference gets overwritten by the inner function object. A common case is to save the this reference to that:
paint: function(§element, layout){
var that = this;
loader.load(assets, function(){
var app = qlik.currApp(that);
// [...]
});
}

Related

Execute external swift code inside a macOS app

I have an external swift 5 file (just function code no UI) that will be fetched daily from a server. I want to embed the code in my running MacOS app so that the code in the external swift file will be executed when the user presses a button. I´m not sure if this is even possible.
The Idea is something like this:
External swift script:
import SwiftUI
func sayHello() {
print("Hi")
}
func newCode() {
// some fancy code
}
The script contains one or two functions (always the same name) that should be called from the buttons (just for simplicity).
The code inside the functions will be always completely different e.g.: some processing of data or changing settings in my app via the app api.
It would be great if there might be a swift solution, other ways I must use a shell script that is executed with Pipe() but I´m not that good in shell programming so I want to avoid it.
The Apple Shortcut app allows user to "program" their code by drag n drop, so maybe this is way to do so, but I don't no how their logic behind this works and if this is similar to my problem.

watchOS does not enter ComplicationController

I want to develop a simple complication as my first watchOS project.
I've set everything up as the screenshot shows:
But When I set a breakpoint inside ComplicationController.swift, it will not be called. Therefore, my complication does not fill with any data I supply. I set a breakpoint to all implemented methods (e.g. getLocalizableSampleTemplate) in that class, but the code is just running and the complication does not fill with the supplied data.
What am I doing wrong?
My class conforms to CLKComplicationDataSource (I left all the default implementation).
It works if I add $(PRODUCT_MODULE_NAME). in front of the data source class inside the complication configuration.

Swift 1.2 drag and drop controls and views in Cocoa

I'm building one application where I need to make a simple window and be able to drag&drop files onto this window. In this app I have to then parse file path and write out all paths of dropped files in table or nice order (one under another). App doesn't need to take more than one file at once, but this might be a feature for future.
Up to now I have managed to make simple drag&drop in NSView (which I extended with custom class). App is correctly registering drag&drop events and I get all file path and I have also figured how to get file names out of those strings.
My question is: How can I move this "drag&drop" to NSTableView, as I wish to have file names in nicely in table?
I have tried to put tableview under NSView but it doesn't work and if I extend NSTableView class it just registers that there was drag&drop event but nothing else happens.
Do I have to extend other class or how to make this work? I'm implementing NSDraggingDestination protocol in custom class and using performDragOperation function.
I would like to have:
- whole app window can take drag&drop-ed files, not matter where I drop it it has to accept file and put file name into table
I'm sorry if this might sound trivial but I have just started learning swift and developing OS X apps and I'm not used to this new API and don't really know how all things works here.

How to check if a word is defined in the English dictionary in cocoa-touch?

I am trying to make a crossword app for IOS but i Don't know that how to check if a string is valid english word or not.
How can i check it.
Is there any API or online facility to check it.
Thanks in Advance
Easy to do in iOS5 using the UIReferenceLibraryViewController class' +dictionaryHasDefinitionForTerm: method.
A UIReferenceLibraryViewController object provides a dictionary
service to look up the definition of terms. You create and initialize
a reference library view controller using the initWithTerm: method.
You pass the term to define as the parameter to this method and the
definition is displayed. You can present this view controller modally
or as part of another interface. On iPad, you can set the reference
library view controller as the content view controller of a
UIPopoverController object. Optionally, use the
dictionaryHasDefinitionForTerm: class method to check if a definition
is available for a given term before creating an instance—for example,
use this method if you want to change the user interface depending on
whether a definition is available.
There is no API for this.
In order to do this, you will need to have a dictionary file (text file or database) in your application bundle. One of the faster ways to check will be to load the dictionary into memory when the application launches so you don't have to read the file for each word. This may be overkill if you simply want hardcoded crosswords, but if you are randomly generating them then this is a must.

Why we use app delegate in our application

I am new in iphone development and i needed a array which i use to access in different class so my senior told me that you should declare in App delegate and access it another class in which it require, so i wrote line for that
MyAppAppDelegate * appObject =
(MyAppAppDelegate*)[[UIApplication sharedApplication]delegate];
I done my task successfully but i couldn't get it 100%. Someone tell that why we use this and in what exactly situation in which we've to use this?
AppDelegate is loaded first when you run your application as it contains window. So, the variable and objects you want to access throughout your project is declared in AppDelegate. You just have to create an instance and you can access all the objects in AppDelegate.
ApplicationDelegate can be useful as a singleton class but you have to use it with discretion - and there are varying opinions on this - but if you have a few global type properties or methods you want to recall from various other classes, and I emphasize few, then ApplicationDelegate may be a nice place to add these.
And yes, it is bad design - but you can get away with it if you are prudent and as #Sedate Alien mentions, take a look at dependency injection.
The purpose of ApplicationDelegate, by the way, is mainly to handle events like loading your application, when you return to home screen, when you come back from home screen, etc.