Home Blog Page 3891

Customized UIView subclass from a xib file


Do you need to discover ways to load a xib file to create a customized view object? Nicely, this UIKit tutorial is only for you written in Swift.

I have already got a complete information about initializing views and controllers, however that one lacks a really particular case: making a customized view utilizing interface builder. 🤷‍♂️

Loading xib information

Utilizing the contents of a xib file is a fairly rattling simple activity to do. You should use the next two strategies to load the contents (aka. the view hierarchy) of the file.

let view = UINib(
    nibName: "CustomView", 
    bundle: .most important
).instantiate(
    withOwner: nil, 
    choices: nil
).first as! UIView

// does the identical as above
// let view = Bundle.most important.loadNibNamed(
//    "CustomView", 
//    proprietor: nil, 
//    choices: nil
// )!.first as! UIView 

view.body = self.view.bounds
self.view.addSubview(view)

The snippet above will merely instantiate a view object from the xib file. You’ll be able to have a number of root objects within the view hierarchy, however this time let’s simply choose the primary one and use that. I assume that in 99% of the circumstances that is what you’ll want to be able to get your customized views. Additionally you may prolong the UIView object with any of the options above to create a generic view loader. Extra on that later… 😊

This methodology is fairly easy and low cost, nonetheless there’s one little downside. You’ll be able to’t get named pointers (retailers) for the views, however just for the foundation object. If you’re placing design components into your display screen, that’s effective, but when it’s good to show dynamic knowledge, you would possibly need to attain out for the underlying views as effectively. 😃

Customized views with retailers & actions

So the correct method to load customized views from xib information goes one thing like this:

Inside your customized view object, you instantiate the xib file precisely the identical method as I informed you proper up right here. 👆 The one distinction is that you just don’t want to make use of the thing array returned by the strategies, however it’s important to join your view objects via the interface builder, utilizing the File’s Proprietor as a reference level, plus a customized container view outlet, that’ll comprise the whole lot you want. 🤨

// observe: view object is from my earlier tutorial, with autoresizing masks disabled
class CustomView: View {

    // that is going to be our container object
    @IBOutlet weak var containerView: UIView!

    // different ordinary retailers
    @IBOutlet weak var textLabel: UILabel!

    override func initialize() {
        tremendous.initialize()

        // first: load the view hierarchy to get correct retailers
        let identify = String(describing: sort(of: self))
        let nib = UINib(nibName: identify, bundle: .most important)
        nib.instantiate(withOwner: self, choices: nil)

        // subsequent: append the container to our view
        self.addSubview(self.containerView)
        self.containerView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            self.containerView.topAnchor.constraint(equalTo: self.topAnchor),
            self.containerView.bottomAnchor.constraint(equalTo: self.bottomAnchor),
            self.containerView.leadingAnchor.constraint(equalTo: self.leadingAnchor),
            self.containerView.trailingAnchor.constraint(equalTo: self.trailingAnchor),
        ])
    }
}

So the initialize methodology right here is simply loading the nib file with the proprietor of self. After the loading course of completed, your outlet pointers are going to be crammed with correct values from the xib file. There may be one final thing that we have to do. Even the views from the xib file are “programmatically” linked to our customized view object, however visually they aren’t. So we now have so as to add our container view into the view hierarchy. 🤐

Customized UIView subclass from a xib file

If you wish to use your customized view object, you simply must create a brand new occasion from it – inside a view controller – and eventually be at liberty so as to add it as a subview!

One phrase about bounds, frames aka. springs and struts: fucking UGLY! That’s two phrases. They’re thought of as a nasty apply, so please use auto format, I’ve a pleasant tutorial about anchors, they’re superb and studying them takes about quarter-hour. 😅

class ViewController: UIViewController {

    weak var customView: CustomView!

    override func loadView() {
        tremendous.loadView()

        let customView = CustomView()
        self.view.addSubview(customView)
        NSLayoutConstraint.activate([
            customView.topAnchor.constraint(equalTo: self.view.topAnchor),
            customView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
            customView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
            customView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
        ])
        self.customView = customView
    }

