--cocoa Touch design mode and application notification mechanism, "learning swift from scratch" study notes (Day)

Source: Internet
Author: User
Tags notification center

original articles, welcome reprint. Reprint Please specify: Dongsheng's blog

Notification ( Notification ) mechanism is based on the viewer ( Observer ) mode is also called publishing / Subscription ( Publish/subscribe ) mode, is MVC ( Model - View - Controller) is an important part of the model.  

Questions raised

The weather has been a subject of great interest to the British, and the changes in recent years have become a subject of great concern to the Chinese people. I will decide whether to take the subway or drive to work according to the weather forecast, and my daughter will decide which dress to wear tomorrow according to the weather forecast. So I customized the weather forecast SMS Notification service for my phone in mobile company, it's working model.

650) this.width=650; "Width=" "height=" 272 "title=" Untitled -3.jpg "style=" width:500px;height:272px; "src="/HTTP/ S1.51cto.com/wyfs02/m00/7d/12/wkiol1bfu0tzxrwtaaqtti-iwom205.jpg "border=" 0 "vspace=" 0 "hspace=" 0 "alt=" Wkiol1bfu0tzxrwtaaqtti-iwom205.jpg "/>

Every day the meteorological Bureau sends the weather forecast information to the mobile operator, and the mobile operator's SMS Center sends the weather report to the phone that has customized the service.

In a software system, an object state change can also affect the state of many other objects. There are many design schemes that can achieve this need, but the observer pattern is the most suitable one for the reusable and anonymous communication between objects .

Solution Solutions

The notification mechanism can implement communication between "one-to-many" objects. , all objects that are interested in a notification in the notification mechanism can be recipients. First, these objects need to send addobserver messages to notification hubs (nsnotificationcenter) for registration notifications, Postnotificationname Message Delivery notification to the notification center, the notification center will broadcast the notification to registered recipients. All the recipients don't know who delivered the notification, and they don't care more about its details. The delivery object is a one-to-many relationship with the receiver. If the recipient is no longer concerned about the notification, the Notification center will be issued a removeobserver message cancellation notification, no longer receive notifications.

  

Welcome to follow Dongsheng Sina Weibo@tony_Dongsheng.
Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom
650) this.width=650; "Width=" "height=" "title=" "style=" width:150px;height:150px "src=" http://s2.51cto.com/ Wyfs02/m02/7d/13/wkiom1bfuv_xamxcaadc6s3knxs690.jpg "border=" 0 "vspace=" 0 "hspace=" 0 "alt=" wKiom1bfuv_ Xamxcaadc6s3knxs690.jpg "/>
More ProductsIOS,Cocos, mobile Design course please pay attention to the official website of Chi Jie Classroom:http://www.zhijieketang.com
Smart-Jie Classroom Forum Website:http://51work6.com/forum.php


This article is from the "Dongsheng-ios Technical Consultant" blog, make sure to keep this source http://tonyguan.blog.51cto.com/701759/1749097

--cocoa Touch design mode and application notification mechanism, "learning swift from scratch" study notes (Day)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.