Swift pasted from iBooks into Xcode playground doesn't work [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm learning Swift from the Apple Swift book on iBooks, and code pasted into an Xcode playground from the book does not work. The code needs to be completely re-typed to work. Is there any way around this?

As #matt commented, you're better off working from the Xcode documentation window or the HTML version of the book in a web browser. iBooks, despite being an electronic medium, uses a lot of formatting tricks from the print publishing world that put invisible, illegal-for-Swift characters in the text.
You can find the web version of The Swift Programming Language on developer.apple.com. Ditto for the other Apple Swift iBook, Using Swift with Cocoa and Objective-C, and a lot of other documentation (Swift-specific and otherwise) that isn't on iBooks. You can copy-paste from the web version of the docs without getting invisible garbage characters.
You can also download the first chapter in TSPL, "A Swift Tour", as a runnable playground, so for that you can save the copy-pasting/typing entirely.
The command less by default will show you special characters. You can pipe the output of pbpaste to less to see true state of your clipboard. (The option -X prevents the screen from clearing which is good for capturing shell transcripts.)

You'll be copying soft returns from the book instead of proper line endings. In the text editor, turn on invisible characters, and look at the difference between the line ending character and the one that appears when you press return.
iBooks does nasty things when you copy-paste (adding attribution, for example) so it's not great for copying code from.

Related

Is it not possible to use "Analyze" with swift? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Previously with objective-c code, I could "Analyze" - CMD + Shift + B and Xcode would warn me of all kinds of wrongdoings on my part.
It seems that with Swift, I can do no wrong! No warnings of any kind! But clearly there is a memory leak in my code.
Is there some setting I have to enable to get Swift to analyze my code properly? (I am aware I should use the profiler and test on an actual device, which I do, but I wonder why "Analyze" doesn't do anything.
Unfortunately no. Even many releases later, the latest version of XCode (6.4) still cannot do Swift analysis. The 'Analyze' option only works for the Objective C files in your project.
Let's hope the next version will have it, along with the refactoring capabilities which also are still limited to Objective C code.
To this moment (Xcode 8.3.x) Static Code analysis skips Swift code. Some Swift warnings cover some of the issues previously detected by the analyzer.
Also the upcoming Xcode 9 (presented in WWDC 2017) does not announce any change in this direction.
Many issues detected by the static Analyzer of Obj-C are for the most part prevented by the actual Swift language (e.g. unintended fall-through in switch statements). Other issues and scenarios formerly caught by the analyser, are now caught directly by the Swift compiler.
Many flows and scenarios leading to program crash - (e.g. accessing null pointers, leaving dangling pointers, or accessing released memory blocks) are hardly possible in Swift. Swift strong typing, heavy use of optionals, the requirement to completely cover protocols, and switch-case over enums, etc. remove another bunch of issues previously found by the analyzer.
A Swift static code analyzer will need to go to another level in analyzing program logic, which is much harder, and theoretically impossible to do completely.
So - although I'm quite thrilled to think of some future Xcode Analyzer, I wouldn't hold my breath waiting for it
Update:
As more and more people are down voting my post, just small update from my side. It seems that indeed apple just did allow for pressing option "Analyze" but in the background it does nothing (state for 2016.04.21, though I am not working on iOS for the moment and probably I don't have the latest version of Xcode).
below my original post:
Just for next readers of this article. At this moment Xcode 7 is already able to analyze also Swift projects. Refactoring is still not working though.
BR,
Darek

License of "Apple Color Emoji.ttf" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
What's the license of OS X Lion's /System/Library/Fonts/Apple Color Emoji.ttf?
In this posting Apple's Peter Edberg says:
As previously stated, Apple would like to make the Apple Emoji font -
and the glyphs therefrom - widely available using a license that makes
it possible for anyone to change it as they see fit or to combine its
glyphs with those from another font, without Apple acquiring any
rights to such changes. The only conditions we want to impose are: a)
The name "Apple Emoji" can only be used for the original unmodified
font; if the font is modified or combined with another font, the
result must have a different name (without "Apple" in it). b) The
original font, or one derived from it or incorporating parts of it,
can not be sold as a stand-alone package. (However, it it could be
included as part of a system which is sold as a package). Otherwise a
third party should be free to use the font, or to adapt it, modify
it, extend it, distribute it, etc.
However, at the time of that posting (2009), Apple had not decided about the actual license. I tried to find out now, but I could not find a more official license statement.
[Update 2014-03-12: I have now mailed Mr. Edberg and asked for clarification.]
Mr. Edberg has answered me (my emphasis):
The font being considered for licensing as per the emoji4unicode posting [...] was not “Apple Color Emoji”, which was never considered for licensing. Rather, it was a separate black & white “Apple Emoji” font mainly developed as part of the proposal to Unicode and ISO 10646 for the addition of emoji characters, in order to provide glyphs for use in the code charts etc. As far as I know it is not a font that ever been included in shipping Apple products.
So the answer is that there is no license for 'Apple Color Emoji.ttf' available.
IANAL, by the way.
Update 2018-02-06: According to Twitter posts, Apple has started enforcing that now in the App Store. Sam Eckert reports there:
I’ve just been on the phone with the App Review team regarding the Emoji issue. Apps are NO LONGER ALLOWED TO USE EMOJI in non-keyboard based situations. Means if your app displays emoji anywhere without a user having it typed in, it’s illegal and will be rejected.