    override func viewDidLoad() {
        tremendous.viewDidLoad()

        self.customView.textLabel.textual content = "Lorem ipsum"
    }
}

That’s it, now you could have a very working customized UIView object that hundreds a xib file to be able to use it’s contents. Wasn’t so unhealthy, proper? 🤪

Yet one more further factor. Should you don’t wish to deal with views programmatically otherwise you merely don’t need to fiddle with the loadView methodology, simply take away it fully. Subsequent put the @IBOutlet key phrase proper earlier than your customized view class variable. Open your storyboard utilizing IB, then drag & drop a brand new UIView ingredient to your controller and join the customized view outlet. It ought to work like magic. 💫

Storyboard

I promised retailers and actions within the heading of this part, so let’s speak somewhat bit about IBActions. They work precisely the identical as you’d count on them with controllers. You’ll be able to merely hook-up a button to your customized view and delegate the motion to the customized view class. If you wish to ahead touches or particular actions to a controller, it’s best to use the delegate sample or go together with a easy block. 😎

Possession and container views

It’s attainable to go away out all of the xib loading mechanism from the view occasion. We are able to create a set of extensions to be able to have a pleasant view loader with a customized view class from a xib file. This fashion you don’t want a container view anymore, additionally the proprietor of the file will be disregarded from the sport, it’s kind of the identical methodology as reusable cells for tables and collections created by Apple. 🍎

You need to know that going this fashion you may’t use your default UIView init strategies programmatically anymore, as a result of the xib file will handle the init course of. Additionally in case you are making an attempt to make use of this sort of customized views from a storyboard or xib file, you gained’t have the ability to use your retailers, as a result of the correspondig xib of the view class gained’t be loaded. In any other case in case you are making an attempt to load it manyally you’ll run into an infinite loop and finally your app will crash like hell. 😈

import UIKit

extension UINib {
    func instantiate() -> Any? {
        return self.instantiate(withOwner: nil, choices: nil).first
    }
}

extension UIView {

    static var nib: UINib {
        return UINib(nibName: String(describing: self), bundle: nil)
    }

    static func instantiate(autolayout: Bool = true) -> Self {
        // generic helper perform
        func instantiateUsingNib(autolayout: Bool) -> T {
            let view = self.nib.instantiate() as! T
            view.translatesAutoresizingMaskIntoConstraints = !autolayout
            return view
        }
        return instantiateUsingNib(autolayout: autolayout)
    }
}

class CustomView: UIView {

    @IBOutlet weak var textLabel: UILabel!
}

// utilization (inside a view controller for instance)
// let view = CustomView.instantiate()

Identical to with desk or assortment view cells this time it’s important to set your customized view class on the view object, as an alternative of the File’s Proprietor. You must join your retailers and principally you’re finished with the whole lot. 🤞

ownership

Any more it’s best to ALWAYS use the instantiate methodology in your customized view object. The excellent news is that the perform is generic, returns the correct occasion sort and it’s extremely reusable. Oh, btw. I already talked about the unhealthy information… 🤪

There may be additionally another method by overriding awakeAfter, however I might not depend on that answer anymore. In many of the circumstances you may merely set the File’s Proprietor to your customized view, and go together with a container, that’s a secure wager. You probably have particular wants you would possibly want the second strategy, however please watch out with that. 😉

Preventative protection techniques in the true world

0


Enterprise Safety

Don’t get hacked within the first place – it prices far lower than coping with the aftermath of a profitable assault

Preventative defense tactics in the real world

We watch actual life assaults in horror, the place firms merely attempt to defend in opposition to attackers stomping on their networks in actual time, blunting the injury and scouring for backups in a bid to keep away from the crippling value of ransom funds.

It’s a protection akin to investing in good demolition gear in case your home catches fireplace so you may clear particles shortly and rebuild. Nevertheless, as any fireplace security professional would attest, it’s a lot cheaper and time-consuming to stop fires within the first place.

