Xcode8: File Structure Quick View Seperator ('//MARK: -') - xcode8

I love the way how //MARK: - helps to separate the definitions in File Structure Quick View. However in Xcode8 such comment pattern has a usual Mark behaviour (bold text only).
Do you guys know its Xcode8 counterpart?
Reference:

Found it. Now MARK needs to have no text after a colon. So both empty //MARK:, //TODO: will produce a line separator inside the quick view.

Related

'fold up' sections of code - like when you close a control structure

I remember that there was a tag which made it possible to fold multiple lines.
e.g. like if you would fold down a for loop:
to
Is there a tag which makes this possible? Or is this an IDE specific tag?
Depends on the language and ide/editor.
In C# there are #region's that can be used for this. In some editors you can enable folding on all scopes (brackets). In some editors you can teach the editor to enable folding on comments with brackets in them ("//{" "//}").
In most cases this is an editor option that has to be enabled and configured.
What editor are you using? (and what language is this, JavaScript?)
For netbeans checkout the following: (You don't need to go past the first one)
http://wiki.netbeans.org/FaqCustomCodeFolds - Manual method
http://wiki.netbeans.org/SurroundWithCodeFolding - Code Template
https://ui.netbeans.org/docs/ui/code_folding/cf_uispec.html#custom - Talks about the how they work.
Example from first article:
// <editor-fold>
Your code goes here...
// </editor-fold>

How do I reliably style object layout in apache isis wicket viewer?

I have created a module by copying module-simple. I have everything working well. However, the layout does not follow the layout.xml specification - I did not change anything except to rename the file.
This is the SimpleObject view.
This is my ZiemObject view - only the name is changed.
When I remove the layout.xml and try to use #MemberOrder(name=..,sequence = .. ) I get nothing but the basic object view.
What am I doing wrong?
It isn't clear to me from your question, did you rename the layout file to ZiemObject.layout.xml ? I guess it must be because a layout is the only way to specify tabs. Could you paste a copy of it here?
Even better, perhaps you could upload your app to a github repo so we can take a deeper look?
UPDATE:
I downloaded the sample app from the github repo, and what's there works as expected...
the ZiemObject.layout.xml controls the member order of the ZiemObject, and because it is present the #MemberOrder annotation in that class are ignored
Also, the notes property is no longer shown as multi-line because that metadata is only provided in the .layout.xml file
if I rename the layout file, eg mv ZiemObject.layout.xml ZiemObject.layout.xml.MOVED then the default layout is honoured. In particular, the (framework-defined) id and version fields are no longer shown in tabs.
(Also, the notes is no longer shown as multi-line because that metadata is only provided in the .layout.xml file).
If I change the #MemberOrder#sequence attribute for the name and notes properties to "2" and "1" respectively, then the order of these fields is inverted, as shown below:
Hope that helps
Dan

UILables, Text Flow and Layouts

Consider the following, I have paragraph data being sent to a view which needs to be placed over a background image, which has at the top and the bottom, fixed elements (fig1)
Fig1.
My thought was to split this into 4 labels (Fig1.example2) my question here is how I can get the text to flow through labels 1 - 4 given that label 1,2 & 3 ar of fixed height. I assumed here that label 3 should be populated prior to 4 hence the layout in the attached diagram.
Can someone suggest the best way of doing this with maybe an example?
Thanks
Wish I could help more, but I think I can at least point you in the right direction.
First, your idea seems very possible, but would involve lots of calculations of text size that would be ugly and might not produce ideal results. The way I see it working is a binary search of testing portions of your string with sizeWithFont: until you can get the best guess for what the label will fit into that size and still look "right". Then you have to actually break up the string and track it in pieces... just seems wrong.
In iOS 6 (unfortunately doesn't apply to you right now but I'll post it as a potential benefit to others), you could probably use one UILabel and an NSAttributed string. There would be a couple of options to go with here, (I haven't done it so I'm not sure which would be the best) but it seems that if you could format the page with html, you can initialize the attributed string that way.
From the docs:
You can create an attributed string from HTML data using the initialization methods initWithHTML:documentAttributes: and initWithHTML:baseURL:documentAttributes:. The methods return text attributes defined by the HTML as the attributes of the string. They return document-level attributes defined by the HTML, such as paper and margin sizes, by reference to an NSDictionary object, as described in “RTF Files and Attributed Strings.” The methods translate HTML as well as possible into structures of the Cocoa text system, but the Application Kit does not provide complete, true rendering of arbitrary HTML.
An alternative here would be to just use the available attributes, setting line indents and such according to the image size. I haven't worked with attributed strings at this level, so I the best reference would be the developer videos and the programming guide for NSAttributedString. https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/AttributedStrings/AttributedStrings.html#//apple_ref/doc/uid/10000036-BBCCGDBG
For lesser versions of iOS, you'd probably be better off becoming familiar with CoreText. In the end you'll be rewarded with a better looking result, reusability/flexibility, the list goes on. For that, I would start with the CoreText programming guide: https://developer.apple.com/library/mac/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html
Maybe someone else can provide some sample code, but I think just looking through the docs will give you less of a headache than trying to calculate 4 labels like that.
EDIT:
I changed the link for CoreText
You have to go with CoreText: create your AttributedString and a CTFramesetter with it.
Then you can get a CTFrame for each of your textboxes and draw it in your graphics context.
https://developer.apple.com/library/mac/#documentation/Carbon/Reference/CTFramesetterRef/Reference/reference.html#//apple_ref/doc/uid/TP40005105
You can also use a UIWebView

Multi language localization storyboard support issue

I have an issue with my project storyboard. I have added two localizations more to storyboard, so now I have three storyboards: spanish, english and basque. All of them depending from the main one:
Now I have the issue that I have to update all changes manually to all to storyboards, because if I do changes to MainStoryboard, the others are not updated with this changes.
How can I modify all storyboards at the same time?
Thanks
Here is a really great tutorial for automating changes from one storyboard localization to all the others:
http://danielsaidi.wordpress.com/2012/08/20/localization-in-ios/
http://www.youtube.com/watch?v=cF1Rf02QvZQ
From what I gather, the solution involves adding a python script to the end of the build that syncs the storyboards and generates string files.
Go to the links for a more detailed solution. They said it better than I can.
You could either take out all the strings from Storyboard and put them in localized set of strings. Then you would have to do everything in your code like this:
self.label = NSLocalizedString("LABEL_STRING", nil);
or you could open the Storyboard as an XML file and do it there maybe a little faster. But other than that, no it is not doable, bcs the Storyboard localization serves you for polishing your localization. Say you have a screen called "HOME" and then (using google translate), you have "HASIERA" in basque. The problem here is, that in basque it's longer, so you need to adjust the GUI elements so it fits the screen perfectly. What could happen is that the string would be cut off, which we don't want to happen. That's why you need to do Storyboard localization step by step. If you don't need it, use strings file instead...

Localizing the Cut|Copy|Paste menu on iOS

Im having some issues localizing a danish app ive made. (The language, not the pastry)
I have set the CFBundleDevelopmentRegion to da_DK for danish in my info.plist, but the popup appearing for text input is still in english, even on phones running the danish OS.
How in Jobs name can i change this ?
The test device is a non-jailbroken iPhone 4S running iOS 5.1 with Danish as its iOS setting, and a danish itunes account associated.
I do not use .xibs for designs. all interfaces are programmed as viewcontrollers.
In the Xcode's file tree (Project Navigator) select your project. in the right hand pane select your project again. select Info and add your language.
I created a sample project, this is the result:
You can do this directly in the info.plist. Something like this:
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>de</string>
<string>es</string>
<string>ja</string>
</array>
Try adding/setting the "Localized resources can be mixed" flag in Info.plist to YES.
You must localize your app in Danish to make the standard UI elements appear in that language. This is to avoid having a UI with mixed languages.
If you don't use xibs, you'd usually do this by adding a Localizable.strings file to your project. In Xcode's "Add File" dialog, you can use the "Strings File" template (under "Resources") for this.
To actually localize the strings file, open the file inspector (⌘ ⌥ 1) and click the + button in the "Localization" section. You'll end up with the file being displayed as a group in the project navigator, with a sub-entry for each language.
The strings file has the format:
"Label_Text" = "Smørrebrød";
(don't forget the semicolon)
To use localized strings in your code, you can use the NSLocalizedString macro like this:
myLabel.text = NSLocalizedString(#"Label_Text", nil);
(The second parameter is for a comment. This can be useful if you use the genstrings tool to extract localizable strings from your code and give the resulting file to a professional translator.)
If you use the English strings as keys, you can leave the English version of Localizable.strings empty (but don't delete it).
Having a Localizable.strings file in the language that the user has selected will also cause standard UI elements, such as the editing menu, photo picker, and so forth, to appear in that language.
If you can't get it working the official way, as provided by #vikingosegundo, you can do this with some creative engineering (Creative as in, oh my god that is dangerous). I discovered this method when I accidentally overrode [NSBundle localizedStringForKey:value:tableName:].
1) Add a category to NSBundle with the following methods:
#import <objc/runtime.h>
+ (void) load {
Method original, swizzled;
original = class_getInstanceMethod(self, #selector(localizedStringForKey:value:table:));
swizzled = class_getInstanceMethod(self, #selector(swizzled_localizedStringForKey:value:table:));
method_exchangeImplementations(original, swizzled);
}
- (NSString*) swizzled_localizedStringForKey:(NSString *)key value:(NSString *)value table:(NSString *)tableName {
NSLog(#"Key: %#. Value: %#", key, value);
return [self swizzled_localizedStringForKey: key value:value table:tableName];
}
2) Where I simply log the key/value, you want to put an if ([key isEqualToString: xxx] ) block. In there, you want to catch (at least some of) the following key values: Cut, Copy[Menu], Select, Select All, Paste, Delete[Menu], Replace..., Define, Speak, Pause. These are the default values that can appear there.
3) When you have caught the value you can look up in a custom table or use hardcoded values. If you look up in a custom table make sure you have a catch in your swizzled method to avoid infinite looping in your custom table.
NB: Why do you need to swizzle? Because this over-rides all Apple text for you app. You will still want the defaults for all the other strings, so you need to swizzle to get the defaults for the strings you aren't interested in.
Good luck.
Paul
Search if your .xib is localized (you'll find it in the inspector on the right panel) if so go to your Project/Target-Settings press the +-Sign and select "Duplicate English to Danish" or something which means the same (I can't check the right item at the moment)
Btw it's called iPhone 4S.