What are the advantages of Sublime Text over Notepad++ and vice-versa? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Closed 9 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
Lots of friends have suggested me to start using Sublime Text instead of Notepad++, but I've been happy so far with Notepad++. I use Notepad++ mainly for quick editing files (Haskell, Python, C#, HTML, JS, CSS, etc.), copying & paste pieces of text and running macros on it, etc.
What are the main differences in the feature set of Sublime Text and Notepad++?
One thing that should be considered is licensing.
Notepad++ is free (as in speech and as in beer) for perpetual use, released under the GPL license, whereas Sublime Text 2 requires a license.
To quote the Sublime Text 2 website:
..a license must be purchased for continued use. There is currently no
enforced time limit for the evaluation.
The same is now true of Sublime Text 3, and a paid upgrade will be needed for future versions.
Upgrade Policy
A license is valid for Sublime Text 3, and includes all
point updates, as well as access to prior versions (e.g., Sublime Text
2). Future major versions, such as Sublime Text 4, will be a paid
upgrade.
This licensing requirement is still correct as of Dec 2019.
Main advantage for me is that Sublime Text 2 is almost the same, and has the same features on Windows, Linux and OS X. Can you claim that about Notepad++? It makes me move from one OS to another seamlessly.
Then there is speed. Sublime Text 2, which people claim is buggy and unstable ( 3 is more stable ), is still amazingly fast. If you use it, you will realize how fast it is.
Sublime Text 2 has some neat features like multi cursor input, multiple selections etc that will make you immensely productive.
Good number of plugins and themes, and also support for those of Textmate means you can do anything with Sublime Text 2. I have moved from Notepad++ to Sublime Text 2 on Windows and haven't looked back. The real question for me has been - Sublime Text 2 or vim?
What's good on Notepad++ side - it loads much faster on Windows for me. Maybe it will be good enough for you for quick editing. But, again, Sublime Text 3 is supposed to be faster on this front too. Sublime text 2 is not really good when it comes to handling huge files, and I had found that Notepad++ was pretty good till certain size of files. And, of course, Notepad++ is free. Sublime Text 2 has unlimited trial.
It's best if you judge on your own,
1) Sublime works on Mac & Linux that may be its plus point, with VI mode that makes things easily searchable for the VI lover(UNIX & Linux).
http://text-editors.findthebest.com/compare/9-45/Notepad-vs-Sublime-Text
This Link is no more working so please watch this video for similar details Video
Initial observation revealed that everything else should work fine and almost similar;(with help of available plugins in notepad++)
Some Variation: Some user find plugins useful for PHP coders on that
http://codelikeapoem.com/2013/01/goodbye-notepad-hellooooo-sublime-text.html
although, there are many plugins for Notepad Plus Plus ..
I am not sure of your requirements, nor I am promoter of either of these editors :)
So, judge on basis of your requirements, this should satisfy you query...
Yes we can add that both are evolving and changing fast..