Likewise, in cybersecurity, prevention isn’t just preferable however important. Listed here are a couple of assault techniques, based mostly on developments we’re seeing daily with our clients, and a few preventative strategies that may blunt the assault earlier than it will get into your community.

Distant Desktop Protocol (RDP) protection

RDP assaults, if profitable, enable attackers to realize administrator privileges and shut off your cyber-defenses. It’s like giving an attacker a grasp key to your home, then making an attempt to maintain them away out of your priceless jewellery. Safety firms get blamed for lacking such tough assaults, but it surely’s arduous to beat the digital equal of leaving the entrance door open. Including defensive layers like multi-factor authentication (MFA) can assist thwart RDP assaults like brute pressure and Distant Code Exploits (RCE). Additional, Endpoint Detection and Response (EDR) and Managed Detection and Response (MDR) can assist cease attackers in the event that they’re capable of get previous RDP, by stopping lateral motion and encryption makes an attempt for ransomware. That is additionally true of Distant Desktop Companies (RDS), the place attackers leverage capabilities far past what RDS is supposed to be doing.

Enterprise visibility

Attackers solely have to succeed as soon as whereas defenders should be profitable each single time. Attackers who acquire persistence on one community node can begin to map and plan assaults. Community entry makes an attempt seen solely from the endpoint can miss the larger image of a coordinated assault. Core community firewalls are key right here, particularly if they arrive with IDS/IPS inbuilt, with the flexibility so as to add YARA guidelines to defend in opposition to rising assaults. Safety firms, together with ESET, usually launch YARA guidelines and varied free instruments to assist defend in opposition to network-based assaults, whether or not originating from inside or outdoors the group.

Multi-Issue Authentication (MFA)

As most companies transition to the cloud, a single exploit in opposition to a cloud supplier can enable attackers to wreak havoc in opposition to a number of targets, together with your group. Person passwords, as soon as compromised, are frequently dumped into freely accessible coaching units for automated brute pressure makes an attempt. MFA can cease, or a minimum of blunt, brute pressure assaults, particularly Enterprise E-mail Compromise (BEC), which is a perpetual concern. Including MFA to customers’ logins can considerably restrict your publicity.

Whereas nation-state degree assaults make the headlines, it’s less complicated assaults which can be much more doubtless. Don’t begin by searching for tastily-crafted zero days utilized by devoted groups of cyber-adversaries focusing on your group. These threats are typically much less acute, except you’re harboring multi-billion greenback potential payouts from stealing company or navy secrets and techniques. You’re in all probability not.

However these defensive techniques work, are available and sensible to implement, and you may be far much less prone to do the equal of sitting again and watching the constructing burn whilst you seize a terrific video to share.

In case you choose prevention over recording the aftermath, you could wish to take a look at our risk studies for extra techniques and our @ESETresearch X account for the newest updates on risk exercise.



Waymo hits 100,000 robotaxi rides in only one week

0


Backside line: Waymo’s self-driving taxi service is lastly again on the precise path after overcoming regulatory setbacks in California earlier this summer season. In response to co-CEO Tekedra Mawakana, the corporate just lately surpassed the 100,000 paid journeys per week threshold. It is a important achievement contemplating the corporate solely crossed the 50,000 paid journeys per week mark again in Could, and operates commercially in simply 4 cities.

A Waymo spokesperson instructed CNBC that almost all of its journeys now happen in San Francisco. Phoenix, Austin, and Los Angeles are the three different markets that Waymo’s driverless taxis serve. The corporate’s fleet consists of round 700 automobiles, however that would develop considerably within the close to future.

Again in July, father or mother firm Alphabet introduced it was investing $5 billion extra into the autonomous driving tech firm. Earlier this week, Waymo detailed its newest self-driving expertise, which ought to assist the corporate’s automobiles sort out a wider array of climate situations while not having as many sensors and cameras.

In response to Waymo, its self-driving system is thrice higher at avoiding crashes reported to the police than people, and three.5 occasions higher in avoiding crashes that trigger accidents.

