1. Каким образом лучше и продуктивнее продвигаться в освоении? Сидеть за книгами или верстать из шаблонов все подряд поглядывая в htmlbook или гулять по ютубу в поисках видео?
2. Есть какой-либо смысл покупать "индивидуальные курсы"?
3. Конечно же советы от себя.
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
const NSUInteger WIDTH = 100;
const NSUInteger HEIGHT = 200;
const NSUInteger COMPONENTS_PER_PIXEL = 4;
const NSUInteger BITS_PER_COMPONENT = 8;
const NSUInteger BUFFER_LENGTH = WIDTH * HEIGHT * COMPONENTS_PER_PIXEL;
char *buffer = (char *) malloc(BUFFER_LENGTH);
for (NSUInteger i = 0; i < BUFFER_LENGTH; i += 4) {
buffer[i + 0] = 0x00;
buffer[i + 1] = 0x00;
buffer[i + 2] = 0xFF;
buffer[i + 3] = 0xFF;
}
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, buffer, BUFFER_LENGTH, NULL);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGImageRef image = CGImageCreate(WIDTH, HEIGHT, BITS_PER_COMPONENT, BITS_PER_COMPONENT * COMPONENTS_PER_PIXEL, COMPONENTS_PER_PIXEL * WIDTH, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaLast, dataProvider, NULL, false, kCGRenderingIntentDefault);
NSString *filePath = @"~/test.png";
NSURL *url = [NSURL fileURLWithPath:[filePath stringByExpandingTildeInPath]];
CGImageDestinationRef imageDestination = CGImageDestinationCreateWithURL((__bridge CFURLRef) url, kUTTypePNG, 1, NULL);
CGImageDestinationAddImage(imageDestination, image, NULL);
CGImageDestinationFinalize(imageDestination);
CGImageRelease(image);
CGColorSpaceRelease(colorSpace);
CGDataProviderRelease(dataProvider);
free(buffer);
return 0;
}
let x: Int! = 42
let y = x // y has type Int?
func f(_ arg: Int) { print(arg) }
let x: Int! = 42
let y: Int = x
let z = x as Int
f(x)
struct Dog {
func bark() { print("Woof!") }
}
let d: Dog! = Dog()
d.bark()
class Foo {
var x: Int!
init() {
// I can't setup x at this point :(
x = nil
}
func setup(x newValue: Int) { x = newValue }
func foo() {
// I promise that setupX() will be called before
// I will deal with x as if it was always present
print(x * 2)
}
}
let x: Int! = 42
@implicitlyUnwrapped let x: Optional<Int> = .some(42)
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetails" {
if let destination = segue.destination as? TheChoiseOfShipTableViewController,
let cell = sender as? UITableViewCell,
let indexPath = tableView.indexPath(for: cell) {
destination.ships = self.ships[indexPath.row]
}
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showDetails" {
if let destination = segue.destination as? TheChoiseOfShipTableViewController,
let cell = sender as? UITableViewCell,
let indexPath = tableView.indexPath(for: cell) {
destination.ships = self.ships[indexPath.row]
}
}
}