Basic knowledge of IOS development-fragmentation 48, basic knowledge of ios-48
1: Assertion failure in dequeueReusableCellWithIdentifier: forIndexPath:
static NSString *CellIdentifier = @"Cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
The above is always reported as a crash under IOS9; then changed to the following solution:
static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; }
2: CoreTelephony framework is not a private library
The Directory of the private framework is:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/PrivateFrameworks/
It can be seen that the CoreTelephony framework is in frameworks rather than PrivateFrameworks, so it can be safely used. The reason why CoreTelephony is a private library on the internet is that it was a private framework in iOS6, And then Apple made it public again;
3: how to get the phone status
A: First, import the CoreTelephony framework:
@ Import CoreTelephony;
B: Then declare a CTCallCenter variable:
@ Interface ViewController () {CTCallCenter * center _; // a variable declared to avoid retain cycle, pointing to the recipient's call center object} @ end
Then listen to the phone status:
-(Void) aboutCall {// obtain call access information callCenter. callEventHandler = ^ (CTCall * call) {if ([call. callState islog tostring: CTCallStateDisconnected]) {NSLog (@ "Call has been disconnected");} else if ([call. callState isEqualToString: CTCallStateConnected]) {NSLog (@ "Call has just been connected");} else if ([call. callState isEqualToString: CTCallStateIncoming]) {NSLog (@ "Call is incoming");} else if ([call. callState isEqualToString: CTCallStateDialing]) {NSLog (@ "call is dialing");} else {NSLog (@ "Nothing is done ");}};}
You can also obtain carrier information:
-(Void) getCarrierInfo {// obtain carrier information CTTelephonyNetworkInfo * info = [CTTelephonyNetworkInfo alloc] init]; CTCarrier * carrier = info. subscriberCellularProvider; NSLog (@ "carrier: % @", [carrier description]); // if the carrier changes, the carrier will be updated to output info. subscriberCellularProviderDidUpdateNotifier = ^ (CTCarrier * carrier) {NSLog (@ "carrier: % @", [carrier description]);}; // output NSLog (@ "Radio Access Technology: % @", info. currentRadioAccessTechnology );}
Of course, the test is conducted on the real machine. The output information is as follows:
16:34:14. 525 RWBLEManagerDemo [1489: 543655] carrier: CTCarrier (0x134e065c0) {Carrier name: [China Mobile] Mobile Country Code: [460] Mobile Network Code: [07] ISO Country Code: [cn] Allows VOIP? [YES]} 16:34:14. 526 RWBLEManagerDemo [1489: 543655] Radio Access Technology: CTRadioAccessTechnologyHSDPA