Waymo would not have a lot home competitors in the meanwhile. Final October, Normal Motors subsidiary Cruise halted its driverless program nationwide as a part of an effort to “rebuild public belief.” Earlier that month, one of many firm’s driverless automobiles was concerned in an accident with a pedestrian. In response to a report from the San Francisco Chronicle, a human driver hit a pedestrian, knocking her into the following lane the place she was once more struck. The Cruise car got here to a cease with one among its rear wheels pinning her leg.

Do you’ve got any expertise with robotaxis? The tech hasn’t but made its strategy to a metropolis close to me and even when it was accessible regionally, I am undecided I am able to belief my life to an autonomous car. That might change in just a few years with additional developments however for now, I am extra snug with a human behind the wheel.

This is each iPhone 16 digital camera enchancment you’ll be able to anticipate to see on Apple’s latest telephone

0



Because the iPhone 16 and iPhone 16 Professional launch will get nearer, we’re beginning to get extra rumors in regards to the upcoming units. And now, lower than a month earlier than the anticipated launch, it seems to be like we all know each digital camera enchancment throughout the iPhone 16 line-up.

A brand new report from AppleInsider reveals some new details about the cameras throughout the iPhone 16 units, in addition to rehashing some info we already knew.



Hacktivism is evolving – and that may very well be unhealthy information for organizations in all places


Enterprise Safety, Essential Infrastructure

Hacktivism is nothing new, however the more and more fuzzy traces between conventional hacktivism and state-backed operations make it a stronger risk

Hacktivism is evolving – and that could be bad news for organizations everywhere

Hacktivism surged again into mainstream consciousness with Russia’s invasion of Ukraine in February 2022. Lower than two years later, politically-motivated teams and people have been out in drive once more, this time ostensibly to make their level amid the Israel-Hamas battle. Worryingly, hacktivists have been noticed utilizing more and more subtle and aggressive ways to convey their agendas to public consideration.

Maybe much more disconcerting is the probability that many teams are, in actual fact, both backed by, and even include, nation-state actors. Certainly, the traces between state-sponsored cyber operations and conventional hacktivism have change into fuzzy. In a world more and more characterised by geopolitical instability and an erosion of the previous rules-based order, organizations, particularly these working in essential infrastructure, ought to take into account constructing the hacktivist risk into their danger modelling.

What’s new in hacktivism?

At its most simple, hacktivism is the act of launching cyberattacks for political or social causes. As a sign of the seriousness with which it’s now considered, the Pink Cross final yr issued eight guidelines for “civilian hackers” working throughout wartime, all whereas noting that hacktivists are more and more inflicting disruption to non-military targets resembling hospitals, pharmacies and banks.

READ ALSO: ESET APT Exercise Report This autumn 2023–Q1 2024

Predictably, there’s been little signal of hacktivists adhering to the rules issued by the Pink Cross. Certainly, with attribution nonetheless tough on-line, the professionals of participating in hacktivist exercise nonetheless largely outweigh the cons – particularly if assaults are secretly backed by nation states. 

The previous and the brand new

The present Israel-Hamas battle has drawn unprecedented numbers of activists onto streets world wide. And, in lockstep, it has led to a surge in on-line exercise. A lot of that is much like the ways we’ve seen in earlier hacktivist campaigns, together with:

  • DDoS assaults: Based on some sources, hacktivist-driven DDoS exercise final yr peaked in October at “document ranges, following the battle between Israel and Hamas.” This made Israel the nation most focused by hacktivists; with 1,480 DDoS assaults recorded in 2023, together with some big-name organizations.
  • Net defacement: Over 100 hacktivists launched over 500 internet defacement assaults on Israeli web sites within the week following the October 7 raids, in keeping with Cambridge College researchers. Comparable low-level internet defacements proceed to this present day.
  • Stolen information: Some teams claimed to have stolen and revealed information from Israel and allied organizations. In different phrases, hacktivists can infiltrate company programs to pilfer delicate data earlier than releasing it publicly to embarrass or hurt the goal.

