class], &outCount); for (i = 0; i < outCount; i++) { objc_property_t property = properties[i]; NSString...*propertyName = [[NSString alloc] initWithCString:property_getName(property) encoding:NSUTF8StringEncoding...]; NSString *propertyType = [[NSString alloc] initWithCString:property_getAttributes(property) encoding...*)getClassName:(NSString *)attributes { NSString *type = [attributes substringFromIndex:[attributes...*)className { NSBundle *bundle = [NSBundle mainBundle]; Class aClass = [bundle classNamed:className
*ivarType; if ([obj isKindOfClass:NSClassFromString(@"__NSCFString")]) {...ivarType = @"NSString"; }else if ([obj isKindOfClass:NSClassFromString(@"__NSCFArray")]){...ivarType = @"NSArray"; }else if ([obj isKindOfClass:NSClassFromString(@"...__NSCFNumber")]){ ivarType = @"int"; }else if ([obj isKindOfClass:NSClassFromString...*ivarType = [Status dictWithModelClass][key]; Class modalClass = NSClassFromString(ivarType
plist文件中存放着与视图控制器同名的字符串 WechatIMG33.png 获取工程文件: NSString * path = [[NSBundle mainBundle] pathForResource...arrayWithContentsOfFile:path]; 从数组中取出: NSDictionary * dict = [array objectAtIndex:indexPath.row]; NSString...* str = [dict objectForKey:@"viewController"]; UIViewController* vc = [[NSClassFromString(str)alloc]...init]; vc.title = [dict objectForKey:@"title"]; 转换方法:NSString类型转换Class类型 NSClassFromString(NSString...; NSStringFromClass(Class aClass); //协议 NSStringFromProtocol(Protocol *proto) NSProtocolFromString(NSString
NSLog(@"done some with:%@",para); } @end 我们在其他类中,不通过类而是通过runtime的方式来调用这个方法,我们可以这样做: Class cls = NSClassFromString...类的方法的完整代码: SEL aSelecotor = NSSelectorFromString(@"doSomethingWithParameter:"); Class cls = NSClassFromString...action:(NSString *)actionName name:(NSString *)name hour:(NSUInteger)hour place:(NSString *)palce doSomething...:(NSString *)doSomething; @end 这是核心代码 - (id)performTarget:(NSString *)targetName action:(NSString *)...actionName parameters:(NSArray *)parameters{ Class tagetClass = NSClassFromString(targetName);
:NSClassFromString(@"WXSwitchComponent")]; [self registerComponent:@"input" withClass:NSClassFromString...:NSClassFromString(@"WXLoadingIndicator")]; [self registerComponent:@"refresh" withClass:NSClassFromString...:NSClassFromString(@"WXModalUIModule")]; [self registerModule:@"webview" withClass:NSClassFromString...:NSClassFromString(@"WXClipboardModule")]; [self registerModule:@"globalEvent" withClass:NSClassFromString...:NSClassFromString(@"WXWebSocketModule")]; }复制代码 WXSDKEngine会默认注册这15种基础模块。
(NSString *aSelectorName); // Class和字符串转换 FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass)...; FOUNDATION_EXPORT Class __nullable NSClassFromString(NSString *aClassName); // Protocol和字符串转换 FOUNDATION_EXPORT...NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0); FOUNDATION_EXPORT Protocol...Class class = NSClassFromString(@"ViewController"); ViewController *vc = [[class alloc] init]; SEL selector...remoteNotificationDictionary:(NSDictionary *)dict { // 根据字典字段反射出我们想要的类,并初始化控制器 Class class = NSClassFromString
* nameStr=[NSString stringWithUTF8String:name]; int ret=old_sysctlbyname(name,oldp,oldlenp,newp...*) value { return [OpenUDID valueWithError:nil]; } + (NSString*) valueWithError:(NSError **)error...SensorsAnalyticsAnonymousId]; // 返回保存的设备 ID return _anonymousId; } // 获取 IDFA:使用NSClassFromString...Class cls = NSClassFromString(@"ASIdentifierManager"); if (cls) { #pragma clang diagnostic push #...SensorsAnalyticsAnonymousId]; // 返回保存的设备 ID return _anonymousId; } // 获取 IDFA Class cls = NSClassFromString
YES : NO; // Class clazz = NSClassFromString(BUGLY_AGENT_CLASS); // ...* pKey = NSStringNonnullMake(key); Class clazz = NSClassFromString(BUGLY_AGENT_CLASS); ...* pUserId = NSStringMake(userId); Class clazz = NSClassFromString(BUGLY_AGENT_CLASS); ...* pType = NSStringMake(type); NSString * pMsg = NSStringMake(msg); NSString * pTraceStack =...(msg); Class clazz = NSClassFromString(BUGLY_AGENT_CLASS); if (clazz) { SEL
method_exchangeImplementations(imageNamedMethod, in_imageNamedMethod); } + (UIImage *)in_imageNamed:(NSString...*ivarName = [NSString stringWithUTF8String:ivar_getName(ivar)]; // 去掉name前面的"_" NSString...[ivarType hasPrefix:@"NS"]) { // 根据类型名 生成类对象 Class modelClass = NSClassFromString...= [idSelf arrayContainModelClass][key]; // 生成模型 Class classModel = NSClassFromString...*key = [NSString stringWithUTF8String:name]; id value = [aDecoder decodeObjectForKey:key
[alert show]; [alert release]; } //点击按钮后,触发这个方法 -(void)sendEMail { Class mailClass = (NSClassFromString..., 1); // jpeg [mailPicker addAttachmentData: imageData mimeType: @"" fileName: @"123.jpg"]; NSString...; NSString body = @"&body=email body!"...; NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body]; email = [email stringByAddingPercentEscapesUsingEncoding...*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { NSString
:@"tabbar_contacts" :@"tabbar_contactsHL"]; } //自定的方法中根据传进来的字符串创建控制器 -(void)addNavigationChildVC: (NSString...*) vcName :(NSString *)title :(NSString *)nomalImageName :(NSString *)selectedImageName { //创建控制器...Class class = NSClassFromString(vcName); UIViewController *vc = [[class alloc]init]; ......else { print("获取失败") return nil } //拼接完整的类 guard let vcClass = NSClassFromString
*)testFun:(NSString*)argc argb:(NSString*)argb{ //实现 [argc stringByAppendingString:argb]; NSString...* string = argc; NSString* aString; NSString* stringToAppend = argb; NSInvocation* inv =...(@"NSArray"); Class __NSArrayI = NSClassFromString(@"__NSArrayI");//数组有内容obj类型才是__NSArrayI...Class __NSSingleObjectArrayI = NSClassFromString(@"__NSSingleObjectArrayI");//iOS10 以上,单个内容类型是__NSArraySingleObjectI...Class __NSArray0 = NSClassFromString(@"__NSArray0");//iOS9 以上,没内容类型是__NSArray0
对象类型 NSString *key = [NSString stringWithUTF8String:ivar_getName(ivar)]; // 忽略不需要归档的属性...对象类型 NSString *key = [NSString stringWithUTF8String:ivar_getName(ivar)]; // 忽略不需要解档的属性...type hasPrefix:@"NS"]) { // 将对象名转换为对象的类型,将新的对象字典转模型(递归) Class class = NSClassFromString...NSString *classStr = [self arrayObjectClass]; class = NSClassFromString(classStr)..."_view"]; for (UIView *subView in tabBarButton.subviews) { if ([subView isKindOfClass:NSClassFromString
setNavigationContent]; // self.tabBarItem addObserver: forKeyPath:NSString...title ,达到选中之后和未选中的title不一样的效果 切换到首页时title为刷新,提示用户再次点击tab刷新界面数据 在这里插入图片描述 未选择首页tab时的title为首页 在这里插入图片描述 NSString... * const GYQhomeTabbarTitle = @"首页"; NSString * const GYQhomeTabbarSelectedTitle = @"刷新"; - (void)tabBar...; for (UIControl *tabBarButton in self.subviews) { if ([tabBarButton isKindOfClass:NSClassFromString...tabBarButton { for (UIView *imageView in tabBarButton.subviews) { if ([imageView isKindOfClass:NSClassFromString
(@"WXDivComponent") withProperties:nil]; [self registerComponent:@"div" withClass:NSClassFromString...(@"WXComponent") withProperties:nil]; [self registerComponent:@"text" withClass:NSClassFromString...(@"WXTextComponent") withProperties:nil]; [self registerComponent:@"image" withClass:NSClassFromString...废话不多说,还是上代码: - (void)registerMethods { Class currentClass = NSClassFromString(_clazz); while...[_jsBridge registerCallNativeModule:^NSInvocation*(NSString *instanceId, NSString *moduleName, NSString
details/105599042 字符串和数组的转换 componentsSeparatedByString componentsJoinedByString class与string之间的互相转换 NSClassFromString...I 、字符串和数组的转换 1.1、字符串和数组的转换 #字符串分割到数组里# NSString *str = @"You@are@the@best"; NSArray *array7 = [str componentsSeparatedByString...结果:array7 = @[@"You",@"are",@"the",@"best"]; #数组连接成字符串# NSArray *array8 = @[@"I", @"love", @"you"]; NSString...为分隔符进行拼接】 /** 应用场景:上传审核材料,接口参数AuditMaterials多张图用“|”隔开 返回的字符串: 【数组arr元素对象的属性picurl 以“|”为分隔符进行拼接】 */ + (NSString...valueForKeyPath:@"@distinctUnionOfObjects.picurl"];//arDistinct是一些含有picurl属性的对象集合 //数组连接成字符串# NSString
*html = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"web" ofType:@"html...(v) { // 查目标容器 for (UIView *sub in v.subviews) { if ([sub isKindOfClass:NSClassFromString...*)pre ids:(NSString *)ids { if (!...UIScrollView *webViewScrollView = self.webView.scrollView; if ([webViewScrollView isKindOfClass:NSClassFromString...[_WKContentView isKindOfClass:NSClassFromString(@"WKContentView")]) return; NSArray *gestrues
// 获取网络环境的方法 + (NSString *)networktype{ NSArray *subviews = [[[[UIApplication sharedApplication]...*dataNetworkItemView = nil; for (id subview in subviews) { if([subview isKindOfClass:[NSClassFromString
WKWebJSHandler : NSObject typedef void (^JSResponseCallback)(id responseData); @property (nonatomic,copy)NSString...jsResponseCallback;//回参 -(NSArray *)getSubClassArr;//获取所有继承该类的方法 //注册控件 - (void)messageWithHandler:(NSString...:(void (^)(id responseData))completeBlock; @end 通过运行时,把注册的控件的入参出参model化 - (void)messageWithHandler:(NSString...void (^)(id responseData))completeBlock { @synchronized(self) { Class class = NSClassFromString...* className = each.allKeys.firstObject; NSString * methodName = each.allValues.firstObject;
objc_property_t *allPropertys = class_copyPropertyList([self class], &propertyCount); 获取属性的name //拿到属性名称 NSString...*property_name = [NSString stringWithUTF8String:property_getName(property)]; 以name为key从Json字典里获取值 //...,就先转化为NSData if ([json isKindOfClass:[NSString class]]) { jsonData = [(NSString *)json dataUsingEncoding...mapperDict = [[self class] attributesMapperDictionary]; } // 如果有属性需要重新映射=== NSString...*className = [nestDict objectForKey:property_name]; Class class = NSClassFromString(className