Level : 13,718 WORDPRESS BOOK LINKEDIN PATENT Send Mail 동냥하기 윤지오

Digital Nomad

import UIKit


class DetailViewController: UIViewController {

    

    @IBOutlet weak var detailDescriptionLabel: UILabel!

    

    func configureView() {

        // Update the user interface for the detail item.

        if let detail = detailItem {

            detail.sizeToFit()

            self.view.addSubview(detail)

        }

    }

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        configureView()

    }

    

    var detailItem: UIImageView? {

        didSet {

            // Update the view.

            configureView()

        }

    }

}


class MasterViewController: UITableViewController {

.

.

.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        if segue.identifier == "showDetail" {

            if let indexPath = tableView.indexPathForSelectedRow {

//                let object = objects[indexPath.row] as! NSDate

                let controller = (segue.destination asUINavigationController).topViewController asDetailViewController

                switch indexPath.row {

                case 0: controller.detailItem = UIImageView(image:  imageLiteral(resourceName: "tohip"))

                case 1: controller.detailItem = UIImageView(image:  imageLiteral(resourceName: "tomigum"))

                defaultbreak

                }

                controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem

                controller.navigationItem.leftItemsSupplementBackButton = true

            }

        }

    }


'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

Making mater-detail app to hadle imageView  (0) 2019.02.05
UITabBar 크기 조정  (0) 2019.02.05
Alamofire SwiftyJSON  (0) 2019.02.05
log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04

Comment +0

Snapkit 쓰면 편하지만, 그냥 해 보았다.




3가지 방법이 있다. 1번은 interface builder에서 수정하는 방법.

2번은 서브 뷰를 펼치기 전에 호출되는 viewWillLayoutSubviews 를 override 해서 그 안에 tabview 의 height를 변경하는 방법.

extension UITabBar {

        override open func sizeThatFits(_ size: CGSize) -> CGSize {

            print("HJH_sizeThatFits")

            return super.sizeThatFits(size)

        }

}

3번은 UITabBar의 sizeThatFits를 오버라이드 하는 방법이다.

1번은 스킵하고 2번과 3번의 호출은 다음과 같았다.


HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_sizeThatFits

HJH_viewWillLayoutSubviews()

HJH_sizeThatFits

HJH_viewWillLayoutSubviews()

HJH_sizeThatFits


처음 그릴 때 많이 호출되고 이 후 탭 이동 시 마다 HJH_sizeThatFits이 2번씩 호출된다.


결국 viewWillLayoutSubviews를 override 하는 방법이 현명하겠다.


다음 3개 사이트의 코드가 필요하다.




var myDefaultFontSize:CGFloat = 26.0

switch UIDevice().type {

    case .iPhoneSE,.iPhone5,.iPhone5S: print("default value")

    case .iPhone6,.iPhone7,.iPhone8,.iPhone6S, .iPhoneX  : myDefaultFontSize += 4

    default:break

}


'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

Making mater-detail app to hadle imageView  (0) 2019.02.05
UITabBar 크기 조정  (0) 2019.02.05
Alamofire SwiftyJSON  (0) 2019.02.05
log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04

Comment +0

import UIKit

import Alamofire

import SwiftyJSON


class ViewController: UIViewController {

    

    let urlString: String = "https://yoursite.com"

    let token: String = "/yourTokenAPI"

    let login: String = "/yourLoginAPI"

    let testUserName: String = "hajunho"

    let testPassword: String = "sorasorapululunsora"

    let json1level = "data"

    let json2level = "token"

    

    var count: Int = 0

    

