I was very excited to view the video on WWDC2015 Session 405 Authoring Rich Playgrounds , in that they seem to promise to reuse a piece of code in Sources, among different Pages.
However, it seems not happen automatically. I mean, a new page cannot aceess a func which is defined in a Source swift file.
What should I do to access func defined in a source file?
Thanks
You need to make the function or class public.
Related
I have started to learn C#, so I have started to use VS Code as my editor and have also installed dotnet framework with it.
The problem is that when I create a new file, my file has a completely different code setup/layout/template, unlike the one that I had seen in a video, and I was wondering if I could change that default template, to the one in the video, so that it automatically loads in when I create a new C# file.
I tried to search through the VS settings and preferences, googling it, but can't seem to find this specific answer.
Currently when I create a new file I get such looking code:
look of the code that I get when I create the file
but I am looking to find this type of code, so that I can follow up with the tutorial that I am following:
look of code that I want to get when I create the file
You can set template by following below steps
I would like to create a SDK to use without iOS or Xcode.
Let me explain. I would like to use Swift language to create a framework with which to develop front-end. In few words with this framework I would like create html pages for web and substitute HTML, CSS and javascript with swift. The idea get from what Apple does with iOS. If you look how is made a xib or storyboard you can see xml file. I would like to do the same thing or take the idea and applicate for the web.
To do this I need to create an SDK that is not connected to iOS but that I can use in any IDE like VSCode or similar or also in a my own IDE created by me.
An other thing that could help you to understand what I mean is Javascript. In javascript there is a command createElement that let you to create an element, adding class, attribute and, yes, style. But create UI in this way, you understand well that is very hard. So, I Would like create a framework in iOS style, to create frontend in simpler and easier way.
I would like create create this framework (if it's possible) in Xcode and I don't want have any interference by iOS.
So, have you any suggests about how to start?
thank you
XIB layout is constraint-based, which means you describe your view hierarchy and constraints, and autolayout system does the layout for you every time according to constraints you've provided. Technically, inside it converts constraints to a system of linear equations and solves it in run-time, thus calculating frames for every UIView. And .xib file is just an XML with all the views, their properties and constraints. (that's a bit simplified, but you've got the idea)
HTML layout is totally different: HTML is a declarative way to describe elements on a page, i.e you describe every element with tags, and every tag (or its parent, or CSS file) already contains all necessary information about its positioning and appearance, so browser just parses and renders a page accordingly.
Theoretically, you could've reinvented a web browser: write your HTML parser, then write UI to somehow render it, and add feature to alter HTML tags by moving the page elements with mouse. But that would've taken a lot of time and effort :)
There are many website constructors on WWW, which allow you to build simple sites only with drag-and-drop (no coding needed). Also, you can inspect element in your browser, and then change some attributes of some element right in the debug window, and see changes in realtime.
P.S Im not a web/frontend developer, but I suppose that IDE's popular among frontenders already have some features or plugins that allow them to render HTML/CSS code and see changes in realtime, just like browser's debug menu.
I am currently making an extension, and I hope I could get some
practical advice on feasibility :
I want my extension to go fetch/load a local folder of custom homescreen
thumbnails(top-sites), and then replace the auto-generated thumbnails in
the homescreen with those it loaded.
The extension would be able to read the associated domain names of the
thumbnails and then replace them accordingly.
(e.g :Pinned Url : youtube.com/anything : Ok so it’s YouTube : then replace the thumbnail with “Custom_Youtube_Thumbnail.png”)
Does that seems possible to you ? (Before I dive in head first)
I saw that the top-sites API is not quite available
https://bugzilla.mozilla.org/show_bug.cgi?id=1246693 but maybe I’m wrong.
Extra : My extension is switching themes (like this :
https://github.com/mdn/webextensions-examples/tree/master/theme-switcher ).
Would it be possible to switch the thumbnails accordingly
(Custom_Youtube_Thumbnail_light.png > Custom_Youtube_Thumbnail_dark.png)
as i’ve made a version for each.
Would be a pleasure to hear your opinion on this, or just pointing
useful resources to me,
I’m not asking for a perfectly baked solution.
Hope I’ve been concise.
Thanks for reading me !
Very nice idea you had.
But In short: no possible.
Main problem is that you cannot inject and manipulate on the homepage which is a built in browser tab.
"You cannot inject code into any of the browser's built-in pages, such as: about:debugging, about:addons, or the page that opens when you open a new empty tab."
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript
I'm trying to create a webview with the capability to block/redirect certain urls requested inside the webview (not just the page url, but also the requests sent from the page, think of it as what a browser extension is able to do).
After some research, the closest I get was this Swift/Obj-c approach of use NSUrlProtocol: https://www.raywenderlich.com/2292-using-nsurlprotocol-with-swift, and the doc of the native-webview-ext mentioned something about WKURLSchemeHandler https://github.com/Notalib/nativescript-webview-ext .
I'm new to mobile development and this feature is crucial for my project. I wonder if anyone has experience building this out in NativeScript, I hope I don't have to convince my team and my boss to write this in Swift instead :(.
As you see in the webview-ext plugin docs, it does support overriding resource urls. Refer the registerLocalResource method.
Just in case, even if that is not supported you don't have to write your whole project in Swift as you can always access all native apis from JavaScript / TypeScript itself, read more about it here.
I want to import a document from another app into my app like it's done in MS Outlook iOS app when you click the paperclip in an email. Then you get a list of apps (dropbox, google drive etc) + recent documents and you can select a document.
How is this done / do I need to use the app-extensions for this ?
thanks
Frank van Vliet
this is the scope of App Extensions. To add an App Extension to your Project you have to navigate to File -> New -> Target and the App Extension you are looking for is called Document Provider. Please first check the WWDC Video on best practice for App Extensions and the App Extension Programming Guide. It will help you to develop the understanding of this Feature.
EDIT:
Maybe I set you on the wrong track, but within the App Extension Programming Guide you could have found the answer to your Question. I'm using Xcode 7.0 Beta 4, but most of the following screenshots should look exactly the same in Xcode 6.*. First of all I started a new SingleView-Application written in Swift and added the Document-Provider Extension as a target to the Project as outlined above.
After building the application with the new Document Provider target I ended up starring confused onto the Share-Menu realising that we talked at cross purposes. The Documentation on this target is slightly muddled but after a while of testing and searching I realised that the thing you are looking for is the Document Picker, not the Document Provider. On this Page you can find the Relevant Chapter: Accessing Documents Link, where you can get examples for the Document Picker.
Since this will hopefully solve your Problem, I would like to shortly refer to the Document Provider and the overvalue it could add to your Application.
The Document Provider extension consists of two separate parts: the Document
Picker View Controller extension and the File Provider extension. The Document Picker View Controller extension provides your document provider’s user interface. The system displays this interface when the host app presents a document picker view controller for your document provider. This interface should let users browse through and select documents and destinations from inside your document provider. This extension can also perform basic import and export operations without any additional support.
from the App Extension Programming Guide as mentioned above
So the Document Provider is kind of an Import Feature as seen from another app. If you would implement a Document Provider Target for your Application, other Apps can access designated data. For example you could attach Files from your App to an E-Mail (left screenshot) or Open a File in Pages (right Screenshot).
When working with Files, this could be a nice feature for your users.
Also I would recommend using either a Share or a Action Extension.
Share extensions give users a convenient way to share content with other entities, such as social sharing websites or upload services. For example, in an app that includes a Share button, users can choose a Share extension that represents a social sharing website and then use it to post a comment or other content.
That doesn't sound exactly like the thing you want to achieve, but at the moment even Apple uses the Share Extension for all kinds of things.
An Action extension helps users view or transform content originating in a host app. For example, an Action extension might help users edit an image in a document that they’re viewing in a text editor. Another type of Action extension might let users view a selected item in a different way, such as viewing an image in a different format or reading text in a different language.
You said you want to import a document from another app into your app. This sounds handy. Lets assume a user opens a Document "loremIpsum.txt" in the iCloudDrive Application and wants to share it to your new app.
Now, you have to write the code to handle imported files when opened by the Document Picker, you could reuse this code to easily add a Action Extension to the Share-/Action-Menu. I hope this will help you and solves more than one problem.
Best regards
cr0ss