- Swift
- Objective-C
- C++/C
- JavaScript
- Mac OSX
- iOS
public class ReverseLinkedList { | |
public static void main(String[] args) { | |
ListNode head = new ListNode(2); | |
head.next = new ListNode(4); | |
head.next.next = new ListNode(6); | |
head.next.next.next = new ListNode(8); | |
head.next.next.next.next = new ListNode(10); | |
ListNode result = ReverseLinkedList.reverse2(head); | |
System.out.print("Nodes of the reversed LinkedList are: "); |
#import "TestViewController.h" | |
@interface TestViewController ()<TYLabelDelegate> | |
@property (nonatomic,copy) NSString *text; | |
@property (nonatomic,copy) NSString *text2; | |
@property (nonatomic,strong) TYLabel *contentAttributedLabel; | |
@property (nonatomic,strong) TYTextRender *textRender; | |
@property (nonatomic,strong) TYTextRender *textRender2; | |
@property (nonatomic,assign) CGFloat contentHeight; |
+ (CGSize)rectForAttributedString:(NSAttributedString *)string | |
size:(CGSize)theSize { | |
if (!string || CGSizeEqualToSize(theSize, CGSizeZero)) { | |
return CGSizeZero; | |
} | |
// setup TextKit stack | |
NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:theSize]; | |
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:string]; | |
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init]; |
// | |
// DeepCopy.h | |
// | |
// | |
#import <Foundation/Foundation.h> | |
// Deep -copy and -mutableCopy methods for NSArray and NSDictionary | |
@interface NSArray (DeepCopy) |
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation | |
Strings: | |
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently. | |
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store | |
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo" | |
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM | |
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings | |
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers. |
UILabel* leftLabel = [[UILabel alloc] init]; | |
leftLabel.backgroundColor = [UIColor redColor]; | |
[self.view addSubview:leftLabel]; | |
[leftLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal]; | |
leftLabel.text = @"返程高峰首日全国铁路发送1060万人 同比增长8.3%"; | |
[leftLabel sizeToFit]; | |
UILabel* rightLabel = [[UILabel alloc] init]; | |
rightLabel.backgroundColor = [UIColor greenColor]; |
// | |
// UIView+frameAdjust.h | |
// fenbi | |
// | |
// Created by Tang Qiao on 12-5-31. | |
// Copyright (c) 2012年 Fenbi.com . All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
package main | |
import ( | |
"errors" | |
"log" | |
) | |
func handlePanic(f func()) { | |
defer func() { | |
if r := recover(); r != nil { |
package main | |
import ( | |
"archive/tar" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
) |