How do I use an SF Symbol in Swift using its symbol literal instead of its name? - swift

The normal way to use an SF Symbol is to find the image you want in the SF Symbols app, copy its name, and then use this name in the Image(systemName:) constructor. For example, if I'd like to display the share Icon, I could use the following code:
Image(systemName: "square.and.arrow.up")
This will produce the following image in the UI:
This is great, but just like color and image literals, I was hoping that instead of the string square.and.arrow.up I could have something more literal in my code. For example, if I choose "Copy symbol" in SF Symbols and then paste that into Xcode, I get a string which represents a "symbol literal":
If I try using that code, though, I get the following error:
No symbol named '􀈂' found in system symbol set
Is there another way to use this Symbol within Xcode and have it provide me an Image with the corresponding systemName so I can stop using the string square.and.arrow.up in my codebase and instead use the symbol literal?
My current workaround is to add the literal symbol as a comment, but I'd like to avoid duplicating the symbol:
Other things I've tried:
Image(_ name:bundle:): This doesn't show anything.
Text(_ content:): This shows a black square with a question mark.
Using an #imageLiteral: I investigated this a while ago but couldn't find a way to do this.

Image literals don't work in Xcode these days, and haven't worked for a long time. You have to refer to the string "square.and.arrow.up" in order to specify this image; there is no other way. You can give the string a synonym; you can use the storyboard to fetch the image into an image view so that you don't have to do it in code; but there is no other "magic" way such as you are envisioning.

Related

Ag-Grid Not Supporting Special Symbol

I tried using Ag-Grid, and faced a challenge to plot the data for Special Symbol, It actually doesn't support the special symbol and doesn't plot it!!
Refer To Example1.png, here the No. Column Doesn't contain data,
but when I remove the dot operator from my script.js file from headerName,
and rowData, it starts plotting it. (Refer To Example2.png)
Also attached a zip file (Google Drive Link) as a prototype of this problem for your reference!
https://drive.google.com/open?id=1UqyrRtAhg8-HBwqVqUT_CGMhwyr_cOUt
Kushagra
You probably just need to set the suppressFieldDotNotation grid option to true:
suppressFieldDotNotation
If true, then dots (eg address.firstline) in field names are not treated as deep references. Allows you to use dots in your field name
if you prefer.
(You didn't show any code and I'm not looking in a .zip.)
Alternatively, you can have dots in your headerName, they just can't be in your field name.

VSCode Extension - Rename Symbols

I have seen this link:
VsCode Extension: Rename Symbols
but it doesn't solve my questions.
My problem is that I only have a file as context, not some kind of cursor position. I would like to find the position of a certain symbolname in it (in my case, object name in al language - but that's besides the point).
I know the first match of a certain text will be the symbol ...
Thing is, I need code to be able to rename the symbol, and I have two problems with the code that I found in the link above:
first, as said, I don't know how I can get to the position of a certain string. I can get to the index, but not the position.
second, the last line of that example doesn't compile, since the "edit" variable is of type {}, and isn't allowed as a parameter in the ApplyEdit function.
The built-in rename ui is designed for renaming a symbol as a specific location.
If you want to rename a symbol in a file without using the current position, you can build your own flow using vscode.showInputBox to prompt the user for the new name and WorkspaceEdit + applyEdit to perform the rename itself

Use Swift to Delete a Single Line from a Text File

I am using a text file as an XML template for a project I am working on in Xcode with Swift 3. Depending on the type of request I am putting together from the template, sometimes certain lines are not needed. Is there a way in Swift to delete a single line from a text file? My searches are coming up empty.
A little more background: At runtime the contents of the file are copied into an NSString. I do not need to modify the text file itself, just the string that is being instantiated by the file. I have tried doing string.replacingOccurrences(of:string with "") but that is leaving gaps in the file. This actually works, I was just hoping for a more elegant solution.
Change your search and replace criteria to include the white space.
Another alternative would be to use NSRegularExpresssion and stringByReplacingMatchesInString to also remove all surrounding white space.

Publish an R code in github

I have written some codes in R that I have compiled into a package. Unfortunately
I am not able to publish it as a package such that any user may download it with the
install_github() function.
Kindly help.
I have shared the path for the repository below.
https://github.com/Kagereki/RPerio
When I try to install your package I get the following error:
Error: Line starting 'Population-Based Sur ...' is malformed!
The specification for DESCRIPTION files states that
DESCRIPTION uses a simple file format called DCF, the Debian control format. You can see most of the structure in the simple example below. Each line consists of a field name and a value, separated by a colon. When values span multiple lines, they need to be indented:
Description: The description of a package is usually long,
spanning multiple lines. The second and subsequent lines
should be indented, usually with four spaces.
Inspecting your DESCRIPTION file shows that its Description field is indeed formatted incorrectly, with the second line not indented:
Description: A collection of tools for Case Definitions and prevalences in
Population-Based Surveillance of Periodontitis.
The functionality is experimental and functions are likely to ...
Note that this line begins with "Population-Based Sur ...", as suggested by the error message.
Make sure your DESCRIPTION is properly formatted and see if that fixes things.
You should be able to use the check() function from devtools to make sure that everything is working locally before you push up a new version.

how do I open an image using the python image library?

I am using the image library with python for the first time and am trying to open an image on my pc. So I type in
Image.open(C:\Users\laurence\Google Drive\INB347 web 2.0)
and I keep getting this:
SyntaxError: invalid syntax: with the colon just after the C highlighted in red.
It does not mention this in the handbook which I am following. The example uses
a simpler file location: ('bride.jpg'). How do I open an image file please? thanks.
Try this:
Image.open(r'C:\Users\laurence\Google Drive\INB347 web 2.0')
i.e., enclose your full path in quotes, and put r in front of it to denote is as a 'raw' string, meaning Python won't try to interpret it as anything other than what you put between quotes. You can read more about raw strings here.