    override func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        getLoginToken()

    }

    

    func connectionTest(_ site: String, auth: Bool) {

        Alamofire.request(site)

            .validate(statusCode: 200..<300)

            .validate(contentType: ["application/json"])

            .responseData { response in

                switch response.result {

                case .success:

                    print("Validation Successful \(self.count)")

                case .failure(let error):

                    if(auth) {

                        print("Authentication is needed for Validation "self.count)

                    }

                    else {

                        assertionFailure()

                        print("Valication is Failed."self.count, error)

                    }

                }

        }

    }

    

    func getLoginToken() {

        let parameters: Parameters = ["username"testUserName,

                                      "password"testPassword]

        

        connectionTest(urlString+login, auth: true)

        

        Alamofire.request(urlString+token, parameters: parameters).responseJSON { response in

            if(false) {

                print("Request: \(String(describing: response.request))"  // original url request

                print("Response: \(String(describing: response.response))"// http url response

                print("Result: \(response.result)"                        // response serialization result

                if let data = response.datalet utf8Text = String(data: data, encoding: .utf8) {

                    print("Data: \(utf8Text)"// original server data as UTF8 string

                }

            }

            

            if let json = response.result.value {

                if(false) {

                    print("JSON: \(json)"// serialized json response

                }

                

                let swiftyJsonVar = JSON(json)

                let resToken = swiftyJsonVar[self.json1level][self.json2level].stringValue //KEYPOINT!!

                print(resToken)

                

            }

        }

    }

}



'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

Making mater-detail app to hadle imageView  (0) 2019.02.05
UITabBar 크기 조정  (0) 2019.02.05
Alamofire SwiftyJSON  (0) 2019.02.05
log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04

Comment +0

- singleton, 프로젝트 전역에서 사용 가능

GlobalSettings.shared.logLevel.contains(.all) 

- log level 나누기 가능

logLevel = .graphPanel

if GlobalSettings.shared.logLevel.contains(.graph2) { print("blah, blah") }

- 편리한 현재 위치 찍기

"".pwd(self)



import UIKit


//Where am I, exactly 

extension String {

    func pwd(_ x: Any)  {

        print("pwd_", String(describing: x.self))

    }

}


struct _logLevel: OptionSet {

    let rawValue: Int


    static let critical    = _logLevel(rawValue: 1 << 0)

    static let major  = _logLevel(rawValue: 1 << 1)

    static let minor   = _logLevel(rawValue: 1 << 2)

    static let just   = _logLevel(rawValue: 1 << 3)

    static let graph = _logLevel(rawValue: 1 << 4)

    static let graph2 = _logLevel(rawValue: 1 << 5)

    static let graphPanel = _logLevel(rawValue: 1 << 6)

    static let all: _logLevel = [.critical, .major, .minor, .just, .graph, .graph2, .graphPanel]

}


class GlobalSettings {

    var logLevel : _logLevel


    private init() {

//        logLevel = .all

//        logLevel = .critical

           logLevel = .graphPanel

//        logLevel = .just

    }


    static let shared = GlobalSettings()

}


'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

UITabBar 크기 조정  (0) 2019.02.05
Alamofire SwiftyJSON  (0) 2019.02.05
log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04
swift free book pdf  (0) 2019.02.04

Comment +0

https://github.com/AssistoLab/DropDown




        let lblDropDown : UILabel = {

            let ret = UILabel()

            ret.text = "drop down"

            ret.textColor = UIColor(hexColor: "9F9F9F")

            ret.lineBreakMode = .byClipping

            ret.sizeToFit()

            ret.isUserInteractionEnabled = true

            let tap = UITapGestureRecognizer(target: self, action: #selector(objDropDown))

            ret.addGestureRecognizer(tap)

            return ret

        }()

        

        self.bottomGroup.addSubview(lblDropDown)

        lblDropDown.snp.makeConstraints {

            $0.width.equalTo(40)

            $0.height.equalTo(40)

            $0.left.equalTo(lblSortBy.snp.right).offset(20)

        }



    @objc func objDropDown() {

        

        let dropDown = DropDown()

        // The view to which the drop down will appear on

        dropDown.anchorView = view // UIView or UIBarButtonItem

        

        // The list of items to display. Can be changed dynamically

        dropDown.dataSource = ["Car", "Motorcycle", "Truck"]

        

        // Action triggered on selection

        dropDown.selectionAction = { [unowned self] (index: Int, item: String) in

            print("Selected item: \(item) at index: \(index)")

        }

        

        dropDown.show()

    }

'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

Alamofire SwiftyJSON  (0) 2019.02.05
log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04
swift free book pdf  (0) 2019.02.04
swift badge  (0) 2019.01.31

Comment +2



다음과 같은 test.plist 가 있을 때,


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">


<plist version="1.0">


<array>


<integer>73</integer>


<integer>72</integer>


<integer>142</integer>


<integer>143</integer>


<integer>132</integer>


<integer>133</integer>


<integer>133</integer>


<integer>122</integer>


<integer>102</integer>


<integer>102</integer>


<integer>102</integer>


<integer>73</integer>


</array>


</plist>





var dataSource : Array<Int> = Array()





let lvPath = Bundle.main.url(forResource: "test", withExtension: "plist")!


let lvArray = try! Data(contentsOf: lvPath)


let decoder = PropertyListDecoder()


dataSource = try! decoder.decode(Array<Int>.self, from: lvArray)





print("jhFile_dataSource => ", dataSource)






plist 자료형은


https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PropertyLists/AboutPropertyLists/AboutPropertyLists.html

About Property Lists



developer.apple.com


'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

log 출력  (0) 2019.02.05
dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04
swift free book pdf  (0) 2019.02.04
swift badge  (0) 2019.01.31
swift 4.2에서 잘되는 background timer  (0) 2019.01.28

Comment +0

SwiftNotesForProfessionals.pdf


'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

dropDown Menu  (2) 2019.02.05
plist 읽기  (0) 2019.02.04
swift free book pdf  (0) 2019.02.04
swift badge  (0) 2019.01.31
swift 4.2에서 잘되는 background timer  (0) 2019.01.28
nodepointer  (1) 2019.01.28

Comment +0

스위프트 배지 라이브러리 주소

https://github.com/evgenyneu/swift-badge


Demo-iOS 에 CreateBadgeFromCodeViewController 참조


    lazy var mBadge : UIView = {

        let real = UIView()

        let ret = BadgeSwift()

        real.addSubview(ret)

        self.configureBadge(ret)

        self.positionBadge(ret, view: real)

        return real

    }()


real이랰ㅋㅋㅋ 나도 참.

'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

plist 읽기  (0) 2019.02.04
swift free book pdf  (0) 2019.02.04
swift badge  (0) 2019.01.31
swift 4.2에서 잘되는 background timer  (0) 2019.01.28
nodepointer  (1) 2019.01.28
SwiftMessages 사용법  (0) 2019.01.25

Comment +0

좌표는

https://github.com/yethafiz/BackgroundTimer


스냅샷은

BackgroundTimer.zip


앱 백그라운드 상태에서 시간이 디버그 로그로  잘 찍힌다.


https://github.com/rafaelcpalmeida/Countdowner 얘도 같은 API + 화면 제어 추가



'블로그 항해 일지 > !A. APIs' 카테고리의 다른 글

swift free book pdf  (0) 2019.02.04
swift badge  (0) 2019.01.31
swift 4.2에서 잘되는 background timer  (0) 2019.01.28
nodepointer  (1) 2019.01.28
SwiftMessages 사용법  (0) 2019.01.25
텍스트를 이미지로 그려서 붙이기  (0) 2019.01.23

Comment +0

https://github.com/apple/swift/blob/master/stdlib/public/runtime/Demangle.cpp

//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#include "swift/Basic/Range.h"
#include "swift/ABI/TypeIdentity.h"
#include "swift/Runtime/Metadata.h"
#include "swift/Runtime/Portability.h"
#include "swift/Strings.h"
#include "Private.h"
#include <vector>
#if SWIFT_OBJC_INTEROP
#include <objc/runtime.h>
#endif
using namespace swift;
Demangle::NodePointer
swift::_buildDemanglingForContext(const ContextDescriptor *context,
llvm::ArrayRef<NodePointer> demangledGenerics,
Demangle::Demangler &Dem) {
unsigned usedDemangledGenerics = 0;
NodePointer node = nullptr;
// Walk up the context tree.
std::vector<const ContextDescriptor *> descriptorPath;
{
const ContextDescriptor *parent = context;
while (parent) {
descriptorPath.push_back(parent);
parent = parent->Parent;
}
}
auto getGenericArgsTypeListForContext =
[&](const ContextDescriptor *context) -> NodePointer {
if (demangledGenerics.empty())
return nullptr;
if (context->getKind() == ContextDescriptorKind::Anonymous)
return nullptr;
auto generics = context->getGenericContext();
if (!generics)
return nullptr;
auto numParams = generics->getGenericContextHeader().NumParams;
if (numParams <= usedDemangledGenerics)
return nullptr;
auto genericArgsList = Dem.createNode(Node::Kind::TypeList);
for (unsigned e = generics->getGenericContextHeader().NumParams;
usedDemangledGenerics < e;
++usedDemangledGenerics) {
genericArgsList->addChild(demangledGenerics[usedDemangledGenerics],
Dem);
}
return genericArgsList;
};
for (auto component : reversed(descriptorPath)) {
switch (auto kind = component->getKind()) {
case ContextDescriptorKind::Module: {
assert(node == nullptr && "module should be top level");
auto name = llvm::cast<ModuleContextDescriptor>(component)->Name.get();
node = Dem.createNode(Node::Kind::Module, name);
break;
}
case ContextDescriptorKind::Extension: {
auto extension = llvm::cast<ExtensionContextDescriptor>(component);
// Demangle the extension self type.
auto selfType = Dem.demangleType(extension->getMangledExtendedContext());
if (selfType->getKind() == Node::Kind::Type)
selfType = selfType->getChild(0);
// Substitute in the generic arguments.
auto genericArgsList = getGenericArgsTypeListForContext(component);
if (selfType->getKind() == Node::Kind::BoundGenericEnum
|| selfType->getKind() == Node::Kind::BoundGenericStructure
|| selfType->getKind() == Node::Kind::BoundGenericClass
|| selfType->getKind() == Node::Kind::BoundGenericOtherNominalType) {
if (genericArgsList) {
auto substSelfType = Dem.createNode(selfType->getKind());
substSelfType->addChild(selfType->getChild(0), Dem);
substSelfType->addChild(genericArgsList, Dem);
selfType = substSelfType;
} else {
// TODO: Use the unsubstituted type if we can't handle the
// substitutions yet.
selfType = selfType->getChild(0)->getChild(0);
}
}
auto extNode = Dem.createNode(Node::Kind::Extension);
extNode->addChild(node, Dem);
extNode->addChild(selfType, Dem);
// TODO: Turn the generic signature into a demangling as the third
// generic argument.
node = extNode;
break;
}
case ContextDescriptorKind::Protocol: {
auto protocol = llvm::cast<ProtocolDescriptor>(component);
auto name = protocol->Name.get();
auto protocolNode = Dem.createNode(Node::Kind::Protocol);
protocolNode->addChild(node, Dem);
auto nameNode = Dem.createNode(Node::Kind::Identifier, name);
protocolNode->addChild(nameNode, Dem);
node = protocolNode;
break;
}
default:
// Form a type context demangling for type contexts.
if (auto type = llvm::dyn_cast<TypeContextDescriptor>(component)) {
auto identity = ParsedTypeIdentity::parse(type);
Node::Kind nodeKind;
Node::Kind genericNodeKind;
switch (kind) {
case ContextDescriptorKind::Class:
nodeKind = Node::Kind::Class;
genericNodeKind = Node::Kind::BoundGenericClass;
break;
case ContextDescriptorKind::Struct:
nodeKind = Node::Kind::Structure;
genericNodeKind = Node::Kind::BoundGenericStructure;
break;
case ContextDescriptorKind::Enum:
nodeKind = Node::Kind::Enum;
genericNodeKind = Node::Kind::BoundGenericEnum;
break;
default:
// We don't know about this kind of type. Use an "other type" mangling
// for it.
nodeKind = Node::Kind::OtherNominalType;
genericNodeKind = Node::Kind::BoundGenericOtherNominalType;
break;
}
// Override the node kind if this is a Clang-imported type so we give it
// a stable mangling.
if (identity.isCTypedef()) {
nodeKind = Node::Kind::TypeAlias;
} else if (nodeKind != Node::Kind::Structure &&
_isCImportedTagType(type, identity)) {
nodeKind = Node::Kind::Structure;
}
auto typeNode = Dem.createNode(nodeKind);
typeNode->addChild(node, Dem);
auto nameNode = Dem.createNode(Node::Kind::Identifier,
identity.getABIName());
if (identity.isAnyRelatedEntity()) {
auto relatedName = Dem.createNode(Node::Kind::RelatedEntityDeclName,
identity.getRelatedEntityName());
relatedName->addChild(nameNode, Dem);
nameNode = relatedName;
}
typeNode->addChild(nameNode, Dem);
node = typeNode;
// Apply generic arguments if the context is generic.
if (auto genericArgsList = getGenericArgsTypeListForContext(component)){
auto unspecializedType = Dem.createNode(Node::Kind::Type);
unspecializedType->addChild(node, Dem);
auto genericNode = Dem.createNode(genericNodeKind);
genericNode->addChild(unspecializedType, Dem);
genericNode->addChild(genericArgsList, Dem);
node = genericNode;
}
break;
}
// This runtime doesn't understand this context, or it's a context with
// no richer runtime information available about it (such as an anonymous
// context). Use an unstable mangling to represent the context by its
// pointer identity.
char addressBuf[sizeof(void*) * 2 + 1 + 1];
snprintf(addressBuf, sizeof(addressBuf), "$%" PRIxPTR, (uintptr_t)component);
auto anonNode = Dem.createNode(Node::Kind::AnonymousContext);
CharVector addressStr;
addressStr.append(addressBuf, Dem);
auto name = Dem.createNode(Node::Kind::Identifier, addressStr);
anonNode->addChild(name, Dem);
anonNode->addChild(node, Dem);
// Collect generic arguments if the context is generic.
auto genericArgsList = getGenericArgsTypeListForContext(component);
if (!genericArgsList)
genericArgsList = Dem.createNode(Node::Kind::TypeList);
anonNode->addChild(genericArgsList, Dem);
node = anonNode;
break;
}
}
// Wrap the final result in a top-level Type node.
auto top = Dem.createNode(Node::Kind::Type);
top->addChild(node, Dem);
return top;
}
// FIXME: This stuff should be merged with the existing logic in
// include/swift/Reflection/TypeRefBuilder.h as part of the rewrite
// to change stdlib reflection over to using remote mirrors.
Demangle::NodePointer
swift::_swift_buildDemanglingForMetadata(const Metadata *type,
Demangle::Demangler &Dem);
static Demangle::NodePointer
_buildDemanglerForBuiltinType(const Metadata *type, Demangle::Demangler &Dem) {
#define BUILTIN_TYPE(Symbol, Name) \
if (type == &METADATA_SYM(Symbol).base) \
return Dem.createNode(Node::Kind::BuiltinTypeName, Name);
#include "swift/Runtime/BuiltinTypes.def"
return nullptr;
}
/// Build a demangled type tree for a nominal type.
static Demangle::NodePointer
_buildDemanglingForNominalType(const Metadata *type, Demangle::Demangler &Dem) {
using namespace Demangle;
// Get the context descriptor from the type metadata.
const TypeContextDescriptor *description;
switch (type->getKind()) {
case MetadataKind::Class: {
auto classType = static_cast<const ClassMetadata *>(type);
#if SWIFT_OBJC_INTEROP
// Peek through artificial subclasses.
while (classType->isTypeMetadata() && classType->isArtificialSubclass())
classType = classType->Superclass;
#endif
description = classType->getDescription();
break;
}
case MetadataKind::Enum:
case MetadataKind::Optional: {
auto enumType = static_cast<const EnumMetadata *>(type);
description = enumType->Description;
break;
}
case MetadataKind::Struct: {
auto structType = static_cast<const StructMetadata *>(type);
description = structType->Description;
break;
}
case MetadataKind::ForeignClass: {
auto foreignType = static_cast<const ForeignClassMetadata *>(type);
description = foreignType->Description;
break;
}
default:
return nullptr;
}
// Gather the complete set of generic arguments that must be written to
// form this type.
std::vector<const Metadata *> allGenericArgs;
gatherWrittenGenericArgs(type, description, allGenericArgs);
// Demangle the generic arguments.
std::vector<NodePointer> demangledGenerics;
for (auto genericArg : allGenericArgs) {
// When there is no generic argument, put in a placeholder.
if (!genericArg) {
auto placeholder = Dem.createNode(Node::Kind::Tuple);
auto emptyList = Dem.createNode(Node::Kind::TypeList);
placeholder->addChild(emptyList, Dem);
auto type = Dem.createNode(Node::Kind::Type);
type->addChild(placeholder, Dem);
demangledGenerics.push_back(type);
continue;
}
// Demangle this argument.
auto genericArgDemangling =
_swift_buildDemanglingForMetadata(genericArg, Dem);
if (!genericArgDemangling)
return nullptr;
demangledGenerics.push_back(genericArgDemangling);
}
return _buildDemanglingForContext(description, demangledGenerics, Dem);
}
// Build a demangled type tree for a type.
//
// FIXME: This should use MetadataReader.h.
Demangle::NodePointer
swift::_swift_buildDemanglingForMetadata(const Metadata *type,
Demangle::Demangler &Dem) {
using namespace Demangle;
switch (type->getKind()) {
case MetadataKind::Class:
case MetadataKind::Enum:
case MetadataKind::Optional:
case MetadataKind::Struct:
case MetadataKind::ForeignClass:
return _buildDemanglingForNominalType(type, Dem);
case MetadataKind::ObjCClassWrapper: {
#if SWIFT_OBJC_INTEROP
auto objcWrapper = static_cast<const ObjCClassWrapperMetadata *>(type);
const char *className = class_getName(objcWrapper->getObjCClassObject());
auto module = Dem.createNode(Node::Kind::Module, MANGLING_MODULE_OBJC);
auto node = Dem.createNode(Node::Kind::Class);
node->addChild(module, Dem);
node->addChild(Dem.createNode(Node::Kind::Identifier,
llvm::StringRef(className)), Dem);
return node;
#else
assert(false && "no ObjC interop");
return nullptr;
#endif
}
case MetadataKind::Existential: {
auto exis = static_cast<const ExistentialTypeMetadata *>(type);
auto protocols = exis->getProtocols();
auto type_list = Dem.createNode(Node::Kind::TypeList);
auto proto_list = Dem.createNode(Node::Kind::ProtocolList);
proto_list->addChild(type_list, Dem);
// The protocol descriptors should be pre-sorted since the compiler will
// only ever make a swift_getExistentialTypeMetadata invocation using
// its canonical ordering of protocols.
for (auto protocol : protocols) {
#if SWIFT_OBJC_INTEROP
if (protocol.isObjC()) {
// The protocol name is mangled as a type symbol, with the _Tt prefix.
StringRef ProtoName(protocol.getName());
NodePointer protocolNode = Dem.demangleSymbol(ProtoName);
// ObjC protocol names aren't mangled.
if (!protocolNode) {
auto module = Dem.createNode(Node::Kind::Module,
MANGLING_MODULE_OBJC);
auto node = Dem.createNode(Node::Kind::Protocol);
node->addChild(module, Dem);
node->addChild(Dem.createNode(Node::Kind::Identifier, ProtoName),
Dem);
auto typeNode = Dem.createNode(Node::Kind::Type);
typeNode->addChild(node, Dem);
type_list->addChild(typeNode, Dem);
continue;
}
// Dig out the protocol node.
// Global -> (Protocol|TypeMangling)
protocolNode = protocolNode->getChild(0);
if (protocolNode->getKind() == Node::Kind::TypeMangling) {
protocolNode = protocolNode->getChild(0); // TypeMangling -> Type
protocolNode = protocolNode->getChild(0); // Type -> ProtocolList
protocolNode = protocolNode->getChild(0); // ProtocolList -> TypeList
protocolNode = protocolNode->getChild(0); // TypeList -> Type
assert(protocolNode->getKind() == Node::Kind::Type);
assert(protocolNode->getChild(0)->getKind() == Node::Kind::Protocol);
} else {
assert(protocolNode->getKind() == Node::Kind::Protocol);
}
type_list->addChild(protocolNode, Dem);
continue;
}
#endif
auto protocolNode =
_buildDemanglingForContext(protocol.getSwiftProtocol(), { }, Dem);
if (!protocolNode)
return nullptr;
type_list->addChild(protocolNode, Dem);
}
if (auto superclass = exis->getSuperclassConstraint()) {
// If there is a superclass constraint, we mangle it specially.
auto result = Dem.createNode(Node::Kind::ProtocolListWithClass);
auto superclassNode = _swift_buildDemanglingForMetadata(superclass, Dem);
result->addChild(proto_list, Dem);
result->addChild(superclassNode, Dem);
return result;
}
if (exis->isClassBounded()) {
// Check if the class constraint is implied by any of our
// protocols.
bool requiresClassImplicit = false;
for (auto protocol : protocols) {
if (protocol.getClassConstraint() == ProtocolClassConstraint::Class)
requiresClassImplicit = true;
}
// If it was implied, we don't do anything special.
if (requiresClassImplicit)
return proto_list;
// If the existential type has an explicit AnyObject constraint,
// we must mangle it as such.
auto result = Dem.createNode(Node::Kind::ProtocolListWithAnyObject);
result->addChild(proto_list, Dem);
return result;
}
// Just a simple composition of protocols.
return proto_list;
}
case MetadataKind::ExistentialMetatype: {
auto metatype = static_cast<const ExistentialMetatypeMetadata *>(type);
auto instance = _swift_buildDemanglingForMetadata(metatype->InstanceType,
Dem);
auto node = Dem.createNode(Node::Kind::ExistentialMetatype);
node->addChild(instance, Dem);
return node;
}
case MetadataKind::Function: {
auto func = static_cast<const FunctionTypeMetadata *>(type);
Node::Kind kind;
switch (func->getConvention()) {
case FunctionMetadataConvention::Swift:
if (!func->isEscaping())
kind = Node::Kind::NoEscapeFunctionType;
else
kind = Node::Kind::FunctionType;
break;
case FunctionMetadataConvention::Block:
kind = Node::Kind::ObjCBlock;
break;
case FunctionMetadataConvention::CFunctionPointer:
kind = Node::Kind::CFunctionPointer;
break;
case FunctionMetadataConvention::Thin:
kind = Node::Kind::ThinFunctionType;
break;
}
std::vector<std::pair<NodePointer, bool>> inputs;
for (unsigned i = 0, e = func->getNumParameters(); i < e; ++i) {
auto param = func->getParameter(i);
auto flags = func->getParameterFlags(i);
auto input = _swift_buildDemanglingForMetadata(param, Dem);
auto wrapInput = [&](Node::Kind kind) {
auto parent = Dem.createNode(kind);
parent->addChild(input, Dem);
input = parent;
};
switch (flags.getValueOwnership()) {
case ValueOwnership::Default:
/* nothing */
break;
case ValueOwnership::InOut:
wrapInput(Node::Kind::InOut);
break;
case ValueOwnership::Shared:
wrapInput(Node::Kind::Shared);
break;
case ValueOwnership::Owned:
wrapInput(Node::Kind::Owned);
break;
}
inputs.push_back({input, flags.isVariadic()});
}
NodePointer totalInput = nullptr;
switch (inputs.size()) {
case 1: {
auto singleParam = inputs.front();
// If the sole unlabeled parameter has a non-tuple type, encode
// the parameter list as a single type.
if (!singleParam.second) {
auto singleType = singleParam.first;
if (singleType->getKind() == Node::Kind::Type)
singleType = singleType->getFirstChild();
if (singleType->getKind() != Node::Kind::Tuple) {
totalInput = singleParam.first;
break;
}
}
// Otherwise it requires a tuple wrapper.
LLVM_FALLTHROUGH;
}
// This covers both none and multiple parameters.
default:
auto tuple = Dem.createNode(Node::Kind::Tuple);
for (auto &input : inputs) {
NodePointer eltType;
bool isVariadic;
std::tie(eltType, isVariadic) = input;
// Tuple element := variadic-marker label? type
auto tupleElt = Dem.createNode(Node::Kind::TupleElement);
if (isVariadic)
tupleElt->addChild(Dem.createNode(Node::Kind::VariadicMarker), Dem);
if (eltType->getKind() == Node::Kind::Type) {
tupleElt->addChild(eltType, Dem);
} else {
auto type = Dem.createNode(Node::Kind::Type);
type->addChild(eltType, Dem);
tupleElt->addChild(type, Dem);
}
tuple->addChild(tupleElt, Dem);
}
totalInput = tuple;
break;
}
NodePointer parameters = Dem.createNode(Node::Kind::ArgumentTuple);
NodePointer paramType = Dem.createNode(Node::Kind::Type);
paramType->addChild(totalInput, Dem);
parameters->addChild(paramType, Dem);
NodePointer resultTy = _swift_buildDemanglingForMetadata(func->ResultType,
Dem);
NodePointer result = Dem.createNode(Node::Kind::ReturnType);
result->addChild(resultTy, Dem);
auto funcNode = Dem.createNode(kind);
if (func->throws())
funcNode->addChild(Dem.createNode(Node::Kind::ThrowsAnnotation), Dem);
funcNode->addChild(parameters, Dem);
funcNode->addChild(result, Dem);
return funcNode;
}
case MetadataKind::Metatype: {
auto metatype = static_cast<const MetatypeMetadata *>(type);
auto instance = _swift_buildDemanglingForMetadata(metatype->InstanceType,
Dem);
auto typeNode = Dem.createNode(Node::Kind::Type);
typeNode->addChild(instance, Dem);
auto node = Dem.createNode(Node::Kind::Metatype);
node->addChild(typeNode, Dem);
return node;
}
case MetadataKind::Tuple: {
auto tuple = static_cast<const TupleTypeMetadata *>(type);
const char *labels = tuple->Labels;
auto tupleNode = Dem.createNode(Node::Kind::Tuple);
for (unsigned i = 0, e = tuple->NumElements; i < e; ++i) {
auto elt = Dem.createNode(Node::Kind::TupleElement);
// Add a label child if applicable:
if (labels) {
// Look for the next space in the labels string.
if (const char *space = strchr(labels, ' ')) {
// If there is one, and the label isn't empty, add a label child.
if (labels != space) {
auto eltName =
Dem.createNode(Node::Kind::TupleElementName,
llvm::StringRef(labels, space - labels));
elt->addChild(eltName, Dem);
}
// Skip past the space.
labels = space + 1;
}
}
// Add the element type child.
auto eltType =
_swift_buildDemanglingForMetadata(tuple->getElement(i).Type, Dem);
if (eltType->getKind() == Node::Kind::Type) {
elt->addChild(eltType, Dem);
} else {
auto type = Dem.createNode(Node::Kind::Type);
type->addChild(eltType, Dem);
elt->addChild(type, Dem);
}
// Add the completed element to the tuple.
tupleNode->addChild(elt, Dem);
}
return tupleNode;
}
case MetadataKind::HeapLocalVariable:
case MetadataKind::HeapGenericLocalVariable:
case MetadataKind::ErrorObject:
break;
case MetadataKind::Opaque:
default: {
if (auto builtinType = _buildDemanglerForBuiltinType(type, Dem))
return builtinType;
// FIXME: Some opaque types do have manglings, but we don't have enough info
// to figure them out.
break;
}
}
// Not a type.
return nullptr;
}
// NB: This function is not used directly in the Swift codebase, but is
// exported for Xcode support and is used by the sanitizers. Please coordinate
// before changing.
char *swift_demangle(const char *mangledName,
size_t mangledNameLength,
char *outputBuffer,
size_t *outputBufferSize,
uint32_t flags) {
if (flags != 0) {
swift::fatalError(0, "Only 'flags' value of '0' is currently supported.");
}
if (outputBuffer != nullptr && outputBufferSize == nullptr) {
swift::fatalError(0, "'outputBuffer' is passed but the size is 'nullptr'.");
}
// Check if we are dealing with Swift mangled name, otherwise, don't try
// to demangle and send indication to the user.
if (!Demangle::isSwiftSymbol(mangledName))
return nullptr; // Not a mangled name
// Demangle the name.
auto options = Demangle::DemangleOptions();
options.DisplayDebuggerGeneratedModule = false;
auto result =
Demangle::demangleSymbolAsString(mangledName,
mangledNameLength,
options);
// If the output buffer is not provided, malloc memory ourselves.
if (outputBuffer == nullptr || *outputBufferSize == 0) {
return strdup(result.c_str());
}
// Indicate a failure if the result does not fit and will be truncated
// and set the required outputBufferSize.
if (*outputBufferSize < result.length() + 1) {
*outputBufferSize = result.length() + 1;
}
// Copy into the provided buffer.
_swift_strlcpy(outputBuffer, result.c_str(), *outputBufferSize);
return outputBuffer;
}



Comment +1


xib 하나 만듦. 비어있는 View 추가

File Inspector 탭에서 Use Safe Area Layout Guides 해제

Simulated Metrics에서 Size를 Freeform 으로 변경

Size Inspector 탭에서 600, 309 로 width, height 변경

내부에 view 추가(Background view)

Background view 내부에 stack view 추가(Content view)


        btnQuestionMark.addTarget(self, action: #selector(btnQuestionmark), for: .touchUpInside)



@IBAction func btnQuestionmark() {

        let view: BottomDialogView = try! SwiftMessages.viewFromNib()

        view.configureDropShadow()

        view.cancelAction = { SwiftMessages.hide() }

        var config = SwiftMessages.defaultConfig

        config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)

        config.duration = .forever

        config.presentationStyle = .bottom

        config.dimMode = .gray(interactive: true)

        SwiftMessages.show(config: config, view: view)

    }


주의할 점 : Interface Builder 에서 Ctrl+C, V로 생성된 박스는 인식 안됨.



Comment +0

러프한 코드 뭉치지만 도움이 될 부분도 있을 것 같다.


    private func drawText(str : String, x : CGFloat, y : CGFloat, width : CGFloat, height : CGFloat, txtSize : CGFloat) -> CALayer {

        let commonWidth = width + (txtSize / 4)

        let renderer = UIGraphicsImageRenderer(size: CGSize(width: commonWidth, height: height))

        let img = renderer.image { soraforever in

            let paragraphStyle = NSMutableParagraphStyle()

            paragraphStyle.alignment = .center

            let attrs = [NSAttributedStringKey.font: UIFont(name: "".font1(), size: txtSize)!, NSAttributedStringKey.paragraphStyle: paragraphStyle]

            let string = str

            string.draw(with: CGRect(x: 0, y: 0, width: commonWidth, height: height), options: .usesLineFragmentOrigin, attributes: attrs, context: nil)

        }


self.addSublayer(drawText(str: String(l), x: xlocation-(GS.s.jhATextPanelSize*3), y: jhDraw.ARQ-mMargin, width: GS.s.jhATextPanelSize, height: GS.s.jhATextPanelSize, txtSize: GS.s.jhATextSize))

            }


 self.addSublayer(drawText(str: mUnit, x: 50, y: 50, width: GS.s.jhATextPanelSize+10, height: GS.s.jhATextPanelSize, txtSize: 7)) 


   self.addSublayer(drawText(str: label, x: 100, y: fx2 - 600, width: GS.s.jhATextPanelSize, height: GS.s.jhATextPanelSize, txtSize: GS.s.jhATextSize))


Comment +0

       let yourAttributes : [NSAttributedStringKey: Any] = [

            NSAttributedStringKey.font : UIFont(name: "".font1(), size: 14)!,

            NSAttributedStringKey.foregroundColor : UIColor.black,

            NSAttributedStringKey.underlineStyle : NSUnderlineStyle.styleNone.rawValue]

        

        let attributeString = NSMutableAttributedString(string: "TxtWhatYouWantToWrite",

                                                        attributes: yourAttributes)

        btn.setAttributedTitle(attributeString, for: .normal)

        btn.endEditing(false)


폰트 지정은 


import UIKit


//Where am I, exactly  ex) "".pwd(self)

extension String {

    func pwd(_ x: Any)  {

        if(!GS.s.logLevel.contains(.none)) {

            if x is String {

                print("🍭pwd_\(x)")

            } else {

                print("🍭pwd_", String(describing: x.self))

            }

        }

    }

    

    func pwdJustString(_ x: Any) -> String {

        return String(describing: x.self)

    }

    

    func font1() -> String {

        return "NanumSquareOTFR"

    }

    

    func font1L() -> String {

        return "NanumSquareOTFL"

    }

    

    func font1B() -> String {

        return "NanumSquareOTFB"

    }

    

    func font2() -> String {

        return "Pecita"

    }

}

Comment +2

2018-12-13

let today = Date()

        let dateFormatter = DateFormatter()

        dateFormatter.dateFormat = "yyyy-MM-dd EE"

        dateFormatter.locale = Locale(identifier: "ko_KR")

        print(dateFormatter.string(from: today))


2018. 12. 13(목)

dateFormatter.dateFormat = "yyyy. MM. dd(EE)"


기타

  let df = DateFormatter()

//        df.dateFormat = "yyyy-MMMM"

        df.dateFormat = "yyyy. MM. dd(EE)"

        df.locale = Locale(identifier: "ko_KR")




7일전 날짜 저장


        let aWeekAgo : Double = Date().timeIntervalSince1970 - (7 * 60 * 60 * 24)

        GS.s.periodStartDate = Date(timeIntervalSince1970: aWeekAgo)


//----------------------


        let dt : Date = GS.s.periodStartDate ?? Date()

        let dateFormatter = DateFormatter()

        dateFormatter.timeZone = TimeZone(abbreviation: "KST")

        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

        dateLabel.text = dateFormatter.string(from: dt)


swift date to string

Comment +2

var ie7 = 0;