Nevertheless, there are additionally indicators that hacktivism is changing into extra focused and complex:

  • One report prompt hacktivist group AnonGhost exploited an API vulnerability within the “Pink Alert” app, which gives real-time missile alerts for Israeli residents. The group “efficiently intercepted requests, uncovered susceptible servers and APIs, and employed Python scripts to ship spam messages to some customers of the app,” it famous. The group even managed to ship pretend messages to civilians a couple of nuclear bomb.
  • Different reviews famous that hacktivist had posted screenshots indicating that they had entry to Israeli water programs’ SCADA units. The researchers have been unable to confirm these claims, however prompt that hacktivists might have been conducting reconnaissance operations focusing on the sector.

When nation states become involved

Hacktivists with extra superior technical know-how and/or entry to instruments and information on the cybercrime underground might have been behind the latter assaults. Nevertheless, nation state backing can’t be dominated out. Many nations have geopolitical and ideological causes to assault different nations and their allies below the camouflage of hacktivism.

In truth, suspected Russia-affiliated teams appear to have a protracted historical past of doing so, together with below the Nameless Sudan moniker, which has taken down many targets within the West. The group claimed the assault on The Jerusalem Submit and a number of other others focusing on industrial management programs (ICS), together with the Israeli World Navigational Satellite tv for pc Techniques, Constructing Automation and Management Networks and Modbus ICS. One other pro-Russian group, Killnet, claimed to have taken down an Israeli authorities web site and the web site of safety company Shin Wager.

Whereas these assaults are notably excessive profile, there are hints of extra insidious state-backed efforts masquerading as hacktivism. Disinformation efforts embody the use of AI-generated photographs purporting to present missile strikes, tanks rolling by means of ruined neighborhoods, or households combing by means of rubble for survivors.

The main target right here is to generate photographs that create a robust emotional response – resembling one in every of a child crying amidst bomb wreckage, which went viral late final yr. Faux social media and Telegram accounts amplify the disinformation. In a single case, X proprietor Elon Musk apparently promoted a put up from a faked account that was considered 11 million instances earlier than deleting it.

Safety researchers have noticed suspiciously coordinated exercise following the Hamas assault – probably suggesting state involvement. One research claimed at the least 30 hacktivist teams instantly pivoted exercise to the battle inside 48 hours.

How organizations can handle hacktivist dangers

In some ways, whether or not the hacktivist risk comes from real teams, these aligned with state pursuits or covert nation state operatives themselves, the risk stays the identical. Such teams are more and more focusing on non-public sector organizations with the audacity to talk out on political delicate points. In some instances, they could achieve this merely if there’s a notion that the group is aligned to at least one facet or one other. Or as a smokescreen for extra shadowy nation state targets.

Regardless of the rationale, organizations can observe these primary high-level steps to mitigate the hacktivist danger:

  • Ask the fitting questions: Are we a goal? What property are in danger? What’s the extent of our assault floor? Are current measures sufficient to mitigate hacktivist danger? That is the place an intensive cyber-risk evaluation of externally dealing with infrastructure may also help.
  • Plug any gaps revealed by such an evaluation, together with vulnerabilities or misconfigurations – ideally this must be performed in a steady and automatic method.
  • Guarantee property are protected against threats at an e mail, endpoint, community and hybrid cloud layer and constantly monitor for threats with XDR/MDR instruments.
  • Improve id and entry administration with zero belief structure and multi-factor authentication (MFA) and and hold a watch out for suspicious information entry patterns.
  • Use risk intelligence to collect, analyze, and act on details about present and rising threats.
  • Apply strong encryption, each at relaxation and in transit, to guard delicate information from being learn or modified by unauthorized events.
  • Run steady worker schooling and consciousness coaching packages.
  • Associate with a trusted third-party for DDoS mitigation.
  • Construct and take a look at a complete incident response plan.

Hacktivism is nothing new. However the more and more blurred traces between ideologically/politically motivated teams and authorities pursuits makes it a stronger risk. It might be time to rethink your danger administration planning.