# Data & networking

Language: en
Canonical: [Data & networking](<https://allluckly.cn/en/journal/topics/data-network/>)
中文：[中文 HTML](<https://allluckly.cn/journal/topics/data-network/>)
English: [English HTML](<https://allluckly.cn/en/journal/topics/data-network/>)

DEVELOPMENT NOTES · 24 articles

From local storage to remote messages, these notes record approaches to persistence, request wrappers, push notifications and instant messaging. Identify the data layer first, then examine what each part of the code does.

## How to read this collection

1. For local data, begin with Core Data, archiving and caches. Compare storage formats, update timing and invalidation policies; these tools solve different problems.
2. For networking, start with NSURLSession and request architecture, then follow the CocoaAsyncSocket connection flow through requests, callbacks, failures and retries.
3. Push notifications, contacts, maps and payment integrations depend on permissions and changing services. After reading the historical workflow, consult the provider’s current documentation.

These notes date from 2015–2017. Their examples have not been rerun for this archive update. Check the dates and version notes before applying the ideas to a current project.

## Articles in this topic

24 articles · newest first

- 2017-05-03 

  ### [DNS Hijacking and Request Handling in iOS](<https://allluckly.cn/en/journal/2017-05-03-dns-hijacking-and-request-handling-in-ios/>)

   

  Introduces DNS hijacking through unexpected name-resolution results, then describes using NSURLProtocol to adjust requests and resolution. It discusses compatibility boundaries involving IPv6, WebKit, and NSURLSession and retains the implementation examples and references.

   

  SindriLin DNS · NSURLProtocol · IPv6
- 2017-03-09 

  ### [Reading CocoaAsyncSocket: Completing the Connection](<https://allluckly.cn/en/journal/2017-03-09-reading-cocoaasyncsocket-completing-the-connection/>)

   

  Continues tracing the CocoaAsyncSocket connection process from local-address binding to connection establishment and callbacks. Low-level socket operations explain the order of asynchronous execution and the purpose of the relevant configuration.

   

  涂耀辉 CocoaAsyncSocket · GCDAsyncSocket · bind
- 2017-02-17 

  ### [Reading CocoaAsyncSocket: Connection Setup](<https://allluckly.cn/en/journal/2017-02-17-reading-cocoaasyncsocket-connection-setup/>)

   

  Follows GCDAsyncSocket initialization and connection entry points through the CocoaAsyncSocket source. It traces parameter checks, local and server address creation, and socket configuration before connecting, using annotated code to explain the call sequence.

   

  涂耀辉 CocoaAsyncSocket · GCDAsyncSocket · Socket
- 2016-10-12 

  ### [iOS 10 Notifications, Part 2: Service Extensions](<https://allluckly.cn/en/journal/2016-10-12-ios-10-notifications-part-2-service-extensions/>)

   

  Explains how a Notification Service Extension processes content before a notification appears. It covers creating an extension target, changing text, loading attachments, and falling back to the original notification when processing times out.

   

  徐不同 UNNotificationServiceExtension · notification attachments · remote notifications
- 2016-09-28 

  ### [iOS 10 Notifications, Part 1: Requests, Triggers, and Attachments](<https://allluckly.cn/en/journal/2016-09-28-ios-10-notifications-part-1-requests-triggers-and-attachments/>)

   

  Uses local notifications to explain the relationship between UNNotificationRequest, triggers, and the notification center. It manages additions, updates, and deletions through identifiers and introduces valid file paths and configuration for notification attachments.

   

  徐不同 UNNotificationRequest · UNUserNotificationCenter · local notifications
- 2016-09-27 

  ### [iOS 10 Push Notifications: The Basics](<https://allluckly.cn/en/journal/2016-09-27-ios-10-push-notifications-the-basics/>)

   

  Starts with enabling push capabilities and checking an existing project's configuration, then introduces iOS 10 notification registration, notification-center delegates, and callbacks. Third-party push integration illustrates the API changes involved in migrating older code.

   

  徐不同 iOS 10 · UserNotifications · push registration
- 2016-06-02 

  ### [Wrapping automatic object archiving and unarchiving on iOS](<https://allluckly.cn/en/journal/2016-06-02-wrapping-automatic-object-archiving-and-unarchiving-on-ios/>)

   

  Starts with NSCoding and uses the runtime to enumerate instance variables and organise encoding. The WZXArchiver wrapper develops step by step, with discussion of child objects and the limits of automated storage.

   

  WzxJiang NSCoding · WZXArchiver · object archiving
- 2016-05-09 

  ### [A first look at PhotoKit in Swift](<https://allluckly.cn/en/journal/2016-05-09-a-first-look-at-photokit-in-swift/>)

   

  Uses a multi-photo picker to introduce PhotoKit, including the maximum selection count, returning an array of PHAsset objects and invoking a closure. The album project and learning resources document an attempt to move from AssetsLibrary to PhotoKit.

   

  大石头布 PhotoKit · PHAsset · multiple-photo selection
- 2016-04-26 

  ### [MVVM and chained network-request architecture](<https://allluckly.cn/en/journal/2016-04-26-mvvm-and-chained-network-request-architecture/>)

   

  Begins with growing business logic in a view controller, using a sign-in decision to separate Model, ViewModel and ViewController responsibilities. It then introduces ReactiveCocoa and a chained network-request wrapper for organising business calls.

   

  WzxJiang MVVM · ReactiveCocoa · ViewModel
- 2016-03-30 

  ### [Combining AES encryption with Base64 encoding on iOS](<https://allluckly.cn/en/journal/2016-03-30-combining-aes-encryption-with-base64-encoding-on-ios/>)

   

  Defines categories for NSData and NSString to demonstrate a workflow combining AES encryption and decryption with Base64 encoding. It notes that the client and server must agree on the same key and provides a complete demonstration project.

   

  Bison AES · Base64 · CommonCrypto
- 2016-03-16 

  ### [Building a Swift local-cache library step by step](<https://allluckly.cn/en/journal/2016-03-16-building-a-swift-local-cache-library-step-by-step/>)

   

  First distinguishes Documents, Caches, Preferences and temporary directories, then wraps a local file cache for objects, images and audio. Offline-browsing scenarios explain directory management and the approach to reading and writing cached content.

   

  大石头布 Swift · file caching · app sandbox
- 2016-03-14 

  ### [Building a WeChat-style iOS app, part 6](<https://allluckly.cn/en/journal/2016-03-14-building-a-wechat-style-ios-app-part-6/>)

   

  Records three issues after integrating chat: matching keyboard animation parameters, managing observers as the app enters and leaves the background, and preserving sign-in state. It includes the handling code and explicitly limits the simplified automatic sign-in example.

   

  WzxJiang keyboard notifications · instant messaging · app lifecycle
- 2016-03-03 

  ### [Remote notifications with JPush: a detailed integration guide](<https://allluckly.cn/en/journal/2016-03-03-remote-notifications-with-jpush-a-detailed-integration-guide/>)

   

  Prepares remote notifications through App ID configuration, push capabilities and certificate requests, then integrates the JPush SDK. Development and production settings, certificate export and client callbacks document an early push-notification setup workflow.

   

  WzxJiang APNs · JPush · push certificates
- 2016-02-14 

  ### [Building a WeChat-style iOS app, part 5](<https://allluckly.cn/en/journal/2016-02-14-building-a-wechat-style-ios-app-part-5/>)

   

  Continues the profile and Moments screens, using AVUser for registration and sign-in and AVFile for avatar uploads. Image compression reduces transfer size, while notes document issues with a pull-down header image and refresh components.

   

  WzxJiang AVUser · AVFile · avatar uploads
- 2016-02-03 

  ### [Building a WeChat-style iOS app, part 4](<https://allluckly.cn/en/journal/2016-02-03-building-a-wechat-style-ios-app-part-4/>)

   

  Adds cloud-storage and instant-messaging dependencies, wraps sign-in and registration methods, and records troubleshooting while querying user data. An early experiment with a password field is included as part of this historical development account.

   

  WzxJiang WeChat-style app · cloud storage · user sign-in
- 2016-01-25 

  ### [Do you need Alamofire? Trying NSURLSession instead](<https://allluckly.cn/en/journal/2016-01-25-do-you-need-alamofire-trying-nsurlsession-instead/>)

   

  Introduces NSURLSession through a simple data request, distinguishes data, download and upload tasks, and compares default, ephemeral and background configurations. It connects those choices with caching, cookies and the organisation of network tasks.

   

  大石头布 NSURLSession · NSURLSessionConfiguration · download tasks
- 2016-01-20 

  ### [Integrating LianLian Pay into an iOS app](<https://allluckly.cn/en/journal/2016-01-20-integrating-lianlian-pay-into-an-ios-app/>)

   

  Organises the linker options, resource styles and business fields required by the LianLian Pay SDK. It explains user identifiers, card-binding agreements and server callbacks, with notes on signatures and UI customisation settings that are easy to confuse.

   

  Bison LianLian Pay · payment SDK · server-side signatures
- 2016-01-10 

  ### [Understanding and using Core Data for persistence](<https://allluckly.cn/en/journal/2016-01-10-understanding-and-using-core-data-for-persistence/>)

   

  Explains the relationship between managed objects, contexts and the persistent store coordinator, then sets up Core Data and an entity model manually. Examples of creating, fetching, updating and deleting objects illustrate the main persistence workflow.

   

  Bison Core Data · NSManagedObjectContext · entity models
- 2016-01-04 

  ### [GitHub source-code picks, January 4: Bluetooth, launch animations and a custom tab bar](<https://allluckly.cn/en/journal/2016-01-04-github-source-code-picks-january-4-bluetooth-launch-animations-and-a-custom-tab-bar/>)

   

  Selects the BabyBluetooth framework, CLClipImageView launch animation and CYLTabBarController tab bar. Project links and selected usage examples introduce the components, including the distinction between Bluetooth central and peripheral modes.

   

  Bison BabyBluetooth · CoreBluetooth · CLClipImageView
- 2015-12-07 

  ### [OCR for debit and credit cards in iOS development](<https://allluckly.cn/en/journal/2015-12-07-ocr-for-debit-and-credit-cards-in-ios-development/>)

   

  Introduces card.io SDK integration for scanning card numbers, including linker settings, delegates and recognition callbacks. Objective-C and Swift examples accompany the workflow; the article specifies that the selected implementation is for credit-card scanning.

   

  Bison card.io · OCR · credit-card recognition
- 2015-11-09 

  ### [Using Alamofire with Swift 2.0](<https://allluckly.cn/en/journal/2015-11-09-using-alamofire-with-swift-2-0/>)

   

  Shows how to import Alamofire manually, configure project dependencies and make network requests in a Swift 2.0 environment. Screenshots identify the project-linking settings, preserving an early framework integration and usage workflow.

   

  Bison Swift 2.0 · Alamofire · network requests
- 2015-10-21 

  ### [Integrating Alipay friend sharing in three minutes](<https://allluckly.cn/en/journal/2015-10-21-integrating-alipay-friend-sharing-in-three-minutes/>)

   

  Walks through app registration, SDK import, URL Scheme configuration and callbacks for sharing to Alipay friends. It distinguishes the data objects for text, image and web messages, and records checks for installation detection and authentication failures.

   

  Bison Alipay sharing · SocialSDK · URL Scheme
- 2015-09-23 

  ### [Getting started with XMPP, step by step](<https://allluckly.cn/en/journal/2015-09-23-getting-started-with-xmpp-step-by-step/>)

   

  Records the initial integration of XMPP chat: importing dependencies, connecting to Openfire with user information, handling registration and sign-in authentication, and processing message callbacks. Client-side code accompanies the connection and messaging workflow.

   

  Bison XMPP · Openfire · instant messaging
- 2015-06-16 

  ### [Reading iOS contacts and sending SMS invitations](<https://allluckly.cn/en/journal/2015-06-16-reading-ios-contacts-and-sending-sms-invitations/>)

   

  Introduces a small wrapper for a friend-invitation workflow: reading device contacts and opening the SMS composer. It lists the AddressBook, AddressBookUI and MessageUI dependencies and provides the LBContacts example project.

   

  Bison contacts · AddressBook · MessageUI

