Original article and code: http://blog.csdn.net/diyagoanyhacker/article/details/6582783
+ (Nsstring *) getcarrier :( nsstring *) imsi
{
If (imsi = nil | [imsi isequaltostring: @ "Sim not inserted"]) {
Return @ "unknown ";
}
Else {
If ([[imsi substringwithrange: nsmakerange (0, 3)] isw.tostring: @ "460"]) {
Nsinteger MNC = [[imsi substringwithrange: nsmakerange (3, 2)] intvalue];
Switch (MNC ){
Case 00:
Case 02:
Case 07:
Return @ "China Mobile ";
Break;
Case 01:
Case 06:
Return @ "China Unicom ";
Break;
Case 03:
Case 05:
Return @ "China Telecom ";
Break;
Case 20:
Return @ "China tietong ";
Break;
Default:
Break;
}
}
}
Return @ "unknown ";
}
Header files must be introduced
# Import UIDevice-IOKitExtensions.h"
# Include <sys/types. h>
# Include <sys/sysctl. h>
# Import <Mach/mach_host.h>
# Include <netinet/in. h>
# Include <ARPA/inet. h>
# Include <netdb. h>
# Include <ifaddrs. h>
# Include <sys/socket. h>
# Include <net/If. h>
# Include <net/if_dl.h>
# Include <ifaddrs. h>