PDF Parsing with Text and Coordinates [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I am currently using PDF Box to parse a pdf and I am trying to figure out how to retrieve data about the text such as the font (bold, size, etc) and the location of the font.
Any suggestions?
After poking around the (hard to find) PDFBox docs, I found this little gem.
Apparently one of the examples shows exactly how to do everything you asked. Basically, you subclass PdfTextStripper and override the processTextPosition method. There, you query the TextPosition for whatever information you need.
For future reference, you can find the javaDoc here: http://pdfbox.apache.org/apidocs/index.html
Edit 2018-04-02: original link is dead, but example can be found in the SVN repo here.
One of the best things for text extraction from PDFs is TET, the text extraction toolkit. TET is part of the PDFlib.com family of products.
PDFlib.com is Thomas Merz's (the author of the "PostScript and PDF Bible") company.
TET's first incarnation is a library. That one can probably do everything you want, including to positional information about each text element on the page. Oh, and it can also extract images. It recombines+merges images which are fragmented into pieces.
pdflib.com also offers another incarnation of this technology, the TET plugin for Acrobat. Obviously you'd need Acrobat as well to make use of this.
And the third incarnation is the PDFlib TET iFilter. This is a standalone tool for user workstations. Both this is free (as in beer) to use for private, non-commercial purposes.
Lastly, TET also comes with a commandline interface.
TET is really powerful. Way better than Adobe's own text extraction. It extracted text for me where other tools (including Adobe's) do spit out garbage only.
A few months ago I tested their desktop standalone tool, and what they say on their webpage is true. It has a very good commandline. Some of my "problematic" PDF test files the tool handled to my full satisfaction.
This thing is my recommendation for every sophisticated and challenging PDF text extraction requirements.
TET is simply awesome. It detects tables. Inside tables, it identifies cells spanning multiple columns. It identifies table rows and contents of each table cell separately. It deals very well with hyphenations: it removes hyphens and restores complete words. It supports non-ASCII languages (including CJK, Arabic and Hebrew). When encountering ligatures, it restores the original characters...
Give it a try.
The GetPageText function with extract option 3 or 4 in Quick PDF Library returns a CSV string for the selected page which includes the text (either individual words or a piece of text) and the related font name, text color, text size and co-ordinates on the page.
Note: it is a commercial library and I work for the company that sells it.
PDF files can be parsed with tabula-py, or tabula-java.
I made a full tutorial on how to use tabula-py on this article. You can tabula in a web-browser too as long as you have installed Java.

What unicode-friendly text editor would you recommend for Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I work on a lot of Asian Language localization projects, and am looking for a powerful text editor with the following features:
1) Unicode support
2) Find in Files
3) Replace in Files
4) Regular expressions
5) Multiline find/replace
6) Built-in diff
I am currently using NotePad++, but it doesn't really support unicode in its find-in-files tool, which is a deal-breaker. EmEditor looks promising, but it doesn't have multi-line find/replace.
Anyone working with Chinese, Japanese, or Korean files have a text editor that they like, free or commercial?
I use UniRed for Unicode-intensive stuff. (I don't use it as a general purpose editor though: jEdit). UniRed displays the hex value for the current glyph in the lower screen, which is really handy (even for ASCII).
Here's a page that describes using Vim with Chinese language files: http://blog.wensheng.com/2007/05/vim-gvim-utf8-and-chinese-in-windows-xp.html
Disclaimer: I don't actually work with Asian languages, but Vim is the first thing that comes to mind when I think of a featureful and internationalized editor.
Check out JEdit. It's written in Java, which has language-level Unicode support. I haven't confirmed that it has all those features you listed, but I'd be surprised if it did not.
Ultraedit is my favorite text editor and it is advertised as having good Unicode support
http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/unicode.html.
It has the find / replace / regex features you're looking for as well as almost every other feature I have ever needed.
SciTE
http://scintilla.sourceforge.net/SciTETranslation.html
~ ~ ~
Relevant new features (unicode) of Scintilla's (the library which the SciTE editor is built upon) recent release notes:
Released on 18 October 2008.
Scintilla on Windows can interpret keys as Unicode even when a narrow character window with SCI_SETKEYSUNICODE.
Notification sent when autocompletion cancelled.
Assembler lexer works with non-ASCII text.
CSS lexer updated and works with non-ASCII.
I'd recommend EditPadPro (http://www.editpadpro.com). Aside from full Unicode support, it has one of the best regex engines built-in (it's from JGSoft, the makers of RegexBuddy (which incidentally integrates perfectly into EditPadPro)). You'll need RegexBuddy for the Find/Replace in files feature, everything else from your list is covered by EditPadPro itself.
I've switched from UltraEdit to EditPadPro a few months ago precisely because of its superior regex engine (UltraEdit's Perl regex engine has a few annoying bugs especially concerning multi-line find/replace operations).
A portable version that installs on any USB stick is included for free.
Jan Goyvaerts, EPP's creator, is a Belgian living in Thailand, so you can be pretty sure he knows his way around Asian languages.

Resources